13 Commits

Author SHA1 Message Date
403d126ac8 hack/install_golang.sh: revamp
1. Strip leading v from VERSION.

This will allow to simplify renovate rule at [1].

2. Fix git branch in the URL.

In golangci-lint v2 they've switched from master to main,
and it's not clear what will happen to master over time,
so let's just switch to main prophylactically.

3. Use -b option instead of undocumented hack.

Instead of relying on an undocumented feature of having BINDIR,
let's use -b option as recommended by the official docs at [2].

4. Avoid stuttering in the output.

Before:

	[kir@kir-tp1 podman]$ VERSION=2.0.2 ./hack/install_golangci.sh
	golangci-lint has version 2.0.2 built with go1.24.1 from 2b224c2c on 2025-03-25T21:36:18Z
	Using existing ./bin/golangci-lint has version 2.0.2 built with go1.24.1 from 2b224c2c on 2025-03-25T21:36:18Z

After:

	[kir@kir-tp1 podman]$ VERSION=2.0.2 ./hack/install_golangci.sh
	golangci-lint has version 2.0.2 built with go1.24.1 from 2b224c2c on 2025-03-25T21:36:18Z
	Using existing ./bin/golangci-lint

5. Fix shellcheck warnings.

6. Also retry when reinstalling.

The code logic to retry install for up to 5 times when installation
fails was introduced by commit dd8574022d ("CI: retry the golangci
install").

For some reason, the above commit only uses the logic when the binary is
not found. In a situation when the binary is found but is of the wrong
version, no retries are done.

Fix that.

7. Add -f option to curl.

As recommended by the official installation docs at [2].

[1]: 16f757f699/renovate/defaults.json5 (L106-L108)
[2]: https://golangci-lint.run/welcome/install/#binaries

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-02 19:19:05 -07:00
dd8574022d CI: retry the golangci install
It flakes once or twice a day:

   VERSION=1.51.1 ./hack/install_golangci.sh
   Installing golangci-lint v1.51.1 into ./bin/golangci-lint
   golangci/golangci-lint info checking GitHub for tag 'v1.51.1'
   golangci/golangci-lint crit unable to find 'v1.51.1' - use 'latest'
      or see https://github.com/golangci/golangci-lint/releases for details

No visibility into why, and no special reason to believe that
retrying five seconds later will work, but it seems worth a try.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-03-27 10:53:17 -06:00
bb2b47dc70 Add swagger install + allow version updates in CI
Support swagger testing and optional runtime updates similar to
the current golangci-lint tool.  This allows developers to update the
version of swagger at runtime if needed.  Otherwise new CI VM images
will pick up the prescribed version at image build-time via
`make install.tools`.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-10-14 08:18:52 -04:00
0fb95f95d2 CI: only make install.tools when needed
Reintroduce .install.foo targets into Makefile, and invoke
only the bare-minimum ones needed for each individual CI
step in setup_environment.sh.

Also add a retry to the golangci-lint curl, in hopes of
dealing with network flakes. And remove the -f (fail)
because it produces unhelpful logs.

Reason: saw about 25% CI flakes yesterday due to the golangci-lint
fetch, something about a timeout, and this was especially frustrating
because none of the steps actually needed lint. Quick reminder:
avoid network fetches unless absolutely necessary.

Fixes: #15892

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-09-27 05:52:34 -06:00
791dbf8232 golangci install: explicitly set BINDIR
The golangci installer (which is curl pipe sh, ewww) installs
into $BINDIR, which it gets from the caller's environment.
Make sure we set it explicitly.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-07-05 15:59:32 -06:00
e5a86d293f CI: fix golangci-lint installation
avoid this warn:
```
golangci/golangci-lint info installed ./bin/golangci-lint
golangci/golangci-lint err this script is deprecated, please do not use it anymore. check https://github.com/goreleaser/godownloader/issues/207
```

Signed-off-by: Pascal Bourdier <pascal.bourdier@gmail.com>
2022-03-10 08:41:23 +01:00
caaaa2c5e1 hack/install_golangci.sh: smarter install
Detect if the installed version of golangci-lint is outdated and update
it if needed.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-17 17:15:23 +01:00
f38b7f48cc golangci-lint: install to ./bin
Install golangci-lint to `./bin` instead of `$GOBIN`.  The latter may be
shared with other projects who require a different version.  Having a
shared version of golangci-lint is a reoccurring source of red herrings
on my work station, so I think it's time to split them.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-17 17:07:04 +01:00
4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
ba9f18e2b8 Use bash binary from env instead of /bin/bash for scripts
It's not possible to run any of the scripts on distributions which do
have `bash` not in `/bin`. This is being fixed by using `/usr/bin/env
bash` instead.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-17 10:42:23 +02:00
d0782e7839 Cirrus: Fix gate image & false-positive exits
A number of scripts relating to tooling used and the gate container
image were not exiting upon errors as intended.  Coupled with
external service unavailability (i.e. downloading golangci-lint)
was observed to cause difficult to debug failures.

This change corrects the scripts inside/out of the gate container as
well as fixes many golang related path consistency problems vs other CI
jobs.  After this change, all jobs use consistent path names reducing
the number of special-case overrides needed.

Lastly, I also made a documentation-pass, updating/correcting as needed,
including documenting a likely local validation-failure mode, related to
`$EPOCH_TEST_COMMIT`.  This is dependent on the developers git
environment, so documentation is the only possible "fix".

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-03-02 08:50:54 -05:00
d4ca3197b6 hack/install_golangci.sh: check env vars
Also make it executable and `set -eo pipefail`.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-16 15:26:25 +01:00
b830d3eb07 make .install.golangci-lint: force specific version
Instead of only performing a presence check of the binary, also do a
version check and force installing the specified one if needed.  This
will prevent users and the CI from using a wrong version in the future.

Move the logic into a dedicated shell script as I find built-in bash in
Makefiles hard to maintain.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-15 08:55:46 +01:00