Skip to content

Commit

Permalink
fix(cypress): introduce cypress-split
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv committed Mar 7, 2024
1 parent 234819f commit 3b5e864
Show file tree
Hide file tree
Showing 5 changed files with 1,148 additions and 60 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
fallbackNpm: "^10"

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

Expand All @@ -74,8 +74,11 @@ jobs:
fail-fast: false
matrix:
# Run multiple copies of the current job in parallel
# Please increase the number or runners as your tests suite grows
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
containers: [0, 1, 2, 3, 4, 5, 6, 7]
# Hack as strategy.job-total includes the component and GitHub does not allow math expressions
# Always aling this number with the total of e2e runners (max. index + 1)
total-containers: [8]

name: runner ${{ matrix.containers }}

Expand All @@ -88,7 +91,7 @@ jobs:
path: ./

- name: Set up node ${{ needs.init.outputs.nodeVersion }}
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ needs.init.outputs.nodeVersion }}

Expand All @@ -98,14 +101,11 @@ jobs:
- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
uses: cypress-io/github-action@1b70233146622b69e789ccdd4f9452adc638d25a # v6.6.1
with:
record: true
parallel: true
# cypress run type
component: ${{ matrix.containers == 'component' }}
group: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
group: ${{ matrix.use-cypress-cloud && matrix.containers == 'component' && 'Run component' || matrix.use-cypress-cloud && 'Run E2E' || '' }}
# cypress env
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
tag: ${{ github.event_name }}
ci-build-id: ${{ matrix.use-cypress-cloud && format('{0}-{1}', github.sha, github.run_number) || '' }}
tag: ${{ matrix.use-cypress-cloud && github.event_name || '' }}
env:
# Needs to be prefixed with CYPRESS_
CYPRESS_BRANCH: ${{ env.BRANCH }}
Expand All @@ -115,9 +115,11 @@ jobs:
TESTING: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
SPLIT: ${{ matrix.total-containers }}
SPLIT_INDEX: ${{ matrix.containers == 'component' && 0 || matrix.containers }}

- name: Upload snapshots
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: always()
with:
name: snapshots_${{ matrix.containers }}
Expand All @@ -128,14 +130,14 @@ jobs:
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log

- name: Upload NC logs
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: failure() && matrix.containers != 'component'
with:
name: nc_logs_${{ matrix.containers }}
path: nextcloud.log

summary:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-low
needs: [init, cypress]

if: always()
Expand Down
4 changes: 2 additions & 2 deletions css/viewer-main.css

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from '@nextcloud/cypress/docker'
import { defineConfig } from 'cypress'
import cypressSplit from 'cypress-split'

import getCompareSnapshotsPlugin from 'cypress-visual-regression/dist/plugin'

Expand All @@ -20,8 +21,8 @@ export default defineConfig({
// Needed to trigger `after:run` events with cypress open
experimentalInteractiveRunEvents: true,

// Faster processing, video is broken on GH actions anyway
video: false,
// faster video processing
videoCompression: false,

// Visual regression testing
env: {
Expand All @@ -32,12 +33,14 @@ export default defineConfig({
trashAssetsBeforeRuns: true,

e2e: {
// Disable isolation
// Disable session isolation
testIsolation: false,

// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
async setupNodeEvents(on, config) {
cypressSplit(on, config)

getCompareSnapshotsPlugin(on, config)

// Disable spell checking to prevent rendering differences
Expand Down
Loading

0 comments on commit 3b5e864

Please sign in to comment.