Skip to content

Commit

Permalink
Check go.mod and go.sum are up to date in gomod presubmit and continu…
Browse files Browse the repository at this point in the history
…ous jobs

This change modifies `kokoro/testutils/check_go_generated_files_up_to_date.sh` to avoid trying to generate Bazel files, which are no longer needed.

PiperOrigin-RevId: 683533449
Change-Id: I1e2129f128701015fad17da35df3a3f0c8676197
  • Loading branch information
morambro authored and copybara-github committed Oct 8, 2024
1 parent ad2029a commit e9da237
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
2 changes: 2 additions & 0 deletions kokoro/gcp_ubuntu/gomod/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ fi
readonly MODULE_URL="github.com/tink-crypto/tink-go-awskms"
readonly MODULE_VERSION="$(cat version.bzl | grep ^TINK | cut -f 2 -d \")"

./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/check_go_generated_files_up_to_date.sh .
./kokoro/testutils/copy_credentials.sh "testdata" "aws"
./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
./kokoro/testutils/run_go_mod_tests.sh "${MODULE_URL}" . \
Expand Down
25 changes: 2 additions & 23 deletions kokoro/testutils/check_go_generated_files_up_to_date.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
# This scripts checks that a given Go workspace has its generated Bazel files up
# to date.

BAZEL_CMD="bazel"
# Use Bazelisk (https://github.com/bazelbuild/bazelisk) if available.
if command -v "bazelisk" &> /dev/null; then
BAZEL_CMD="bazelisk"
"${BAZEL_CMD}" version
fi

usage() {
echo "Usage: $0 [-h] [-c <compat value (default 1.19)>] <go project dir>"
echo " -c: Value to pass to `-compat`. Default to 1.19."
Expand Down Expand Up @@ -59,16 +52,10 @@ main() {
local -r go_generated_files=(
./go.mod
./go.sum
./deps.bzl
)

# Copy all current generated files into temp_dir_current_generated_files.
local current_go_generated_files=( "${go_generated_files[@]}" )
while read -r -d $'\0' generated_file; do
current_go_generated_files+=("${generated_file}")
done < <(find . -name BUILD.bazel -print0)
readonly current_go_generated_files

local -r current_go_generated_files=( "${go_generated_files[@]}" )
for generated_file_path in "${current_go_generated_files[@]}"; do
mkdir -p \
"$(dirname \
Expand All @@ -79,17 +66,9 @@ main() {

# Update build files.
go mod tidy -compat="${COMPAT}"
# Update deps.bzl.
"${BAZEL_CMD}" run //:gazelle-update-repos
# Update all BUILD.bazel files.
"${BAZEL_CMD}" run //:gazelle

# Compare current with new build files.
local new_go_generated_files=( "${go_generated_files[@]}" )
while read -r -d $'\0' generated_file; do
new_go_generated_files+=("${generated_file}")
done < <(find . -name BUILD.bazel -print0)
readonly new_go_generated_files
local -r new_go_generated_files=( "${go_generated_files[@]}" )

for generated_file_path in "${new_go_generated_files[@]}"; do
if ! cmp -s "${generated_file_path}" \
Expand Down

0 comments on commit e9da237

Please sign in to comment.