-
Notifications
You must be signed in to change notification settings - Fork 14
158 lines (140 loc) · 4.63 KB
/
cypress-testing.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
name: Klicker automated testing with cypress
on:
push:
branches: ['v3', 'v3*']
paths:
- apps/**
- packages/**
pull_request:
branches: ['v3', 'v3*']
types: [opened, synchronize, reopened]
paths:
- apps/**
- packages/**
env:
REGISTRY: ghcr.io
jobs:
cypress-run:
# runs-on: self-hosted
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: klicker
POSTGRES_PASSWORD: klicker
POSTGRES_DB: klicker-prod
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis_cache:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6380:6379
redis_exec:
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
image: redis:7
ports:
- 6379:6379
# strategy:
# fail-fast: false # https://github.com/cypress-io/github-action/issues/48
# matrix:
# containers: [1, 2] # Run parallel instances
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- name: Define node version
uses: actions/setup-node@v3
with:
node-version: 20
- name: Check out repository code
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 9.10.0
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: |
${{ env.STORE_PATH }}
~/.cache/Cypress
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: actions/cache@v3
name: Setup turbo cache
with:
path: |
.turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Install bun
run: pnpm add -g bun@1.0.7
- name: Install dependencies
run: pnpm install
# - name: Install azure-functions-core-tools
# run: npm i -g azure-functions-core-tools@4 --unsafe-perm true
- name: Prepare .env and local.settings.json files
run: |
mv apps/backend-docker/.env.cypress apps/backend-docker/.env
echo "$FUNC_RESPONSES_SETTINGS" > apps/func-incoming-responses/local.settings.json
echo "$FUNC_RESPONSE_PROCESSOR_SETTINGS" > apps/func-response-processor/local.settings.json
env:
FUNC_RESPONSES_SETTINGS: ${{ secrets.FUNC_RESPONSES_SETTINGS }}
FUNC_RESPONSE_PROCESSOR_SETTINGS: ${{ secrets.FUNC_RESPONSE_PROCESSOR_SETTINGS }}
- name: Build all packages and apps
run: pnpm run --filter @klicker-uzh/prisma build:test && pnpm run build:test
- name: Apply migrations and seed the database
run: |
cd packages/prisma
pnpm run prisma:reset:raw -f
pnpm run seed:test
env:
DATABASE_URL: postgres://klicker:klicker@localhost:5432/klicker-prod
- name: Start services in the background
run: pnpm run start:test &
env:
DATABASE_URL: postgres://klicker:klicker@localhost:5432/klicker-prod
# run: pnpm run start:test
- name: Cypress run
uses: cypress-io/github-action@v6
timeout-minutes: 20
with:
install: false
wait-on: 'http://127.0.0.1:3000/api/graphql, http://127.0.0.1:3001, http://127.0.0.1:3002, http://127.0.0.1:3003, http://127.0.0.1:3010'
wait-on-timeout: 300
record: true
browser: electron
working-directory: cypress
# parallel: true
env:
APP_SECRET: abcd
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
DATABASE_URL: postgres://klicker:klicker@localhost:5432/klicker-prod
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_ENV: production
# - name: Archive code coverage results
# uses: actions/upload-artifact@v3
# with:
# name: code-coverage
# path: cypress/coverage
# - name: Coveralls
# uses: coverallsapp/github-action@v2