Skip to content

Commit 14f576e

Browse files
authored
chore(ci): Require ready-to-merge label to run all checks (#5349)
* chore(ci): Require `ready-to-merge` label to run all checks * Add doc and update condition
1 parent 73f2455 commit 14f576e

File tree

6 files changed

+103
-1
lines changed

6 files changed

+103
-1
lines changed

.github/workflows/e2e-v2.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- v5
88
- release/**
99
pull_request:
10+
types: [opened, synchronize, reopened, labeled]
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.ref }}
@@ -19,7 +20,15 @@ env:
1920
IOS_VERSION: '18.1'
2021

2122
jobs:
23+
ready-to-merge-gate:
24+
name: Ready-to-merge gate
25+
uses: ./.github/workflows/ready-to-merge-workflow.yml
26+
with:
27+
is-pr: ${{ github.event_name == 'pull_request' }}
28+
labels: ${{ toJson(github.event.pull_request.labels) }}
29+
2230
diff_check:
31+
needs: [ready-to-merge-gate]
2332
uses: ./.github/workflows/skip-ci.yml
2433
auth_token_check:
2534
uses: ./.github/workflows/skip-ci-noauth.yml

.github/workflows/native-tests.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@ on:
77
- v5
88
- release/**
99
pull_request:
10-
10+
types: [opened, synchronize, reopened, labeled]
11+
1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.ref }}
1314
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1415

1516
jobs:
17+
ready-to-merge-gate:
18+
name: Ready-to-merge gate
19+
uses: ./.github/workflows/ready-to-merge-workflow.yml
20+
with:
21+
is-pr: ${{ github.event_name == 'pull_request' }}
22+
labels: ${{ toJson(github.event.pull_request.labels) }}
23+
1624
diff_check:
25+
needs: [ready-to-merge-gate]
1726
uses: ./.github/workflows/skip-ci.yml
1827

1928
test-ios:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Ready to Merge Workflow
2+
on:
3+
workflow_call:
4+
inputs:
5+
labels:
6+
description: The GitHub event's labels
7+
required: true
8+
type: string
9+
is-pr:
10+
description: Whether the workflow is running on a PR
11+
required: true
12+
type: boolean
13+
14+
jobs:
15+
ready-to-merge-gate:
16+
name: 'Missing "ready-to-merge" label'
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check for exact 'ready-to-merge' label
20+
if: ${{ inputs.is-pr }}
21+
id: check-label
22+
run: |
23+
# Use jq to check for exact label match (avoids substring matching issues with contains())
24+
if echo '${{ inputs.labels }}' | jq -e '.[] | select(.name == "ready-to-merge")' > /dev/null; then
25+
echo "label_found=true" >> $GITHUB_OUTPUT
26+
else
27+
echo "label_found=false" >> $GITHUB_OUTPUT
28+
fi
29+
# Since Github also accepts `skipped` results for Required Workflows, we need
30+
# to fail the job to ensure that the downstream jobs don't just skip.
31+
- name: Fail until the 'ready-to-merge' label is present
32+
if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'false' }}
33+
run: |
34+
echo "Add the 'ready-to-merge' label to run CI."
35+
exit 1
36+
- name: Gate passed
37+
if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'true' }}
38+
run: echo "Label present. Proceeding with CI."
39+
- name: Gate passed
40+
if: ${{ !inputs.is-pr }}
41+
run: echo "Not a PR. Proceeding with CI."

.github/workflows/sample-application-expo.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- v5
88
pull_request:
9+
types: [opened, synchronize, reopened, labeled]
910

1011
concurrency:
1112
group: ${{ github.workflow }}-${{ github.ref }}
@@ -16,7 +17,15 @@ env:
1617
RN_SENTRY_POD_NAME: RNSentry
1718

1819
jobs:
20+
ready-to-merge-gate:
21+
name: Ready-to-merge gate
22+
uses: ./.github/workflows/ready-to-merge-workflow.yml
23+
with:
24+
is-pr: ${{ github.event_name == 'pull_request' }}
25+
labels: ${{ toJson(github.event.pull_request.labels) }}
26+
1927
diff_check:
28+
needs: [ready-to-merge-gate]
2029
uses: ./.github/workflows/skip-ci.yml
2130

2231
build:

.github/workflows/sample-application.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- v5
88
pull_request:
9+
types: [opened, synchronize, reopened, labeled]
910

1011
concurrency:
1112
group: ${{ github.workflow }}-${{ github.ref }}
@@ -23,7 +24,15 @@ env:
2324
ANDROID_API_LEVEL: '30'
2425

2526
jobs:
27+
ready-to-merge-gate:
28+
name: Ready-to-merge gate
29+
uses: ./.github/workflows/ready-to-merge-workflow.yml
30+
with:
31+
is-pr: ${{ github.event_name == 'pull_request' }}
32+
labels: ${{ toJson(github.event.pull_request.labels) }}
33+
2634
diff_check:
35+
needs: [ready-to-merge-gate]
2736
uses: ./.github/workflows/skip-ci.yml
2837

2938
build:

CI.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# CI inner working
2+
3+
## `ready-to-merge` label
4+
5+
CI checks are great, but macOS runners are limited on every provider, because of this, we need to be smarter on how we run jobs.
6+
To avoid running many jobs on every PR's commit, we have decided to only run a subset of tests regularily and run the full suite only when the PR has the label `ready-to-merge`.
7+
8+
### How to use the gate
9+
10+
Add this job at the start the workflow and then add `need: ready-to-merge-gate` to jobs that you want to be skipped.
11+
12+
```
13+
ready-to-merge-gate:
14+
name: Ready-to-merge gate
15+
uses: ./.github/workflows/ready-to-merge-workflow.yml
16+
with:
17+
is-pr: ${{ github.event_name == 'pull_request' }}
18+
labels: ${{ toJson(github.event.pull_request.labels) }}
19+
```
20+
21+
This job will:
22+
23+
- Pass if the event is not a PR
24+
- Fail if the event is a PR and is missing the `ready-to-merge` label
25+
- Pass if the event is a PR and is has the `ready-to-merge` label

0 commit comments

Comments
 (0)