Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/e2e-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- v5
- release/**
pull_request:
types: [opened, synchronize, reopened, labeled]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -19,7 +20,15 @@ env:
IOS_VERSION: '18.1'

jobs:
ready-to-merge-gate:
name: Ready-to-merge gate
uses: ./.github/workflows/ready-to-merge-workflow.yml
with:
is-pr: ${{ github.event_name == 'pull_request' }}
labels: ${{ toJson(github.event.pull_request.labels) }}

diff_check:
needs: [ready-to-merge-gate]
uses: ./.github/workflows/skip-ci.yml
auth_token_check:
uses: ./.github/workflows/skip-ci-noauth.yml
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/native-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ on:
- v5
- release/**
pull_request:

types: [opened, synchronize, reopened, labeled]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
ready-to-merge-gate:
name: Ready-to-merge gate
uses: ./.github/workflows/ready-to-merge-workflow.yml
with:
is-pr: ${{ github.event_name == 'pull_request' }}
labels: ${{ toJson(github.event.pull_request.labels) }}

diff_check:
needs: [ready-to-merge-gate]
uses: ./.github/workflows/skip-ci.yml

test-ios:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/ready-to-merge-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Ready to Merge Workflow
on:
workflow_call:
inputs:
labels:
description: The GitHub event's labels
required: true
type: string
is-pr:
description: Whether the workflow is running on a PR
required: true
type: boolean

jobs:
ready-to-merge-gate:
name: 'Missing "ready-to-merge" label'
runs-on: ubuntu-latest
steps:
- name: Check for exact 'ready-to-merge' label
if: ${{ inputs.is-pr }}
id: check-label
run: |
# Use jq to check for exact label match (avoids substring matching issues with contains())
if echo '${{ inputs.labels }}' | jq -e '.[] | select(.name == "ready-to-merge")' > /dev/null; then
echo "label_found=true" >> $GITHUB_OUTPUT
else
echo "label_found=false" >> $GITHUB_OUTPUT
fi
# Since Github also accepts `skipped` results for Required Workflows, we need
# to fail the job to ensure that the downstream jobs don't just skip.
- name: Fail until the 'ready-to-merge' label is present
if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'false' }}
run: |
echo "Add the 'ready-to-merge' label to run CI."
exit 1
- name: Gate passed
if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'true' }}
run: echo "Label present. Proceeding with CI."
- name: Gate passed
if: ${{ !inputs.is-pr }}
run: echo "Not a PR. Proceeding with CI."
9 changes: 9 additions & 0 deletions .github/workflows/sample-application-expo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- v5
pull_request:
types: [opened, synchronize, reopened, labeled]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -16,7 +17,15 @@ env:
RN_SENTRY_POD_NAME: RNSentry

jobs:
ready-to-merge-gate:
name: Ready-to-merge gate
uses: ./.github/workflows/ready-to-merge-workflow.yml
with:
is-pr: ${{ github.event_name == 'pull_request' }}
labels: ${{ toJson(github.event.pull_request.labels) }}

diff_check:
needs: [ready-to-merge-gate]
uses: ./.github/workflows/skip-ci.yml

build:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
- v5
pull_request:
types: [opened, synchronize, reopened, labeled]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -23,7 +24,15 @@ env:
ANDROID_API_LEVEL: '30'

jobs:
ready-to-merge-gate:
name: Ready-to-merge gate
uses: ./.github/workflows/ready-to-merge-workflow.yml
with:
is-pr: ${{ github.event_name == 'pull_request' }}
labels: ${{ toJson(github.event.pull_request.labels) }}

diff_check:
needs: [ready-to-merge-gate]
uses: ./.github/workflows/skip-ci.yml

build:
Expand Down
25 changes: 25 additions & 0 deletions CI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CI inner working

## `ready-to-merge` label

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.
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`.

### How to use the gate

Add this job at the start the workflow and then add `need: ready-to-merge-gate` to jobs that you want to be skipped.

```
ready-to-merge-gate:
name: Ready-to-merge gate
uses: ./.github/workflows/ready-to-merge-workflow.yml
with:
is-pr: ${{ github.event_name == 'pull_request' }}
labels: ${{ toJson(github.event.pull_request.labels) }}
```

This job will:

- Pass if the event is not a PR
- Fail if the event is a PR and is missing the `ready-to-merge` label
- Pass if the event is a PR and is has the `ready-to-merge` label
Loading