Skip to content

Commit

Permalink
chore: fix cypress config
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Aug 27, 2024
1 parent 74a8f59 commit 1231057
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 314 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ env:
# Adjust APP_NAME if your repository name is different
APP_NAME: ${{ github.event.repository.name }}

# This represents the server branch to checkout.
# Usually it's the base branch of the PR, but for pushes it's the branch itself.
# e.g. 'main', 'stable27' or 'feature/my-feature'
# n.b. server will use head_ref, as we want to test the PR branch.
BRANCH: ${{ github.base_ref || github.ref_name }}
# Server requires head_ref instead of base_ref, as we want to test the PR branch
BRANCH: ${{ github.head_ref || github.ref_name }}

jobs:
init:
Expand All @@ -32,6 +29,8 @@ jobs:
npmVersion: ${{ steps.versions.outputs.npmVersion }}

env:
# We'll install cypress in the cypress job
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_DOWNLOAD: true

steps:
Expand Down Expand Up @@ -89,9 +88,9 @@ jobs:
matrix:
# Run multiple copies of the current job in parallel
# Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
containers: [0, 1, 2]
containers: ['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)
# Always align this number with the total of e2e runners (max. index + 1)
total-containers: [3]

name: runner ${{ matrix.containers }}
Expand All @@ -112,17 +111,19 @@ jobs:
- name: Set up npm ${{ needs.init.outputs.npmVersion }}
run: npm i -g 'npm@${{ needs.init.outputs.npmVersion }}'

- name: Install cypress
run: ./node_modules/cypress/bin/cypress install

- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
uses: cypress-io/github-action@df7484c5ba85def7eef30db301afa688187bc378 # v6.7.2
with:
record: ${{ secrets.CYPRESS_RECORD_KEY && true }}
parallel: ${{ secrets.CYPRESS_RECORD_KEY && true }}
# cypress run type
# We already installed the dependencies in the init job
install: false
component: ${{ matrix.containers == 'component' }}
group: ${{ secrets.CYPRESS_RECORD_KEY && env.CYPRESS_GROUP }}
group: ${{ matrix.use-cypress-cloud && matrix.containers == 'component' && 'Run component' || matrix.use-cypress-cloud && 'Run E2E' || '' }}
# cypress env
ci-build-id: ${{ secrets.CYPRESS_RECORD_KEY && env.CYPRESS_BUILD_ID }}
tag: ${{ secrets.CYPRESS_RECORD_KEY && 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 @@ -136,7 +137,7 @@ jobs:
SPLIT_INDEX: ${{ matrix.containers == 'component' && 0 || matrix.containers }}

- name: Upload snapshots
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
if: always()
with:
name: snapshots_${{ matrix.containers }}
Expand All @@ -147,7 +148,7 @@ jobs:
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log

- name: Upload NC logs
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
if: failure() && matrix.containers != 'component'
with:
name: nc_logs_${{ matrix.containers }}
Expand Down
30 changes: 1 addition & 29 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from '@nextcloud/cypress/docker'
import { configureVisualRegression } from 'cypress-visual-regression/dist/plugin'
import { defineConfig } from 'cypress'
import cypressSplit from 'cypress-split'

Expand Down Expand Up @@ -27,14 +26,6 @@ export default defineConfig({
// https://github.com/cypress-io/cypress/issues/871
scrollBehavior: 'center',

// Visual regression testing
env: {
failSilently: false,
visualRegressionType: 'regression',
},
screenshotsFolder: 'cypress/snapshots/actual',
trashAssetsBeforeRuns: true,

e2e: {
// Disable session isolation
testIsolation: false,
Expand All @@ -43,25 +34,6 @@ export default defineConfig({
// You may want to clean this up later by importing these.
async setupNodeEvents(on, config) {
cypressSplit(on, config)
configureVisualRegression(on)

// Disable spell checking to prevent rendering differences
on('before:browser:launch', (browser, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.preferences.default['browser.enable_spellchecking'] = false
return launchOptions
}

if (browser.family === 'firefox') {
launchOptions.preferences['layout.spellcheckDefault'] = 0
return launchOptions
}

if (browser.name === 'electron') {
launchOptions.preferences.spellcheck = false
return launchOptions
}
})

// Remove container after run
on('after:run', () => {
Expand All @@ -76,7 +48,7 @@ export default defineConfig({
// Setting container's IP as base Url
config.baseUrl = `http://${ip}/index.php`
await waitOnNextcloud(ip)
await configureNextcloud([]) // pass empty array as WE are already the viewer
await configureNextcloud(['groupfolders']) // pass empty array as WE are already the viewer
return config
},
},
Expand Down
218 changes: 0 additions & 218 deletions cypress/dockerNode.ts

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,5 @@ Cypress.Commands.add('uploadContent', (user, blob, mimeType, target) => {

Cypress.Commands.add('runOccCommand', (command: string, options?: Partial<Cypress.ExecOptions>) => {
const env = Object.entries(options?.env ?? {}).map(([name, value]) => `-e '${name}=${value}'`).join(' ')
return cy.exec(`docker exec --user www-data ${env} nextcloud-cypress-tests-groupfolders php ./occ ${command}`, options)
return cy.exec(`docker exec --user www-data ${env} nextcloud-cypress-tests_groupfolders php ./occ ${command}`, options)
})
Loading

0 comments on commit 1231057

Please sign in to comment.