-
Notifications
You must be signed in to change notification settings - Fork 11
111 lines (109 loc) · 4.19 KB
/
cypress-e2e-chrome.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: E2E Cypress Tests (Chrome)
on:
push:
branches:
- main
pull_request:
pull_request_target:
types:
- labeled
jobs:
label_check:
runs-on: ubuntu-latest
outputs:
authorized: ${{ steps.label_check.outputs.authorized }}
steps:
- name: Check if authorized label is present
id: label_check
run: |
LABEL_NAME="CI Approved"
PR_LABELS=$(jq '.pull_request.labels[].name' $GITHUB_EVENT_PATH | tr '\n' ' ')
if [[ ${PR_LABELS} =~ ${LABEL_NAME} ]]; then
echo "Authorized label found."
echo "::set-output name=authorized::true"
else
echo "Authorized label not found."
echo "::set-output name=authorized::false"
fi
cypress-e2e-chrome:
name: Cypress E2E Chrome
runs-on: ubuntu-20.04
# Don't run the e2e tests for dependabot prs or if the PR is not labeled as 'safe to test'.
if: |
${{ github.actor != 'dependabot[bot]' &&
needs.label_check.outputs.authorized == 'true' }}
# Only run the e2e tests if a maintainer has labeled the PR as 'safe to test'.
needs: [label_check]
timeout-minutes: 15
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run 4 copies of the current job in parallel
containers: [1, 2, 3, 4, 5]
steps:
- name: Checkout
uses: actions/checkout@v3
# enables use to use the cache in actions/setup-node
- uses: pnpm/[email protected]
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: CacheAreas
id: cache-areas
uses: actions/cache@v3
with:
path: ./src/api/db/manage/areaToDatabase/.areaInfo.geojson
key: ${{ runner.os }}-areaInfo
- name: Install dependencies
run: pnpm install
- name: Database init
uses: supabase/setup-cli@v1
with:
version: 1.27.7
- run: SUPABASE_SCANNER_BUFFER_SIZE=5mb supabase start
- name: NextCache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: Cypress run
uses: cypress-io/github-action@v4
env:
DATABASE_NAME: toiletmap
VERCEL_URL: http://localhost:3000
AUTH0_SECRET: ${{ secrets.AUTH0_SECRET }}
AUTH0_ISSUER_BASE_URL: https://gbptm.eu.auth0.com/
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
AUTH0_AUDIENCE: https://www.toiletmap.org.uk/graphql
AUTH0_PERMISSIONS_KEY: https://toiletmap.org.uk/permissions
AUTH0_PROFILE_KEY: https://toiletmap.org.uk/profile
CYPRESS_auth0SessionCookieName: 'appSession'
CYPRESS_auth0Username: ${{ secrets.CYPRESS_AUTH0USERNAME }}
CYPRESS_auth0Password: ${{ secrets.CYPRESS_AUTH0PASSWORD }}
CYPRESS_auth0Scope: 'openid profile email'
CYPRESS_auth0Domain: 'gbptm.eu.auth0.com'
CYPRESS_auth0Audience: https://www.toiletmap.org.uk/graphql
CYPRESS_auth0ClientSecret: ${{ secrets.CYPRESS_AUTH0CLIENTSECRET }}
CYPRESS_auth0ClientId: ${{ secrets.CYPRESS_AUTH0CLIENTID }}
CYPRESS_auth0CookieSecret: ${{ secrets.CYPRESS_AUTH0COOKIESECRET }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
with:
build: pnpm build
start: pnpm start
wait-on: 'http://localhost:3000/'
wait-on-timeout: 60
browser: chrome
spec: cypress/e2e/**/*.ts
record: true
parallel: true
group: 1. Chrome