Skip to content

Commit 80efbe8

Browse files
[CI] Introduce guard job (#4047)
1 parent 7198b9d commit 80efbe8

4 files changed

Lines changed: 68 additions & 15 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Guard
2+
description: >
3+
Loads the current PR title (not the stale event payload) and cancels the workflow when it
4+
contains skip-ci, case-insensitive. No-op when the event is not pull_request.
5+
inputs:
6+
github_token:
7+
description: Token with actions:write and pull-requests:read
8+
required: true
9+
runs:
10+
using: composite
11+
steps:
12+
- run: |
13+
set -euo pipefail
14+
if [ "${{ github.event_name }}" != "pull_request" ]; then
15+
exit 0
16+
fi
17+
PR_TITLE=$(gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json title --jq .title)
18+
if printf '%s' "$PR_TITLE" | grep -Fqi 'skip-ci'; then
19+
gh run cancel "${{ github.run_id }}" --repo "${{ github.repository }}"
20+
fi
21+
shell: bash
22+
env:
23+
GH_TOKEN: ${{ inputs.github_token }}

.github/workflows/sdk-performance-metrics.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ jobs:
2323
performance:
2424
name: Metrics
2525
runs-on: macos-15
26+
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
2627
env:
2728
GITHUB_TOKEN: '${{ secrets.CI_BOT_GITHUB_TOKEN }}'
2829
steps:
30+
- uses: actions/checkout@v3.1.0
31+
with:
32+
fetch-depth: 0 # to fetch git tags
33+
34+
- uses: ./.github/actions/ci-guard
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
2938
- name: Connect Bot
30-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
3139
uses: webfactory/ssh-agent@v0.7.0
3240
with:
3341
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
@@ -36,19 +44,12 @@ jobs:
3644
with:
3745
python-version: 3.12 # gsutil requires Python version 3.8-3.12
3846

39-
- uses: actions/checkout@v3.1.0
40-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
41-
with:
42-
fetch-depth: 0 # to fetch git tags
43-
4447
- uses: ./.github/actions/bootstrap
45-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
4648
env:
4749
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
4850
INSTALL_GCLOUD: true
4951

5052
- name: Run XCMetrics
51-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
5253
run: bundle exec fastlane xcmetrics
5354
timeout-minutes: 120
5455
env:

.github/workflows/sdk-size-metrics.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@ jobs:
2020
sdk_size:
2121
name: Metrics
2222
runs-on: macos-15
23+
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
2324
env:
2425
GITHUB_TOKEN: '${{ secrets.CI_BOT_GITHUB_TOKEN }}'
2526
GITHUB_PR_NUM: ${{ github.event.pull_request.number }}
2627
steps:
28+
- uses: actions/checkout@v3.1.0
29+
30+
- uses: ./.github/actions/ci-guard
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
2734
- name: Connect Bot
2835
uses: webfactory/ssh-agent@v0.7.0
2936
with:
3037
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
3138

32-
- uses: actions/checkout@v3.1.0
33-
3439
- uses: ./.github/actions/bootstrap
3540

3641
- name: Run General SDK Size Metrics

.github/workflows/smoke-checks.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,19 @@ env:
2626
GITHUB_PR_NUM: ${{ github.event.pull_request.number }}
2727

2828
jobs:
29+
guard:
30+
name: Guard
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4.1.1
34+
- uses: ./.github/actions/ci-guard
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
2938
build-test-app-and-frameworks:
3039
name: Build Test App and Frameworks
3140
runs-on: macos-15
41+
needs: guard
3242
steps:
3343
- uses: actions/checkout@v4.1.1
3444
- uses: ./.github/actions/ruby-cache
@@ -48,6 +58,7 @@ jobs:
4858
automated-code-review:
4959
name: Automated Code Review
5060
runs-on: macos-14
61+
needs: guard
5162
env:
5263
XCODE_VERSION: "16.1"
5364
if: ${{ github.event.inputs.record_snapshots != 'true' }}
@@ -65,6 +76,7 @@ jobs:
6576
name: Build SDKs (Old Xcode)
6677
runs-on: macos-14
6778
if: ${{ github.event.inputs.record_snapshots != 'true' }}
79+
needs: guard
6880
env:
6981
XCODE_VERSION: "16.1"
7082
steps:
@@ -87,6 +99,7 @@ jobs:
8799
name: Test LLC (Debug)
88100
runs-on: macos-15
89101
if: ${{ github.event.inputs.record_snapshots != 'true' }}
102+
needs: guard
90103
steps:
91104
- uses: actions/checkout@v4.1.1
92105
with:
@@ -125,7 +138,9 @@ jobs:
125138
test-ui-debug:
126139
name: Test UI (Debug)
127140
runs-on: macos-15
128-
needs: build-test-app-and-frameworks
141+
needs:
142+
- guard
143+
- build-test-app-and-frameworks
129144
steps:
130145
- uses: actions/checkout@v4.1.1
131146
- uses: actions/download-artifact@v4
@@ -158,7 +173,9 @@ jobs:
158173
test-common-ui-debug:
159174
name: Test Common UI (Debug)
160175
runs-on: macos-15
161-
needs: build-test-app-and-frameworks
176+
needs:
177+
- guard
178+
- build-test-app-and-frameworks
162179
steps:
163180
- uses: actions/checkout@v4.1.1
164181
- uses: actions/download-artifact@v4
@@ -189,7 +206,9 @@ jobs:
189206
name: Launch Allure TestOps
190207
runs-on: macos-15
191208
if: ${{ github.event.inputs.record_snapshots != 'true' }}
192-
needs: build-test-app-and-frameworks
209+
needs:
210+
- guard
211+
- build-test-app-and-frameworks
193212
outputs:
194213
launch_id: ${{ steps.get_launch_id.outputs.launch_id }}
195214
steps:
@@ -209,6 +228,7 @@ jobs:
209228
runs-on: macos-15
210229
if: ${{ github.event.inputs.record_snapshots != 'true' }}
211230
needs:
231+
- guard
212232
- allure_testops_launch
213233
- build-test-app-and-frameworks
214234
env:
@@ -262,8 +282,10 @@ jobs:
262282
build-apps:
263283
name: Build Demo App + Example Apps
264284
runs-on: macos-15
265-
needs: build-test-app-and-frameworks
266285
if: ${{ github.event.inputs.record_snapshots != 'true' }}
286+
needs:
287+
- guard
288+
- build-test-app-and-frameworks
267289
steps:
268290
- uses: actions/checkout@v4.1.1
269291
- uses: actions/download-artifact@v4
@@ -291,8 +313,10 @@ jobs:
291313
test-integration:
292314
name: Test Integration
293315
runs-on: macos-15
294-
needs: build-test-app-and-frameworks
295316
if: ${{ github.event.inputs.record_snapshots != 'true' }}
317+
needs:
318+
- guard
319+
- build-test-app-and-frameworks
296320
steps:
297321
- uses: actions/checkout@v4.1.1
298322
- uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)