Merge pull request #41039 from nextcloud/fix/run-cypress-always-parallel

feat(cypress): Always run cypress CI in parallel
pull/40877/head
Ferdinand Thiessen 2023-10-22 18:58:39 +07:00 committed by GitHub
commit 91e02fea0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 756 additions and 50 deletions

@ -72,15 +72,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: ["component", 1, 2]
# Only use cypress cloud for PRs
use-cypress-cloud:
- ${{ !!github.head_ref }}
# Only use one container if we are not using the cypress cloud.
exclude:
- use-cypress-cloud: false
containers: 2
# Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
containers: ["component", 0, 1, 2]
# 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: [3]
name: runner ${{ matrix.containers }}
@ -103,9 +99,6 @@ jobs:
- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
uses: cypress-io/github-action@59810ebfa5a5ac6fcfdcfdf036d1cd4d083a88f2 # v6.5.0
with:
record: ${{ !!matrix.use-cypress-cloud }}
parallel: ${{ !!matrix.use-cypress-cloud }}
# cypress run type
component: ${{ matrix.containers == 'component' }}
group: ${{ matrix.use-cypress-cloud && matrix.containers == 'component' && 'Run component' || matrix.use-cypress-cloud && 'Run E2E' || '' }}
# cypress env
@ -120,6 +113,8 @@ 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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3

@ -6,6 +6,7 @@ import {
waitOnNextcloud,
} from './cypress/dockerNode'
import { defineConfig } from 'cypress'
import cypressSplit from 'cypress-split'
import webpackPreprocessor from '@cypress/webpack-preprocessor'
import type { Configuration } from 'webpack'
@ -47,6 +48,8 @@ export default defineConfig({
// 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)
on('file:preprocessor', webpackPreprocessor({ webpackOptions: webpackConfig as Configuration }))
// Disable spell checking to prevent rendering differences
@ -76,18 +79,16 @@ export default defineConfig({
// Before the browser launches
// starting Nextcloud testing container
return startNextcloud(process.env.BRANCH)
.then((ip) => {
// Setting container's IP as base Url
config.baseUrl = `http://${ip}/index.php`
return ip
})
.then(waitOnNextcloud)
.then(configureNextcloud)
.then(applyChangesToNextcloud)
.then(() => {
return config
})
const ip = await startNextcloud(process.env.BRANCH)
// Setting container's IP as base Url
config.baseUrl = `http://${ip}/index.php`
await waitOnNextcloud(ip)
await configureNextcloud()
await applyChangesToNextcloud()
// IMPORTANT: return the config otherwise cypress-split will not work
return config
},
},

761
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -143,6 +143,7 @@
"css-loader": "^6.8.1",
"cypress": "^13.3.0",
"cypress-if": "^1.10.5",
"cypress-split": "^1.15.3",
"cypress-wait-until": "^2.0.1",
"dockerode": "^4.0.0",
"eslint-plugin-cypress": "^2.15.1",