2018-07-26 05:13:07 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Continous Integration script to check that BUILD.bazel files have the correct
|
|
|
|
# visibility.
|
|
|
|
|
|
|
|
# Protected packages are:
|
|
|
|
# //beacon-chain/...
|
2018-08-24 15:15:12 +00:00
|
|
|
# //validator/...
|
2018-07-26 05:13:07 +00:00
|
|
|
|
|
|
|
# Duplicate redirect 5 to stdout so that it can be captured, but still printed
|
|
|
|
# nicely.
|
|
|
|
exec 5>&1
|
|
|
|
|
|
|
|
# Run gazelle while piping a copy of the output to stdout via 5.
|
|
|
|
changes=$(
|
2018-11-21 12:35:47 +00:00
|
|
|
bazel --batch --bazelrc=.buildkite-bazelrc query 'visible(//... except (//beacon-chain/... union //validator/...), (//beacon-chain/... union //validator/...))' | tee >(cat - >&5)
|
2018-07-26 05:13:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# If the captured stdout is not empty then targets are exposed!
|
|
|
|
if [ -z "$changes" ]
|
|
|
|
then
|
|
|
|
echo "OK: Visibility is good."
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "FAIL: The above targets belong to protected packages and the targets \
|
|
|
|
are visible outside of their package!"
|
|
|
|
echo "Please reduce the target visibility."
|
|
|
|
exit 1
|
|
|
|
fi
|