Skip to content

Commit

Permalink
Only run CI e2e tests on approved PRs
Browse files Browse the repository at this point in the history
Avoid running the entire suite of (expensive) e2e tests on every PR that
is opened or updated. Only run if PR is approved.

Reference: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-when-a-pull-request-is-approved
  • Loading branch information
necolas committed May 12, 2024
1 parent 40f6699 commit 93a58c3
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 120 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/call-core-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Lexical Core Tests

on:
workflow_call:

jobs:
integrity:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.11.0]
env:
CI: true
GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run ci-check
- run: npm run build
- run: npm run build-www

unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.18.0]
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run test-unit

integration:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.18.0]
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run test-integration
Original file line number Diff line number Diff line change
@@ -1,181 +1,102 @@
name: Lexical Tests
name: Lexical e2e tests

on:
push:
branches:
- main
paths-ignore:
- 'packages/lexical-website/**'
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- 'packages/lexical-website/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
workflow_call:

jobs:
integrity:
if: github.repository_owner == 'facebook'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.11.0]
env:
CI: true
GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run ci-check
- run: npm run build
- run: npm run build-www

unit:
if: github.repository_owner == 'facebook'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.18.0]
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run test-unit

integration:
if: github.repository_owner == 'facebook'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.18.0]
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- run: npm run test-integration

e2e-mac:
if: github.repository_owner == 'facebook'
mac:
strategy:
matrix:
node-version: [18.18.0]
browser: ['chromium', 'firefox', 'webkit']
editor-mode: ['rich-text', 'plain-text']
events-mode: ['legacy-events', 'modern-events']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
os: 'macos-latest'
node-version: ${{ matrix.node-version }}
browser: ${{ matrix.browser }}
editor-mode: ${{ matrix.editor-mode }}
events-mode: ${{ matrix.events-mode }}

e2e-linux:
if: github.repository_owner == 'facebook'
linux:
strategy:
matrix:
node-version: [18.18.0]
browser: ['chromium', 'firefox']
editor-mode: ['rich-text', 'plain-text']
events-mode: ['legacy-events', 'modern-events']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
os: 'ubuntu-latest'
node-version: ${{ matrix.node-version }}
browser: ${{ matrix.browser }}
editor-mode: ${{ matrix.editor-mode }}
events-mode: ${{ matrix.events-mode }}

e2e-windows:
if: github.repository_owner == 'facebook'
windows:
strategy:
matrix:
node-version: [18.18.0]
browser: ['chromium', 'firefox']
editor-mode: ['rich-text', 'plain-text']
events-mode: ['legacy-events', 'modern-events']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
os: 'windows-latest'
node-version: ${{ matrix.node-version }}
browser: ${{ matrix.browser }}
editor-mode: ${{ matrix.editor-mode }}
events-mode: ${{ matrix.events-mode }}

e2e-collab-mac:
if: github.repository_owner == 'facebook'
collab-mac:
strategy:
matrix:
node-version: [18.18.0]
browser: ['chromium', 'firefox', 'webkit']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
os: 'macos-latest'
node-version: ${{ matrix.node-version }}
browser: ${{ matrix.browser }}
editor-mode: 'rich-text-with-collab'
events-mode: 'modern-events'

e2e-collab-linux:
if: github.repository_owner == 'facebook'
collab-linux:
strategy:
matrix:
node-version: [18.18.0]
browser: ['chromium', 'firefox']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
os: 'ubuntu-latest'
node-version: ${{ matrix.node-version }}
browser: ${{ matrix.browser }}
editor-mode: 'rich-text-with-collab'
events-mode: 'modern-events'

e2e-collab-windows:
if: github.repository_owner == 'facebook'
collab-windows:
strategy:
matrix:
node-version: [18.18.0]
browser: ['chromium', 'firefox']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
os: 'windows-latest'
node-version: ${{ matrix.node-version }}
browser: ${{ matrix.browser }}
editor-mode: 'rich-text-with-collab'
events-mode: 'modern-events'

e2e-prod:
if: github.repository_owner == 'facebook'
prod:
strategy:
matrix:
os: ['macos-latest']
node-version: [18.18.0]
browser: ['chromium']
editor-mode: ['rich-text']
events-mode: ['modern-events']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
prod: true
os: ${{ matrix.os }}
Expand All @@ -184,16 +105,15 @@ jobs:
editor-mode: ${{ matrix.editor-mode }}
events-mode: ${{ matrix.events-mode }}

e2e-collab-prod:
if: github.repository_owner == 'facebook'
collab-prod:
strategy:
matrix:
os: ['macos-latest']
node-version: [18.18.0]
browser: ['chromium']
editor-mode: ['rich-text-with-collab']
events-mode: ['modern-events']
uses: ./.github/workflows/e2e-test.yml
uses: ./.github/workflows/call-e2e-test.yml
with:
prod: true
os: ${{ matrix.os }}
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/call-e2e-canary-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lexical e2e canary test

on:
workflow_call:

jobs:
canary:
strategy:
matrix:
os: ['macos-latest']
node-version: [18.18.0]
browser: ['chromium']
editor-mode: ['rich-text']
events-mode: ['modern-events']
uses: ./.github/workflows/call-e2e-test.yml
with:
os: ${{ matrix.os }}
node-version: ${{ matrix.node-version }}
browser: ${{ matrix.browser }}
editor-mode: ${{ matrix.editor-mode }}
events-mode: ${{ matrix.events-mode }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lexical e2e Tests
name: Lexical e2e test runner

on:
workflow_call:
Expand All @@ -11,7 +11,7 @@ on:
prod: {required: false, type: boolean}

jobs:
e2e-tests:
e2e-test:
runs-on: ${{ inputs.os }}
if: (inputs.browser != 'webkit' || inputs.os == 'macos-latest') && (inputs.editor-mode != 'rich-text-with-collab' || inputs.events-mode != 'legacy-events')
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/size-limit.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'size'
name: 'Bundles'
on:
pull_request:
branches:
- main
jobs:
size:
size-limit:
runs-on: ubuntu-latest
env:
CI_JOB_NUMBER: 1
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/tests-extended.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lexical Tests (Extended)

on:
pull_request:
types: [labeled, synchronize]
paths-ignore:
- 'packages/lexical-website/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
e2e-tests:
if: github.repository_owner == 'facebook' && contains(github.event.pull_request.labels.*.name, 'extended-tests')
uses: ./.github/workflows/call-e2e-all-tests.yml
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lexical Tests

on:
push:
branches:
- main
paths-ignore:
- 'packages/lexical-website/**'
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- 'packages/lexical-website/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
core-tests:
uses: ./.github/workflows/call-core-tests.yml

e2e-tests:
if: github.repository_owner == 'facebook'
uses: ./.github/workflows/call-e2e-canary-tests.yml
2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'*.(js|mjs|jsx|css|html|d.ts|ts|tsx)': 'prettier --write',
'*.(js|mjs|jsx|css|html|d.ts|ts|tsx|yml)': 'prettier --write',
'*.(js|mjs|jsx|ts|tsx)': ['eslint --fix'],
};
Loading

0 comments on commit 93a58c3

Please sign in to comment.