13
13
# limitations under the License.
14
14
15
15
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
+
16
38
# Validate BQ version file and run golangci-lint
17
39
- id : lint
18
40
name : gcr.io/datcom-ci/full-env:${_FULL_ENV_VERSION}
@@ -21,13 +43,18 @@ steps:
21
43
- -c
22
44
- |
23
45
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
24
51
c=`cat deploy/storage/bigquery.version | wc -l`
25
52
if [ "$c" != "0" ]; then
26
53
echo "bigquery.version should not have end of file newline"
27
54
exit 1
28
55
fi
29
56
golangci-lint run -v
30
- waitFor : ["- "]
57
+ waitFor : ["check-event-name "]
31
58
32
59
# Validate feature flag yaml files
33
60
- id : validate-feature-flags
@@ -37,8 +64,13 @@ steps:
37
64
- -c
38
65
- |
39
66
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
40
72
./scripts/check_flags.sh deploy/featureflags
41
- waitFor : ["lint"]
73
+ waitFor : ["lint", "check-event-name" ]
42
74
43
75
# Build protobuf to go bindings
44
76
- id : build-proto
@@ -48,24 +80,35 @@ steps:
48
80
- -c
49
81
- |
50
82
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
51
88
protoc \
52
89
--proto_path=proto \
53
90
--go_out=paths=source_relative:internal/proto \
54
91
--go-grpc_out=paths=source_relative:internal/proto \
55
92
--go-grpc_opt=require_unimplemented_servers=false \
56
93
--experimental_allow_proto3_optional \
57
94
proto/*.proto proto/**/*.proto
58
- waitFor : ["lint"]
95
+ waitFor : ["lint", "check-event-name" ]
59
96
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"
62
100
entrypoint : " bash"
63
101
args :
64
102
- -c
65
103
- |
66
104
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"]
69
112
70
113
substitutions :
71
114
_FULL_ENV_VERSION : " mixer-only-2025-10-02"
0 commit comments