forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (164 loc) 路 6.27 KB
/
reusable-web-e2e.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# This is a basic workflow to help you get started with Actions
name: Test WEB
# Controls when the action will run. Triggers the workflow on push or pull request
on:
workflow_call:
inputs:
ee:
description: 'use the ee version of worker'
required: false
default: false
type: boolean
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
e2e_web:
if: "!contains(github.event.head_commit.message, 'ci skip')"
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
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
permissions:
contents: read
packages: write
deployments: write
id-token: write
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- id: setup
run: |
if ! [[ -z "${{ secrets.SUBMODULES_TOKEN }}" ]]; then
echo "has_token=true" >> $GITHUB_OUTPUT
else
echo "has_token=false" >> $GITHUB_OUTPUT
fi
# checkout with submodules if token is provided
- uses: actions/checkout@v3
if: steps.setup.outputs.has_token == 'true'
with:
submodules: ${{ inputs.ee }}
token: ${{ secrets.SUBMODULES_TOKEN }}
# else checkout without submodules if the token is not provided
- uses: actions/checkout@v3
if: steps.setup.outputs.has_token != 'true'
- uses: ./.github/actions/setup-project
id: setup-project
with:
cypress: true
submodules: true
- uses: mansagroup/nrwl-nx-action@v3
with:
targets: lint,build
projects: '@novu/web,@novu/api,@novu/worker'
args: --skip-nx-cache
- uses: ./.github/actions/start-localstack
- uses: ./.github/actions/setup-redis-cluster
- uses: ./.github/actions/run-backend
with:
cypress_github_oauth_client_id: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_ID }}
cypress_github_oauth_client_secret: ${{ secrets.CYPRESS_GITHUB_OAUTH_CLIENT_SECRET }}
launch_darkly_sdk_key: ${{ secrets.LAUNCH_DARKLY_SDK_KEY }}
- name: Start Client
working-directory: apps/web
env:
REACT_APP_API_URL: http://127.0.0.1:1336
REACT_APP_WS_URL: http://127.0.0.1:1340
REACT_APP_WEBHOOK_URL: http://127.0.0.1:1341
REACT_APP_LAUNCH_DARKLY_CLIENT_SIDE_ID: ${{ secrets.TEST_LAUNCH_DARKLY_CLIENT_SIDE_ID }}
run: pnpm start:static:build &
- name: Start WS
run: |
cd apps/ws && pnpm start:test &
- name: Wait on Services
run: wait-on --timeout=180000 http://127.0.0.1:1340/v1/health-check http://127.0.0.1:4200/
# run cypress install only when cache was not hit
- name: Cypress install
if: steps.setup-project.outputs.cypress_cache_hit != 'true'
working-directory: apps/web
run: pnpm cypress install
- uses: browser-actions/setup-chrome@latest
with:
chrome-version: "stable"
- run: |
echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV
- name: Cypress run EE e2e
if: ${{ inputs.ee }}
uses: cypress-io/github-action@v6
env:
NODE_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_WEB_KEY }}
CYPRESS_GITHUB_USER_EMAIL: ${{ secrets.CYPRESS_GITHUB_USER_EMAIL }}
CYPRESS_GITHUB_USER_PASSWORD: ${{ secrets.CYPRESS_GITHUB_USER_PASSWORD }}
CYPRESS_IS_CI: true
with:
working-directory: apps/web
browser: "${{ env.BROWSER_PATH }}"
record: false
parallel: false
install: false
config-file: cypress.config.ts
spec: "cypress/tests/**/*.spec-ee.{js,jsx,ts,tsx}"
- name: Cypress run e2e
uses: cypress-io/github-action@v6
env:
NODE_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_WEB_KEY }}
CYPRESS_GITHUB_USER_EMAIL: ${{ secrets.CYPRESS_GITHUB_USER_EMAIL }}
CYPRESS_GITHUB_USER_PASSWORD: ${{ secrets.CYPRESS_GITHUB_USER_PASSWORD }}
CYPRESS_IS_CI: true
with:
working-directory: apps/web
browser: "${{ env.BROWSER_PATH }}"
record: false
parallel: false
install: false
config-file: cypress.config.ts
spec: "cypress/tests/**/*.spec.{js,jsx,ts,tsx}"
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: apps/web/cypress/screenshots
component_web:
if: "!contains(github.event.head_commit.message, 'ci skip')"
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-project
id: setup-project
# Runs a single command using the runners shell
- name: Build
run: CI='' pnpm build:web --skip-nx-cache
# run cypress install only when cache was not hit
- name: Cypress install
if: steps.setup-project.outputs.cypress_cache_hit != 'true'
working-directory: apps/web
run: pnpm cypress install
- name: Run Component tests 馃И
uses: cypress-io/github-action@v6
env:
NODE_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_WEB_KEY }}
NODE_OPTIONS: --max_old_space_size=4096
with:
browser: chrome
working-directory: apps/web
install: false
component: true
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: apps/web/cypress/screenshots