github.com/containers/podman/v5@v5.1.0-rc1/hack/golangci-lint.sh (about) 1 #!/bin/bash 2 3 # Need to run linter twice to cover all the build tags code paths 4 set -e 5 6 # WARNING: This script executes on multiple operating systems that 7 # do not have the same version of Bash. Specifically, Darwin uses 8 # a very old version, where modern features (like `declare -A`) are 9 # absent. 10 11 # Makefile calls script with the 'run' argument, but developers may not. 12 # Handle both cases transparently. 13 [[ $1 == run ]] && shift 14 15 BUILD_TAGS_DEFAULT="apparmor,seccomp,selinux" 16 BUILD_TAGS_ABI="$BUILD_TAGS_DEFAULT,systemd" 17 BUILD_TAGS_TUNNEL="$BUILD_TAGS_DEFAULT,remote" 18 BUILD_TAGS_REMOTE="remote,containers_image_openpgp" 19 20 SKIP_DIRS_ABI="" 21 SKIP_DIRS_TUNNEL="pkg/api,pkg/domain/infra/abi" 22 SKIP_DIRS_REMOTE="libpod/events,pkg/api,pkg/domain/infra/abi,pkg/machine/qemu,pkg/trust,test" 23 24 declare -a to_lint 25 to_lint=(ABI TUNNEL REMOTE) 26 27 # Special-case, for Darwin and Windows only "remote" linting is possible and required. 28 if [[ "$GOOS" == "windows" ]] || [[ "$GOOS" == "darwin" ]]; then 29 to_lint=(REMOTE) 30 fi 31 32 for to_lint in "${to_lint[@]}"; do 33 tags_var="BUILD_TAGS_${to_lint}" 34 skip_var="SKIP_DIRS_${to_lint}" 35 echo "" 36 echo Running golangci-lint for "$to_lint" 37 echo Build Tags "$to_lint": ${!tags_var} 38 echo Skipped directories "$to_lint": ${!skip_var} 39 ( 40 # Make it really easy for a developer to copy-paste the command-line 41 # to focus or debug a single, specific linting category. 42 set -x 43 ./bin/golangci-lint run --timeout=10m --build-tags="${!tags_var}" --exclude-dirs="${!skip_var}" "$@" 44 ) 45 done