77 description : Name of workflow
88 required : false
99 type : string
10+ ref :
11+ description : Git ref to checkout (branch, tag, or SHA)
12+ required : false
13+ type : string
14+ default : ' '
1015 run :
1116 description : Bazel command to run
1217 required : true
2126 required : false
2227 type : string
2328 default : ' '
24- browser-version :
25- description : One of stable, latest, latest-beta or latest-devedition
26- required : false
27- type : string
28- default : ' '
2929 caching :
3030 description : Toggle caching of Bazel
3131 required : false
3232 type : boolean
3333 default : true
34- dotnet-version :
35- description : Custom DotNet version to install
36- required : false
37- type : string
38- default : ' '
39- java-version :
40- description : Custom Java version to install
41- required : false
42- type : string
43- default : ' '
4434 node-version :
4535 description : Custom Node version to install
4636 required : false
5646 required : false
5747 type : string
5848 default : ' '
59- nightly-release-files :
60- description : Files to upload to the Nightly release tag
49+ artifact-name :
50+ description : Name of artifact to upload
6151 required : false
6252 type : string
6353 default : ' '
64- artifact-name :
65- description : Name of artifact to upload
54+ artifact-path :
55+ description : Path/glob of files to upload (if empty, uploads git diff as changes.patch)
6656 required : false
6757 type : string
68- default : ' ignore-artifacts'
58+ default : ' '
59+ rerun-with-debug :
60+ description : Rerun failing tests with debugging enabled
61+ required : false
62+ type : boolean
63+ default : false
64+ gpg-sign :
65+ description : Import GPG key for signing (Java releases)
66+ required : false
67+ type : boolean
68+ default : false
69+ fetch-depth :
70+ description : Number of commits to fetch (0 for full history, empty for auto-detect)
71+ required : false
72+ type : string
73+ default : ' '
74+ cache-name :
75+ description : Name for cache restore (restores {name}.gz with key {name}-)
76+ required : false
77+ type : string
78+ default : ' '
6979
7080jobs :
7181 bazel :
@@ -76,21 +86,53 @@ jobs:
7686 SEL_M2_USER : ${{ secrets.SEL_M2_USER }}
7787 SEL_M2_PASS : ${{ secrets.SEL_M2_PASS }}
7888 TWINE_PASSWORD : ${{ secrets.TWINE_PASSWORD }}
79- TWINE_USERNAME : ${{ secrets.TWINE_USERNAME }}
80- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
81- SE_AVOID_STATS : true
89+ GEM_HOST_API_KEY : ${{ secrets.GEM_HOST_API_KEY }}
90+ NUGET_API_KEY : ${{ secrets.NUGET_API_KEY }}
91+ NODE_AUTH_TOKEN : ${{ secrets.NODE_AUTH_TOKEN }}
8292 steps :
93+ - name : Calculate fetch depth
94+ id : depth
95+ shell : bash
96+ env :
97+ FETCH_DEPTH : ${{ inputs.fetch-depth }}
98+ PR_COMMITS : ${{ github.event.pull_request.commits }}
99+ run : |
100+ # Use explicit value if provided
101+ if [ -n "$FETCH_DEPTH" ]; then
102+ echo "val=$FETCH_DEPTH" >> "$GITHUB_OUTPUT"
103+ # For PRs, use commit count plus buffer for merge base
104+ elif [ -n "$PR_COMMITS" ]; then
105+ echo "val=$((PR_COMMITS + 2))" >> "$GITHUB_OUTPUT"
106+ # For push events, read commit count from event payload
107+ else
108+ COMMIT_COUNT=$(jq -e '.commits | length // 0' "$GITHUB_EVENT_PATH" 2>/dev/null) || COMMIT_COUNT=0
109+ echo "val=$((COMMIT_COUNT + 1))" >> "$GITHUB_OUTPUT"
110+ fi
83111 - name : Checkout source tree
84112 uses : actions/checkout@v4
113+ with :
114+ ref : ${{ inputs.ref || github.ref }}
115+ fetch-depth : ${{ steps.depth.outputs.val }}
116+ - name : Fetch base ref for PR comparison
117+ if : github.event.pull_request.base.sha
118+ run : git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }}
85119 - name : Pull latest changes from head ref for PRs
86120 if : contains(github.head_ref, 'renovate/')
87- run : git pull origin ${{ github.head_ref }}
121+ run : git pull origin "$HEAD_REF"
122+ env :
123+ HEAD_REF : ${{ github.head_ref }}
88124 - name : Pull latest changes from ref for branch pushes
89125 if : contains(github.ref, 'renovate/')
90- run : git pull origin ${{ github.ref }}
91- - name : Free space
92- if : inputs.os != 'windows'
93- run : ./scripts/github-actions/free-disk-space.sh
126+ run : git pull origin "$GIT_REF"
127+ env :
128+ GIT_REF : ${{ github.ref }}
129+ - name : Restore cache
130+ if : inputs.cache-name != ''
131+ uses : actions/cache/restore@v4
132+ with :
133+ path : ${{ inputs.cache-name }}
134+ key : ${{ inputs.cache-name }}-
135+ restore-keys : ${{ inputs.cache-name }}-
94136 - name : Remove driver directories Windows
95137 if : inputs.os == 'windows'
96138 run : |
@@ -107,26 +149,16 @@ jobs:
107149 - name : Set Ruby version
108150 if : inputs.ruby-version != ''
109151 run : echo '${{ inputs.ruby-version }}' > rb/.ruby-version
110- - name : Setup DotNet
111- if : inputs.dotnet-version != ''
112- uses : actions/setup-dotnet@v4
113- with :
114- dotnet-version : ${{ inputs.dotnet-version }}
115- - name : Setup Java
116- if : inputs.java-version != ''
117- uses : actions/setup-java@v3
118- with :
119- java-version : ${{ inputs.java-version }}
120- distribution : ' temurin'
121152 - name : Setup Node
122153 if : inputs.node-version != ''
123154 uses : actions/setup-node@v4
124155 with :
125156 node-version : ${{ inputs.node-version }}
126157 - name : Setup Bazel with caching
127158 if : inputs.caching
128- uses : bazel-contrib/setup-bazel@0.15 .0
159+ uses : bazel-contrib/setup-bazel@0.18 .0
129160 with :
161+ cache-save : ${{ github.ref_name == 'trunk' }}
130162 bazelisk-cache : true
131163 bazelrc : common --color=yes
132164 # Workaround for long path issues: https://github.com/bazelbuild/bazel/pull/22532
@@ -136,17 +168,37 @@ jobs:
136168 external-cache : |
137169 manifest:
138170 crates: rust/Cargo.Bazel.lock
139- rules_ruby++ruby+ruby: 'rb/.ruby-version'
140- "pin_browsers_extension+mac_edge": false
141- "pin_browsers_extension+mac_firefox": false
142- "pin_browsers_extension+linux_edge": false
143- "pin_browsers_extension+linux_chrome": false
144- "pin_browsers_extension+linux_firefox": false
145- repository-cache : false
171+ rules_ruby++ruby+ruby: ${{ inputs.os == 'windows' && 'false' || 'rb/.ruby-version' }}
172+ "+pin_browsers_extension+linux_beta_chrome": false
173+ "+pin_browsers_extension+linux_beta_chromedriver": true
174+ "+pin_browsers_extension+linux_beta_firefox": false
175+ "+pin_browsers_extension+linux_chrome": false
176+ "+pin_browsers_extension+linux_chromedriver": true
177+ "+pin_browsers_extension+linux_edge": false
178+ "+pin_browsers_extension+linux_edgedriver": true
179+ "+pin_browsers_extension+linux_firefox": false
180+ "+pin_browsers_extension+linux_geckodriver": true
181+ "+pin_browsers_extension+mac_beta_chrome": false
182+ "+pin_browsers_extension+mac_beta_chromedriver": false
183+ "+pin_browsers_extension+mac_beta_firefox": false
184+ "+pin_browsers_extension+mac_chrome": false
185+ "+pin_browsers_extension+mac_chromedriver": false
186+ "+pin_browsers_extension+mac_edge": false
187+ "+pin_browsers_extension+mac_edgedriver": false
188+ "+pin_browsers_extension+mac_firefox": false
189+ "+pin_browsers_extension+mac_geckodriver": false
190+ repository-cache : true
146191 - name : Setup Bazel without caching
147192 if : inputs.caching == false
148- uses : bazel-contrib/setup-bazel@0.15 .0
193+ uses : bazel-contrib/setup-bazel@0.18 .0
149194 with :
195+ cache-save : false
196+ bazelisk-cache : true
197+ external-cache : |
198+ manifest:
199+ crates: rust/Cargo.Bazel.lock
200+ rules_ruby++ruby+ruby: rb/.ruby-version
201+ repository-cache : true
150202 bazelrc : common --color=yes
151203 - name : Setup curl for Ubuntu
152204 if : inputs.os == 'ubuntu'
@@ -167,38 +219,60 @@ jobs:
167219 - name : Setup Safari
168220 if : inputs.browser == 'safari'
169221 run : sudo safaridriver --enable
170- - name : Run Bazel
171- run : ${{ inputs.run }}
172- - name : Start SSH session
173- if : failure() && runner.debug == '1'
174- uses : mxschmitt/action-tmate@v3
175- with :
176- limit-access-to-actor : false
177- - name : Release Nightly
178- if : inputs.nightly-release-files != ''
179- uses : marvinpinto/action-automatic-releases@latest
222+ - name : Import GPG key
223+ if : inputs.gpg-sign
224+ uses : crazy-max/ghaction-import-gpg@v6
180225 with :
181- repo_token : " ${{ secrets.GITHUB_TOKEN }}"
182- automatic_release_tag : " nightly "
183- title : " Nightly "
184- prerelease : true
185- files : ${{ inputs.nightly-release-files }}
186- - name : Save changes
187- if : ${{ always() && inputs.artifact-name != 'ignore-artifacts' }}
226+ gpg_private_key : ${{ secrets.GPG_PRIVATE_KEY }}
227+ passphrase : ${{ secrets.GPG_PASSPHRASE }}
228+ - name : Run Bazel
229+ shell : bash
230+ env :
231+ MSYS_NO_PATHCONV : 1
232+ MSYS2_ARG_CONV_EXCL : " * "
188233 run : |
189- git diff > changes.patch
190- - name : " Upload test logs"
234+ mkdir -p build
235+ {
236+ ${{ inputs.run }}
237+ } 2>&1 | tee build/bazel-console.log
238+ - name : Rerun failures with debug
239+ if : failure()
240+ shell : bash
241+ run : ./scripts/github-actions/rerun-failures.sh '${{ inputs.run }}' '${{ inputs.rerun-with-debug }}'
242+ - name : Collect failed test logs
243+ if : failure()
244+ shell : bash
245+ run : ./scripts/github-actions/collect-test-logs.sh
246+ - name : Upload failed test logs
191247 if : failure()
192248 uses : actions/upload-artifact@v5
193249 with :
194250 name : test-logs-${{ inputs.os }}-${{ inputs.name }}-${{ inputs.browser }}
195251 retention-days : 7
196- path : |
197- **/*.log
198- - name : " Upload changes"
199- if : ${{ always() && inputs.artifact-name != 'ignore-artifacts' }}
200- uses : actions/upload-artifact@v4
252+ path : build/failures/**
253+ - name : Start SSH session
254+ if : failure() && runner.debug == '1'
255+ uses : mxschmitt/action-tmate@v3
256+ with :
257+ limit-access-to-actor : false
258+ - name : Save git diff
259+ if : always() && inputs.artifact-name != '' && inputs.artifact-path == ''
260+ run : git diff --binary > changes.patch
261+ - name : Upload artifact
262+ if : always() && inputs.artifact-name != ''
263+ uses : actions/upload-artifact@v5
201264 with :
202265 name : ${{ inputs.artifact-name }}
203- path : changes.patch
266+ path : ${{ inputs.artifact-path || ' changes.patch' }}
204267 retention-days : 6
268+ if-no-files-found : ${{ inputs.artifact-path != '' && 'error' || 'warn' }}
269+ - name : Check disk space
270+ if : always()
271+ shell : bash
272+ run : |
273+ avail=$(df -k "$GITHUB_WORKSPACE" | awk 'NR==2 {printf "%.0f", $4/1024/1024}')
274+ echo "Remaining disk space: ${avail}GB"
275+ if [ "$avail" -lt 5 ]; then
276+ echo "::error::Low disk space: ${avail}GB remaining"
277+ exit 1
278+ fi
0 commit comments