Use knapsack pro to speed up cypress tests (#11863)
* Install knapsack pro * Use knapsack pro command * Lint * Use chrome * Add test file pattern * Use two different tokens for knapsack * Use the correct secret * Update lockfile * Fix conflict * Remove redundant options * Add explaining comment * Remove outdated variables and steps * Update comment * Fix conflict * Use the chrome we setup earlier * Add back percy config * Set knapsack pro branch * Use github_env to get browser path * Add badge to readme * Update .github/workflows/cypress.yaml Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Apply prettier --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
62256a3d12
commit
085b39c7af
4 changed files with 239 additions and 48 deletions
53
.github/workflows/cypress.yaml
vendored
53
.github/workflows/cypress.yaml
vendored
|
@ -41,9 +41,6 @@ jobs:
|
|||
outputs:
|
||||
uuid: ${{ steps.uuid.outputs.value }}
|
||||
pr_id: ${{ steps.prdetails.outputs.pr_id }}
|
||||
commit_message: ${{ steps.commit.outputs.message }}
|
||||
commit_author: ${{ steps.commit.outputs.author }}
|
||||
commit_email: ${{ steps.commit.outputs.email }}
|
||||
percy_enable: ${{ steps.percy.outputs.value || '0' }}
|
||||
steps:
|
||||
# We create the status here and then update it to success/failure in the `report` stage
|
||||
|
@ -63,21 +60,6 @@ jobs:
|
|||
owner: ${{ github.event.workflow_run.head_repository.owner.login }}
|
||||
branch: ${{ github.event.workflow_run.head_branch }}
|
||||
|
||||
- name: Get commit details
|
||||
id: commit
|
||||
if: github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'merge_group'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const response = await github.rest.git.getCommit({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
commit_sha: "${{ github.event.workflow_run.head_sha }}",
|
||||
});
|
||||
core.setOutput("message", response.data.message);
|
||||
core.setOutput("author", response.data.author.name);
|
||||
core.setOutput("email", response.data.author.email);
|
||||
|
||||
# Percy is disabled while we're figuring out https://github.com/vector-im/wat-internal/issues/36
|
||||
# and https://github.com/vector-im/wat-internal/issues/56. We're hoping to turn it back on or switch
|
||||
# to an alternative in the future.
|
||||
|
@ -108,11 +90,13 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Naive segmentation of tests
|
||||
segment: ["a-i", "j-p", "q-s", "t-z"]
|
||||
# Run tests using both crypto stacks
|
||||
crypto: [legacy, rust]
|
||||
ci_node_total: [4]
|
||||
ci_node_index: [0, 1, 2, 3]
|
||||
steps:
|
||||
# The version of chrome shipped by default may not be consistent across runners
|
||||
# so we explicitly use a specific version of chrome here.
|
||||
- uses: browser-actions/setup-chrome@803ef6dfb4fdf22089c9563225d95e4a515820a0 # v1
|
||||
- run: echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV
|
||||
|
||||
|
@ -154,23 +138,24 @@ jobs:
|
|||
run: |
|
||||
echo "CYPRESS_RUST_CRYPTO=1" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Run Cypress tests
|
||||
- name: Run Cypress tests via knapsack pro
|
||||
uses: cypress-io/github-action@ebe8b24c4428922d0f793a5c4c96853a633180e3 # v6.6.0
|
||||
with:
|
||||
working-directory: matrix-react-sdk
|
||||
# The built-in Electron runner seems to grind to a halt trying to run the tests, so use chrome.
|
||||
browser: ${{ steps.setup-chrome.outputs.chrome-path }}
|
||||
headed: true
|
||||
start: npx serve -p 8080 -L ../webapp
|
||||
wait-on: "http://localhost:8080"
|
||||
record: true
|
||||
record: false
|
||||
parallel: false
|
||||
command-prefix: "yarn percy exec --parallel --"
|
||||
ci-build-id: ${{ needs.prepare.outputs.uuid }}-${{ matrix.crypto }}
|
||||
spec: cypress/e2e/[${{ matrix.segment }}]*/**
|
||||
# The built-in Electron runner seems to grind to a halt trying to run the tests, so use chrome.
|
||||
command: yarn percy exec --parallel -- npx knapsack-pro-cypress --config trashAssetsBeforeRuns=false --browser "$BROWSER_PATH"
|
||||
env:
|
||||
# pass the Dashboard record key as an environment variable
|
||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||
# Knapsack token and config
|
||||
KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS: ${{ matrix.crypto == 'rust' && secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS_RUST || secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS_LEGACY }}
|
||||
KNAPSACK_PRO_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
|
||||
KNAPSACK_PRO_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
|
||||
KNAPSACK_PRO_TEST_FILE_PATTERN: cypress/e2e/**/*.spec.ts
|
||||
KNAPSACK_PRO_BRANCH: ${{ github.event.workflow_run.head_branch }}
|
||||
|
||||
# Use existing chromium rather than downloading another
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
|
||||
|
@ -181,16 +166,6 @@ jobs:
|
|||
# make Node's os.tmpdir() return something where we actually have permissions
|
||||
TMPDIR: ${{ runner.temp }}
|
||||
|
||||
# tell Cypress more details about the context of this run
|
||||
COMMIT_INFO_BRANCH: ${{ github.event.workflow_run.head_branch }}
|
||||
COMMIT_INFO_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
COMMIT_INFO_REMOTE: ${{ github.repositoryUrl }}
|
||||
COMMIT_INFO_MESSAGE: ${{ needs.prepare.outputs.commit_message }}
|
||||
COMMIT_INFO_AUTHOR: ${{ needs.prepare.outputs.commit_author }}
|
||||
COMMIT_INFO_EMAIL: ${{ needs.prepare.outputs.commit_email }}
|
||||
CYPRESS_PULL_REQUEST_ID: ${{ needs.prepare.outputs.pr_id }}
|
||||
CYPRESS_PULL_REQUEST_URL: https://github.com/${{ github.repository }}/pull/${{ needs.prepare.outputs.pr_id }}
|
||||
|
||||
# pass the Percy token as an environment variable
|
||||
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue