Skip to content

Commit

Permalink
attempt at fixing cypress in the ci
Browse files Browse the repository at this point in the history
- set up recording for cypress cloud
- add env variables for the workflows\
- create a new script for cypress in ci

moved this code, and added more to it, from #371
- ref: #378
  • Loading branch information
alishaevn committed Feb 13, 2024
1 parent e56fad6 commit b572103
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/build-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,33 @@ jobs:
webTarget: web
cypress:
runs-on: ubuntu-22.04
# Runs tests in parallel with matrix strategy https://docs.cypress.io/guides/guides/parallelization
strategy:
fail-fast: false # https://github.com/cypress-io/github-action/issues/48
matrix:
containers: [1, 2] # Uses 2 parallel instances
environment:
name: Production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cypress e2e
uses: cypress-io/github-action@v6
with:
start: yarn start
wait-on: 'http://localhost:3000'
wait-on: 'http://localhost:3001'
command: yarn cypress:e2e:ci
record: true
parallel: true
env:
# For recording and parallelization to work you must set your CYPRESS_RECORD_KEY
# in GitHub repo → Settings → Secrets → Actions
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
NEXT_PUBLIC_TOKEN: ${{ secrets.NEXT_PUBLIC_TOKEN }}
TEST_SESSION_COOKIE: ${{ secrets.TEST_SESSION_COOKIE }}
eslint:
needs: build
uses: scientist-softserv/actions/.github/workflows/[email protected]
Expand Down
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = defineConfig({
NEXT_PUBLIC_PROVIDER_NAME: 'acme',
NEXT_PUBLIC_PROVIDER_ID: '572'
},
projectId: '6wuou2',
reporter: 'junit',
reporterOptions: {
mochaFile: 'cypress/results/results-[hash].xml',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"build": "next build",
"cypress:e2e": "start-server-and-test dev http://localhost:3000 \"cypress open --e2e --browser electron\"",
"cypress:e2e:ci": "next build && start-server-and-test dev http://localhost:3001 \"cypress run --record --e2e --browser electron --key 9f881837-3cd6-48bb-b8dd-a3c085e2ce6c\"",
"cypress:headless:e2e": "start-server-and-test dev http://localhost:3000 \"cypress run --e2e --browser electron\"",
"dev": "next dev",
"lint": "next lint --dir pages --dir utils",
Expand Down

0 comments on commit b572103

Please sign in to comment.