Skip to content

Commit

Permalink
Changed the lint script so the fast tests are run first (#6093)
Browse files Browse the repository at this point in the history
This enables us to fail fast

What changed?
Changed the lint script so the fast tests are run first

Why?
go-generate takes up to 5 minutes and there is no reason to wait for this if the linter is failing. This should increase developer velocity by failing the lint check faster

How did you test it?

Potential risks

Release notes

Documentation Changes
  • Loading branch information
jakobht committed Jun 11, 2024
1 parent 080dec9 commit 50dce23
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions scripts/buildkite/golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,35 @@

set -ex

verify_no_files_changed () {
# intentionally capture stderr, so status-errors are also PR-failing.
# in particular this catches "dubious ownership" failures, which otherwise
# do not fail this check and the $() hides the exit code.
NUM_FILES_CHANGED=$(git status --porcelain 2>&1 | wc -l)
if [ "${NUM_FILES_CHANGED}" -ne 0 ]; then
printf "There file changes after applying your diff and performing a build.\n"
printf "Please run this command and commit the changes:\n"
printf "\tmake tidy && make copyright && make go-generate && make fmt && make lint\n"
git status --porcelain
git --no-pager diff
exit 1
fi
}

# Run the fast checks first, to fail quickly.
make tidy
make copyright
make fmt
make lint

verify_no_files_changed

# Run go-generate after the fast checks, to avoid unnecessary waiting
# We need to run copyright, fmt and lint after, as the generated files
# may change the output of these commands.
make go-generate
make copyright
make fmt
make lint

# intentionally capture stderr, so status-errors are also PR-failing.
# in particular this catches "dubious ownership" failures, which otherwise
# do not fail this check and the $() hides the exit code.
if [ -n "$(git status --porcelain 2>&1)" ]; then
echo "There file changes after applying your diff and performing a build."
echo "Please run this command and commit the changes:"
echo "\tmake tidy && make copyright && make go-generate && make fmt && make lint"
git status --porcelain
git --no-pager diff
exit 1
fi
verify_no_files_changed

0 comments on commit 50dce23

Please sign in to comment.