Files
prysm/hack/check_gazelle.sh
Preston Van Loon 15b1d68249 CI: Add gazelle update-repos check (#16257)
**What type of PR is this?**

Other

**What does this PR do? Why is it needed?**

This wont pass til #16252 merges

**Which issues(s) does this PR fix?**

**Other notes for review**

**Acknowledgements**

- [x] I have read
[CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md).
- [x] I have included a uniquely named [changelog fragment
file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd).
- [x] I have added a description with sufficient context for reviewers
to understand this PR.
- [x] I have tested that my changes work as expected and I added a
testing plan to the PR description (if applicable).
2026-01-15 03:47:34 +00:00

46 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Continuous Integration script to check that BUILD.bazel files and deps.bzl
# are as expected when generated from gazelle.
set -euo pipefail
exit_code=0
# Duplicate redirect 5 to stdout so that it can be captured, but still printed
# nicely.
exec 5>&1
echo "Checking deps.bzl is in sync with go.mod..."
bazel --batch --bazelrc=.buildkite-bazelrc run //:gazelle -- update-repos -from_file=go.mod -to_macro=deps.bzl%prysm_deps -prune=true
if git diff --exit-code deps.bzl; then
echo "OK: deps.bzl is in sync with go.mod"
else
echo ""
echo "FAIL: deps.bzl is out of sync with go.mod"
exit_code=1
fi
echo ""
echo "Checking BUILD.bazel files..."
build_changes=$(bazel --batch --bazelrc=.buildkite-bazelrc run //:gazelle -- fix --mode=diff | tee >(cat - >&5)) || true
if [ -z "$build_changes" ]; then
echo "OK: BUILD.bazel files are in sync"
else
echo "FAIL: BUILD.bazel files are out of sync"
exit_code=1
fi
echo ""
if [ $exit_code -eq 0 ]; then
echo "All gazelle checks passed"
else
echo "Gazelle checks failed. Please run:"
echo " bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=deps.bzl%prysm_deps -prune=true"
echo " bazel run //:gazelle -- fix"
fi
exit $exit_code