Skip to content

Commit 2e3489c

Browse files
morambrocopybara-github
authored andcommitted
Check go.mod and go.sum are up to date in gomod presubmit and continuous 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: Ib740372804dc3aff64b3d04ba4e6ca912cdc407c
1 parent fe64476 commit 2e3489c

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

kokoro/gcp_ubuntu/gomod/run_tests.sh

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ fi
3939
readonly TINK_GO_HCVAULT_MODULE_URL="github.com/tink-crypto/tink-go-hcvault"
4040
readonly TINK_GO_HCVAULT_VERSION="$(cat version.bzl | grep ^TINK | cut -f 2 -d \")"
4141

42+
./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
43+
./kokoro/testutils/check_go_generated_files_up_to_date.sh .
4244
./kokoro/testutils/run_command.sh "${RUN_COMMAND_ARGS[@]}" \
4345
./kokoro/testutils/run_go_mod_tests.sh "${TINK_GO_HCVAULT_MODULE_URL}" . \
4446
"${TINK_GO_HCVAULT_VERSION}" "main"

kokoro/testutils/check_go_generated_files_up_to_date.sh

+2-23
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
# This scripts checks that a given Go workspace has its generated Bazel files up
1818
# to date.
1919

20-
BAZEL_CMD="bazel"
21-
# Use Bazelisk (https://github.com/bazelbuild/bazelisk) if available.
22-
if command -v "bazelisk" &> /dev/null; then
23-
BAZEL_CMD="bazelisk"
24-
"${BAZEL_CMD}" version
25-
fi
26-
2720
usage() {
2821
echo "Usage: $0 [-h] [-c <compat value (default 1.19)>] <go project dir>"
2922
echo " -c: Value to pass to `-compat`. Default to 1.19."
@@ -59,16 +52,10 @@ main() {
5952
local -r go_generated_files=(
6053
./go.mod
6154
./go.sum
62-
./deps.bzl
6355
)
6456

6557
# Copy all current generated files into temp_dir_current_generated_files.
66-
local current_go_generated_files=( "${go_generated_files[@]}" )
67-
while read -r -d $'\0' generated_file; do
68-
current_go_generated_files+=("${generated_file}")
69-
done < <(find . -name BUILD.bazel -print0)
70-
readonly current_go_generated_files
71-
58+
local -r current_go_generated_files=( "${go_generated_files[@]}" )
7259
for generated_file_path in "${current_go_generated_files[@]}"; do
7360
mkdir -p \
7461
"$(dirname \
@@ -79,17 +66,9 @@ main() {
7966

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

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

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

0 commit comments

Comments
 (0)