Skip to content

Commit f18c917

Browse files
committed
ci: run golangci-lint on freebsd
This could have been done by simply running GOOS=freebsd ./bin/golangci-lint run [options] ./... on Linux, but some freebsd code is using cgo (i.e. is linked to C libraries), so real freebsd environment is required. This also fixes the issue of ignoring linter errors for Windows and Darwin (exit 0), introduced by commit c9b108d. Fixes: c9b108d ("Bump golangci-lint to v2.0.2") Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 7882de9 commit f18c917

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

.cirrus.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ freebsd_alt_build_task:
330330
image_family: freebsd-13-4
331331
setup_script:
332332
- pkg install -y gpgme bash go-md2man gmake gsed gnugrep go pkgconf zstd
333+
lint_script:
334+
- gmake golangci-lint
333335
build_amd64_script:
334336
- gmake podman-release
335337
# This task cannot make use of the shared repo.tar.zst artifact and must

hack/golangci-lint.sh

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Run golangci-lint with different sets of build tags.
44
set -e
@@ -8,23 +8,29 @@ set -e
88
# a very old version, where modern features (like `declare -A`) are
99
# absent.
1010

11+
declare -a EXTRA_TAGS
12+
1113
echo "Linting for GOOS=$GOOS"
12-
# Special case: for Darwin and Windows only "remote" linting is possible and required.
13-
if [[ "$GOOS" == "windows" || "$GOOS" == "darwin" ]]; then
14-
(
15-
set -x
16-
./bin/golangci-lint run --build-tags="remote,containers_image_openpgp" "$@"
17-
)
18-
exit 0
19-
fi
14+
case "$GOOS" in
15+
windows|darwin)
16+
# For Darwin and Windows, only "remote" linting is possible and required.
17+
TAGS="remote,containers_image_openpgp"
18+
;;
19+
freebsd)
20+
TAGS="containers_image_openpgp"
21+
EXTRA_TAGS=(",remote")
22+
;;
23+
*)
24+
# Assume Linux: run linter for various sets of build tags.
25+
TAGS="apparmor,seccomp,selinux"
26+
EXTRA_TAGS=(",systemd" ",remote")
27+
esac
2028

21-
# Normal case (Linux): run linter for various sets of build tags.
22-
TAGS="apparmor,seccomp,selinux"
23-
for EXTRA_TAGS in "" ",systemd" ",remote"; do
29+
for EXTRA in "" "${EXTRA_TAGS[@]}"; do
30+
# Use set -x in a subshell to make it easy for a developer to copy-paste
31+
# the command-line to focus or debug a single, specific linting category.
2432
(
25-
# Make it really easy for a developer to copy-paste the command-line
26-
# to focus or debug a single, specific linting category.
2733
set -x
28-
./bin/golangci-lint run --build-tags="${TAGS}${EXTRA_TAGS}" "$@"
34+
./bin/golangci-lint run --build-tags="${TAGS}${EXTRA}" "$@"
2935
)
3036
done
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package e2e_test
2+
3+
const podmanBinary = "../../../bin/podman-remote"
4+
5+
func getOtherProvider() string {
6+
return ""
7+
}

0 commit comments

Comments
 (0)