From d2b3d6375680b2dd692a3db42a1b34ddee9ee9f2 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Fri, 10 May 2024 14:24:49 -0700 Subject: [PATCH] Only run CI e2e tests on approved PRs 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 --- .github/workflows/test.yml | 19 +++++++++++-------- .lintstagedrc.js | 2 +- CONTRIBUTING.md | 18 +++++++++++++----- README.md | 13 +------------ 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 111f306de589..0efcea260846 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: - run: npm run test-integration e2e-mac: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'facebook' && github.event.review.state == 'APPROVED' strategy: matrix: node-version: [18.18.0] @@ -93,7 +93,7 @@ jobs: events-mode: ${{ matrix.events-mode }} e2e-linux: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'facebook' && github.event.review.state == 'APPROVED' strategy: matrix: node-version: [18.18.0] @@ -109,7 +109,10 @@ jobs: events-mode: ${{ matrix.events-mode }} e2e-windows: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'testuser' && ( + github.event.review.state == 'APPROVED' || + (github.event_name == 'pull_request' && contains(fromJson('["COLLABORATOR","MEMBER","OWNER",]'), github.event.pull_request.author_association)) + ) strategy: matrix: node-version: [18.18.0] @@ -125,7 +128,7 @@ jobs: events-mode: ${{ matrix.events-mode }} e2e-collab-mac: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'facebook' && github.event.review.state == 'APPROVED' strategy: matrix: node-version: [18.18.0] @@ -139,7 +142,7 @@ jobs: events-mode: 'modern-events' e2e-collab-linux: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'facebook' && github.event.review.state == 'APPROVED' strategy: matrix: node-version: [18.18.0] @@ -153,7 +156,7 @@ jobs: events-mode: 'modern-events' e2e-collab-windows: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'facebook' && github.event.review.state == 'APPROVED' strategy: matrix: node-version: [18.18.0] @@ -167,7 +170,7 @@ jobs: events-mode: 'modern-events' e2e-prod: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'facebook' && github.event.review.state == 'APPROVED' strategy: matrix: os: ['macos-latest'] @@ -185,7 +188,7 @@ jobs: events-mode: ${{ matrix.events-mode }} e2e-collab-prod: - if: github.repository_owner == 'facebook' + if: github.repository_owner == 'facebook' && github.event.review.state == 'APPROVED' strategy: matrix: os: ['macos-latest'] diff --git a/.lintstagedrc.js b/.lintstagedrc.js index c9c3c2f9cacb..23aea9a0fbfd 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -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'], }; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a79632b955a2..94159098f87d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,11 +8,19 @@ possible. We actively welcome your pull requests. 1. Fork the repo and create your branch from `main`. -2. If you've added code that should be tested, add tests. -3. If you've changed APIs, update the documentation. -4. Ensure the test suite passes. -5. Make sure your code lints. -6. If you haven't already, complete the Contributor License Agreement ("CLA"). +2. Run `npm install` to install dependencies. +3. If you've added code that should be tested, add tests. +4. If you've changed APIs, update the documentation. +5. Ensure the test suite passes. +6. Make sure your code lints. +7. If you haven't already, complete the Contributor License Agreement ("CLA"). + +Note that the local server needs to be running in order to run the e2e tests. + +- `npm run start` +- `npm run test-e2e-chromium` (to run only chromium e2e tests) + +`npm run start` will start both the dev server and collab server. If you don't need collab, use `npm run dev` to start just the dev server. ## Contributor License Agreement ("CLA") diff --git a/README.md b/README.md index ef70854c178f..40fb62ad864b 100644 --- a/README.md +++ b/README.md @@ -334,18 +334,7 @@ editor.registerUpdateListener(({editorState}) => { ## Contributing to Lexical -1. Clone this repository - -2. Install dependencies - - - `npm install` - -3. Start local server and run tests - - `npm run start` - - `npm run test-e2e-chromium` to run only chromium e2e tests - - The server needs to be running for the e2e tests - -`npm run start` will start both the dev server and collab server. If you don't need collab, use `npm run dev` to start just the dev server. +Please read the [CONTRIBUTING.md](https://github.com/facebook/lexical/blob/main/CONTRIBUTING.md). ### Optional but recommended, use VSCode for development