Skip to content

Commit

Permalink
ci: Add parallel PR verification [skip-release] (#1354)
Browse files Browse the repository at this point in the history
Add concurrency to the PR build process to decrease the time we have to wait for pull requests to be verified. Also Cypress retries were added.

[category:Infrastructure]
  • Loading branch information
NicholasBoll authored Nov 23, 2021
1 parent 735c60d commit 3eee1cd
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 10 deletions.
130 changes: 121 additions & 9 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ name: Pull Request
on: pull_request

jobs:
verify:
install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required to retrieve git history
- uses: actions/setup-node@v2
with:
node-version: 14.x
Expand All @@ -20,14 +18,14 @@ jobs:

- name: Cache Cypress
id: cypress-cache
uses: actions/cache/@v1
uses: actions/cache/@v2
with:
path: .cache/cypress
key: ${{ runner.os }}-cypress-cache-version-${{ steps.cypress-version.outputs.version }}

- name: Cache node modules
id: yarn-cache
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-modules-hash-${{ hashFiles('yarn.lock') }}
Expand All @@ -40,7 +38,27 @@ jobs:
env:
CYPRESS_CACHE_FOLDER: .cache/cypress

# Keep steps separate for Github Actions annotation matching: https://github.com/actions/setup-node/blob/83c9f7a7df54d6b57455f7c57ac414f2ae5fb8de/src/setup-node.ts#L26-L33
check:
runs-on: ubuntu-latest
needs: 'install'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x

- uses: actions/cache/@v2
with:
path: .cache/cypress
key: ${{ runner.os }}-cypress-cache-version-${{ steps.cypress-version.outputs.version }}

- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-modules-hash-${{ hashFiles('yarn.lock') }}

# Keep steps separate for Github Actions annotation matching: https://github.com/actions/setup-node/blob/83c9f7a7df54d6b57455f7c57ac414f2ae5fb8de/src/setup-node.ts#L26-L33
- name: Lint
run: yarn lint

Expand All @@ -53,11 +71,63 @@ jobs:
- name: Unit tests
run: yarn test

build:
runs-on: ubuntu-latest
needs: 'install'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x

- uses: actions/cache/@v2
with:
path: .cache/cypress
key: ${{ runner.os }}-cypress-cache-version-${{ steps.cypress-version.outputs.version }}

- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-modules-hash-${{ hashFiles('yarn.lock') }}

- name: Build Storybook
run: yarn build-storybook --quiet

- name: Start Server
run: npx http-server docs -p 9001 & npx wait-on http://localhost:9001
- name: Cache Build
id: build-cache
uses: actions/cache/@v2
with:
path: docs
key: ${{ runner.os }}-build-${{ github.sha }}

visual-test:
runs-on: ubuntu-latest
needs: 'build'

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required to retrieve git history
- uses: actions/setup-node@v2
with:
node-version: 14.x

- uses: actions/cache/@v2
with:
path: .cache/cypress
key: ${{ runner.os }}-cypress-cache-version-${{ steps.cypress-version.outputs.version }}

- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-modules-hash-${{ hashFiles('yarn.lock') }}

- name: Restore Build
uses: actions/cache/@v2
with:
path: docs
key: ${{ runner.os }}-build-${{ github.sha }}

- uses: chromaui/action@v1
with:
Expand All @@ -67,11 +137,53 @@ jobs:
exitOnceUploaded: true
exitZeroOnChanges: true

integration-test:
runs-on: ubuntu-latest
needs: 'build'
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Required to retrieve git history
- uses: actions/setup-node@v2
with:
node-version: 14.x

- uses: actions/cache/@v2
with:
path: .cache/cypress
key: ${{ runner.os }}-cypress-cache-version-${{ steps.cypress-version.outputs.version }}

- uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-modules-hash-${{ hashFiles('yarn.lock') }}

- name: Restore Build
uses: actions/cache/@v2
with:
path: docs
key: ${{ runner.os }}-build-${{ github.sha }}

- name: Start Server
run: npx http-server docs -p 9001 & npx wait-on http://localhost:9001

- name: Integration tests
run: yarn cypress run --record
run: yarn cypress run --record --parallel
env:
# Github Actions doesn't support encryption on forks
# If these keys become compromised, we will rotate and disable these features
# on forked PRs until a suitable workaround is found
CYPRESS_RECORD_KEY: 3a9347b6-36ab-4a36-823d-709f4078b148
CYPRESS_CACHE_FOLDER: .cache/cypress

verify:
runs-on: ubuntu-latest
needs: ['check', 'integration-test']
steps:
- name: Done
run: echo "Done"
5 changes: 4 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"projectId": "odida5",
"baseUrl": "http://localhost:9001",
"supportFile": "cypress/support/index.ts",
"watchForFileChanges": false
"watchForFileChanges": false,
"retries": {
"runMode": 2
}
}

0 comments on commit 3eee1cd

Please sign in to comment.