Files
podman/hack/golangci-lint.sh
Kir Kolyshkin c9b108d5b3 Bump golangci-lint to v2.0.2
This ended up slightly more complicated than anticipated, tin part
because golangci-lint v2 dropped support for --exclude-dirs, so
linter issues with GOOS=windows and GOOS=darwin which were previously
ignored had to be fixed now.

This is also the reason why the ./hack/golangci-lint was simplified.
In addition, it now runs linters on Linux without systemd tag set.

Tested locally with:

	for OS in linux windows darwin; do GOOS=$OS ./hack/golangci-lint.sh; done
	Linting for GOOS=linux
	+ ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux
	0 issues.
	+ ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux,systemd
	0 issues.
	+ ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux,remote
	0 issues.
	Linting for GOOS=windows
	+ ./bin/golangci-lint run --build-tags=remote,containers_image_openpgp
	0 issues.
	Linting for GOOS=darwin
	+ ./bin/golangci-lint run --build-tags=remote,containers_image_openpgp
	0 issues.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 12:27:55 -07:00

31 lines
948 B
Bash
Executable File

#!/bin/bash
# Run golangci-lint with different sets of build tags.
set -e
# WARNING: This script executes on multiple operating systems that
# do not have the same version of Bash. Specifically, Darwin uses
# a very old version, where modern features (like `declare -A`) are
# absent.
echo "Linting for GOOS=$GOOS"
# Special case: for Darwin and Windows only "remote" linting is possible and required.
if [[ "$GOOS" == "windows" || "$GOOS" == "darwin" ]]; then
(
set -x
./bin/golangci-lint run --build-tags="remote,containers_image_openpgp" "$@"
)
exit 0
fi
# Normal case (Linux): run linter for various sets of build tags.
TAGS="apparmor,seccomp,selinux"
for EXTRA_TAGS in "" ",systemd" ",remote"; do
(
# Make it really easy for a developer to copy-paste the command-line
# to focus or debug a single, specific linting category.
set -x
./bin/golangci-lint run --build-tags="${TAGS}${EXTRA_TAGS}" "$@"
)
done