-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4190 from preschian/feat-cypress-parallel
ci: run cypress parallel
- Loading branch information
Showing
8 changed files
with
179 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: cypress | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
e2e: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: cypress/included:10.10.0 | ||
options: --user 1001 | ||
env: | ||
CYPRESS_CACHE_FOLDER: '${GITHUB_WORKSPACE}/.cypress-cache' | ||
strategy: | ||
matrix: | ||
index: [1, 2, 3, 4] # [1, ..., n] where n === parallelSize in e2e-run-tests.js | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.pnpm-store | ||
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}- | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: latest | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
cache: 'pnpm' | ||
|
||
- name: Install Dependencies | ||
run: pnpm install && pnpm cypress install | ||
|
||
- name: Build App | ||
run: pnpm generate | ||
|
||
- name: Cypress run | ||
run: pnpm start:static & pnpm wait-on http://localhost:9090 && MATRIX=${{ matrix.index }} node tests/cypress/e2e-run-tests.js | ||
|
||
- name: Upload Screenshots | ||
uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
path: ./cypress/screenshots/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,4 +91,4 @@ typings/ | |
## service-worker.js | ||
|
||
# cypress | ||
/tests/cypress/screenshots/ | ||
cypress/screenshots/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const cypress = require('cypress') | ||
const glob = require('glob') | ||
const path = require('path') | ||
const { chunk } = require('lodash') | ||
|
||
const configFile = path.join(__dirname, '../cypress.config.ts') | ||
const supportFile = path.join(__dirname, './support/e2e.ts') | ||
const fixturesFolder = path.join(__dirname, './fixtures') | ||
|
||
glob('./tests/cypress/e2e/**/*.cy.ts', async (err, files) => { | ||
if (err) { | ||
process.exit(1) | ||
} | ||
|
||
const parallelSize = 4 // make sure to adjust strategy.matrix.index also in e2e.yml | ||
const size = Math.ceil(files.length / parallelSize) | ||
const group = chunk(files, size) | ||
const index = process.env.MATRIX || 1 | ||
const specs = group[index - 1] | ||
|
||
try { | ||
const results = await cypress.run({ | ||
browser: 'chrome', | ||
configFile, | ||
config: { | ||
supportFile, | ||
e2e: { | ||
fixturesFolder, | ||
specPattern: specs, | ||
}, | ||
}, | ||
}) | ||
|
||
if (results.totalFailed > 0) { | ||
process.exit(1) | ||
} | ||
} catch (error) { | ||
console.log(error) | ||
process.exit(1) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters