mirror of
https://github.com/containers/podman.git
synced 2025-05-17 23:26:08 +08:00

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>
31 lines
948 B
Bash
Executable File
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
|