Skip to content

Commit

Permalink
ci: lint all modules even if one module fails
Browse files Browse the repository at this point in the history
The previous implementation stopped linting when it encountered its
first module that failed the linter.

Now, use a more idiomatic find|xargs pattern, which will run every
module and exit non-zero if any module fails to lint. This will speed up
the feedback cycle on CI in the event that multiple modules fail
linting.
  • Loading branch information
mark-rushakoff committed Apr 12, 2023
1 parent 1641bb9 commit 20e836b
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions scripts/go-lint-all.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
#!/usr/bin/env bash

set -eu
set -eu -o pipefail

export pwd=$(pwd)
if [ $# -ne 0 ]; then
>&2 echo "USAGE: $0
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
Runs golang-ci lint against all modules in the cosmos-sdk git repository"

exit 1
fi

REPO_ROOT="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )"
export REPO_ROOT

lint_module() {
cd "$(dirname "$1")" &&
echo "linting $(grep "^module" go.mod)" &&
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 "$1"' _ {}

0 comments on commit 20e836b

Please sign in to comment.