forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (110 loc) 路 3.97 KB
/
reusable-widget-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
# This is a basic workflow to help you get started with Actions
name: Test E2E WIDGET
# 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_widget:
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 80
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 3 copies of the current job in parallel
containers: [1, 2]
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_version: 12.9.0
cypress: true
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
with:
targets: lint
projects: '@novu/widget'
- uses: mansagroup/nrwl-nx-action@v3
with:
targets: build
projects: '@novu/widget,@novu/embed,@novu/api,@novu/worker,@novu/ws'
- 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 }}
# Runs a single command using the runners shell
- name: Start Client
run: pnpm start:widget:test &
- name: Start WS
env:
NODE_ENV: 'test'
TZ: 'UTC'
run: |
cp apps/ws/src/.env.test apps/ws/dist/src/.env.test
cd apps/ws && pnpm start:prod &
- name: Wait on Widget and WS Services
run: wait-on --timeout=180000 http://127.0.0.1:1340/v1/health-check http://127.0.0.1:3500/
- name: Cypress install
if: steps.setup-project.outputs.cypress_cache_hit != 'true'
working-directory: apps/widget
run: pnpm cypress install
- name: Cypress run
uses: cypress-io/github-action@v6
env:
NODE_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_WIDGET_KEY }}
with:
working-directory: apps/widget
wait-on: http://127.0.0.1:3500/
browser: chrome
install: false
record: true
parallel: true
config-file: cypress.config.ts
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: apps/widget/cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-videos
path: apps/widget/cypress/videos