ci: lint all modules even if one module fails (#15819)
This commit is contained in:
parent
001c11e00d
commit
3cef1a8941
4
Makefile
4
Makefile
@ -379,12 +379,12 @@ golangci_version=v1.51.2
|
||||
lint:
|
||||
@echo "--> Running linter"
|
||||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
|
||||
@sh ./scripts/go-lint-all.sh --timeout=15m
|
||||
@./scripts/go-lint-all.bash --timeout=15m
|
||||
|
||||
lint-fix:
|
||||
@echo "--> Running linter"
|
||||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
|
||||
@sh ./scripts/go-lint-all.sh --fix
|
||||
@./scripts/go-lint-all.bash --fix
|
||||
|
||||
.PHONY: lint lint-fix
|
||||
|
||||
|
||||
18
scripts/go-lint-all.bash
Executable file
18
scripts/go-lint-all.bash
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
REPO_ROOT="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )"
|
||||
export REPO_ROOT
|
||||
|
||||
lint_module() {
|
||||
local root="$1"
|
||||
shift
|
||||
cd "$(dirname "$root")" &&
|
||||
echo "linting $(grep "^module" go.mod) [$(date -Iseconds -u)]" &&
|
||||
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@"
|
||||
}
|
||||
export -f lint_module
|
||||
|
||||
find "${REPO_ROOT}" -type f -name go.mod -print0 |
|
||||
xargs -0 -I{} bash -c 'lint_module "$@"' _ {} "$@" # Prepend go.mod file before command-line args.
|
||||
@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
export pwd=$(pwd)
|
||||
|
||||
for modfile in $(find . -name go.mod); do
|
||||
echo "linting $(dirname $modfile)"
|
||||
DIR=$(dirname $modfile)
|
||||
(cd $DIR; golangci-lint run ./... -c $pwd/.golangci.yml $@)
|
||||
done
|
||||
Loading…
Reference in New Issue
Block a user