Skip to content

Commit 957a902

Browse files
committed
One check
1 parent 3b6e453 commit 957a902

File tree

2 files changed

+50
-30
lines changed

2 files changed

+50
-30
lines changed

build/ci/cloudbuild.merge_test.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

build/ci/cloudbuild.test.yaml

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@
1313
# limitations under the License.
1414

1515
steps:
16+
# Step 1: Set up environment variables based on the GitHub event.
17+
# This step creates a file that other steps can source.
18+
- name: "gcr.io/cloud-builders/gcloud" # Using a small, common image
19+
id: "check-event-name"
20+
entrypoint: "bash"
21+
args:
22+
- -c
23+
- |
24+
set -e
25+
echo "Setting environment for event: $_GITHUB_EVENT_NAME"
26+
if [[ -z "$_GITHUB_EVENT_NAME "]]; then
27+
echo "Error: Expected \$_GITHUB_EVENT_NAME substitution."
28+
echo "Please update the associated build trigger."
29+
exit 1
30+
fi
31+
if [ "$_GITHUB_EVENT_NAME" = "merge_group" ]; then
32+
echo "export IS_MERGE_QUEUE=true" > /workspace/env.sh
33+
else
34+
echo "export IS_MERGE_QUEUE=false" > /workspace/env.sh
35+
fi
36+
waitFor: ["-"]
37+
1638
# Validate BQ version file and run golangci-lint
1739
- id: lint
1840
name: gcr.io/datcom-ci/full-env:${_FULL_ENV_VERSION}
@@ -21,13 +43,18 @@ steps:
2143
- -c
2244
- |
2345
set -e
46+
source /workspace/env.sh
47+
if [ "$IS_MERGE_QUEUE" = "false" ]; then
48+
echo "Skipping build-proto for merge queue"
49+
exit 0
50+
fi
2451
c=`cat deploy/storage/bigquery.version | wc -l`
2552
if [ "$c" != "0" ]; then
2653
echo "bigquery.version should not have end of file newline"
2754
exit 1
2855
fi
2956
golangci-lint run -v
30-
waitFor: ["-"]
57+
waitFor: ["check-event-name"]
3158

3259
# Validate feature flag yaml files
3360
- id: validate-feature-flags
@@ -37,8 +64,13 @@ steps:
3764
- -c
3865
- |
3966
set -e
67+
source /workspace/env.sh
68+
if [ "$IS_MERGE_QUEUE" = "false" ]; then
69+
echo "Skipping validate-feature-flags for merge queue"
70+
exit 0
71+
fi
4072
./scripts/check_flags.sh deploy/featureflags
41-
waitFor: ["lint"]
73+
waitFor: ["lint", "check-event-name"]
4274

4375
# Build protobuf to go bindings
4476
- id: build-proto
@@ -48,24 +80,35 @@ steps:
4880
- -c
4981
- |
5082
set -e
83+
source /workspace/env.sh
84+
if [ "$IS_MERGE_QUEUE" = "false" ]; then
85+
echo "Skipping build-proto for merge queue"
86+
exit 0
87+
fi
5188
protoc \
5289
--proto_path=proto \
5390
--go_out=paths=source_relative:internal/proto \
5491
--go-grpc_out=paths=source_relative:internal/proto \
5592
--go-grpc_opt=require_unimplemented_servers=false \
5693
--experimental_allow_proto3_optional \
5794
proto/*.proto proto/**/*.proto
58-
waitFor: ["lint"]
95+
waitFor: ["lint", "check-event-name"]
5996

60-
- id: test
61-
name: gcr.io/datcom-ci/full-env:${_FULL_ENV_VERSION}
97+
# Step 3: Runs the merge restriction check ONLY for merge queue events.
98+
- name: "gcr.io/cloud-builders/git"
99+
id: "enforce-flag-merge-restrictions"
62100
entrypoint: "bash"
63101
args:
64102
- -c
65103
- |
66104
set -e
67-
go test -v ./...
68-
waitFor: ["build-proto"]
105+
source /workspace/env.sh
106+
if [ "$IS_MERGE_QUEUE" = "true" ]; then
107+
echo "Waiting to enforce flag restrictions until merge queue"
108+
exit 0
109+
fi
110+
./deploy/featureflags/enforce_merge_restrictions.sh deploy/featureflags
111+
waitFor: ["check-event-name"]
69112

70113
substitutions:
71114
_FULL_ENV_VERSION: "mixer-only-2025-10-02"

0 commit comments

Comments
 (0)