Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Update check-deps with check-only option #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions dev-scripts/dependencies/check-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,22 @@
#
# Wrapper script around bazel-deps to generate third_party files, and check if they differ from what's at HEAD. Exits 0
# if they match, non-zero otherwise.
# TODO(https://github.com/johnynek/bazel-deps/issues/85): Drop once issue is fixed.
# TODO(https://github.com/johnynek/bazel-deps/issues/62): check-deps.sh can be used in CI once fixed. Without this fix,
# the check falsely claims thirdparty/jvm/com/google/auto/value/BUILD is not up to date.

set -eu

SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

hash_of_third_party_files() {
find thirdparty -type f | sort | xargs sha1sum
}

BEFORE=$(hash_of_third_party_files)

# shellcheck disable=SC1090
"$SCRIPT_DIR/generate.sh"

AFTER=$(hash_of_third_party_files)
. "$SCRIPT_DIR/setup.sh"

# Fail if the generated files don't match what's committed.
if ! diff -u <(echo "$BEFORE") <(echo "$AFTER")
if ! "$BAZEL_DEPS_DIR/gen_maven_deps.sh" generate --check-only --buildifier buildifier --repo-root "${ROOT_DIR}" --sha-file thirdparty/workspace.bzl --deps maven_deps.yaml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can should use --buildifier in setup.sh as well for consistency

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! I have that in #27.

then
echo
echo "* * *"
echo "Generated dependency files are not up to date. Run \`dev-scripts/dependencies/generate.sh\` and commit the changes."
echo "* * *"
echo
exit 2
else
echo
echo "Generated dependency files are up to date."
echo
fi
fi