set the custom spec pattern #305
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
name: ci | |
on: push | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
jobs: | |
# example splitting all tests across GitHub machines | |
prepare: | |
runs-on: ubuntu-22.04 | |
# explicitly set the output of this job | |
# so that other jobs can use it | |
outputs: | |
matrix: ${{ steps.prepare.outputs.matrix }} | |
steps: | |
# generate the list using a bash script | |
- name: Create matrix ⊹ | |
id: prepare | |
# for reusable workflow, must use the full action reference | |
uses: bahmutov/gh-build-matrix@v1.0.1 | |
with: | |
n: 3 # number of containers to output | |
- name: Print result 🖨 | |
run: echo '${{ steps.prepare.outputs.matrix }}' | |
# two jobs that split 2 explicit specs | |
test-spec: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
containers: [1, 2] | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Run split Cypress E2E tests 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
build: npm run test-names | |
# using operating system process environment variables | |
env: | |
SPEC: 'cypress/e2e/spec-b.cy.js,cypress/e2e/spec-e.cy.js' | |
SPLIT: ${{ strategy.job-total }} | |
SPLIT_INDEX: ${{ strategy.job-index }} | |
DEBUG: 'cypress-split' | |
test-subfolder: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Run Cypress E2E tests in the subfolder 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
build: npm run subfolder | |
env: | |
SPLIT: 2 | |
SPLIT_INDEX: 0 | |
test-merge-timings: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Install dependencies 🧪 | |
uses: cypress-io/github-action@v5 | |
with: | |
runTests: false | |
- name: Merge example timings ⛙ | |
id: merge | |
run: npm run demo-merge -- --set-gha-output merged | |
env: | |
DEBUG: cypress-split | |
- name: Show merged output | |
run: | | |
echo off | |
echo '${{ steps.merge.outputs.merged }}' | |
test-split: | |
needs: prepare | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Print GitHub variables 🖨 | |
run: npx @bahmutov/print-env GITHUB | |
- name: Print GitHub strategy context 🖨 | |
run: echo '${{ toJSON(strategy) }}' | |
- name: Run split Cypress tests 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
build: npm run test-names | |
# using operating system process environment variables | |
env: | |
SPLIT: ${{ strategy.job-total }} | |
SPLIT_INDEX: ${{ strategy.job-index }} | |
test-no-summary: | |
needs: prepare | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Run some Cypress tests 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
# run half of all specs | |
env: | |
SPLIT: 2 | |
# run the second part of the list of specs | |
SPLIT_INDEX: 1 | |
# do not write summary to github | |
SPLIT_SUMMARY: false | |
test-empty: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Run an empty Cypress split 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
build: npm run deps | |
command: npm run empty | |
test-user-spec-list: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Split explicit user list of specs 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
command: npm run user-specs | |
test-timings: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Split specs based on timings json file 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
command: npm run timings | |
test-timings-no-file: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Split specs based on non-existen timings json file 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
command: npm run timings-no-file | |
test-find-timings-file: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Needs to find the timings file 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
with: | |
project: examples/timings-file/tests/cypress-tests | |
env: | |
SPLIT: 1 | |
SPLIT_INDEX: 0 | |
# the timings file is not next to the config file | |
# but in the project folder | |
SPLIT_FILE: timings.json | |
test-workflow-e2e: | |
# https://github.com/bahmutov/cypress-workflows | |
uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v1 | |
with: | |
n: 3 | |
test-workflow-component: | |
# https://github.com/bahmutov/cypress-workflows | |
uses: bahmutov/cypress-workflows/.github/workflows/split.yml@v1 | |
with: | |
component: true | |
n: 2 | |
# using SPLIT_INDEX1 to start index at 1 | |
test-index1: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Run split Cypress E2E tests 🧪 | |
# https://github.com/cypress-io/github-action | |
uses: cypress-io/github-action@v5 | |
# using operating system process environment variables | |
env: | |
SPEC: 'cypress/e2e/spec-b.cy.js,cypress/e2e/spec-e.cy.js' | |
SPLIT: 2 | |
# should run the first spec "spec-b" in the list | |
SPLIT_INDEX1: 1 | |
DEBUG: 'cypress-split' | |
release: | |
if: github.ref == 'refs/heads/main' | |
needs: | |
[ | |
test-empty, | |
test-split, | |
test-spec, | |
test-workflow-e2e, | |
test-workflow-component, | |
test-no-summary, | |
test-user-spec-list, | |
test-subfolder, | |
test-index1, | |
test-timings, | |
test-timings-no-file, | |
test-merge-timings, | |
test-find-timings-file, | |
] | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@v4 | |
- name: Semantic Release 🚀 | |
uses: cycjimmy/semantic-release-action@v3 | |
with: | |
branch: main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |