forked from sabinadams/testing_mono_repo
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (102 loc) · 3.28 KB
/
tests.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
name: Tests
on:
pull_request:
branches:
- main
env:
VITE_API_URL: ${{ vars.VITE_API_URL }}
API_SECRET: ${{ secrets.API_SECRET }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ vars.POSTGRES_DB }}
DATABASE_URL: postgres://${{ secrets.POSTGRES_USER }}:${{ secrets.POSTGRES_PASSWORD }}@postgres-service:5432/${{ vars.POSTGRES_DB }}
CI: 1
jobs:
unit-and-integration-tests:
runs-on: ubuntu-latest
container: node:18
services:
postgres-service:
image: postgres
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ vars.POSTGRES_DB }}
options: >-
--health-cmd pg_isready
--health-interval 1s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Dependencies
uses: ./.github/actions/prepare
- name: Run Unit Tests
run: npx vitest --config ./vitest.config.unit.ts
working-directory: backend
- name: Prisma Migrate Deploy
run: npx prisma migrate deploy
- name: Run Integration Tests
run: npx vitest --config ./vitest.config.integration.ts
working-directory: backend
e2e-tests:
runs-on: ubuntu-latest
container: mcr.microsoft.com/playwright:v1.37.0-jammy
strategy:
fail-fast: false
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
services:
postgres-service:
image: postgres
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ vars.POSTGRES_DB }}
options: >-
--health-cmd pg_isready
--health-interval 1s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Dependencies
uses: ./.github/actions/prepare
- name: Prisma Migrate Deploy
run: npx prisma migrate deploy
- name: Run E2e Tests
run: npx playwright test --shard=${{ matrix.shard }}
working-directory: e2e
env:
HOME: /root
- uses: actions/upload-artifact@v3
if: always()
with:
name: all-blob-reports
path: e2e/blob-report
retention-days: 3
merge-e2e-reports:
runs-on: ubuntu-latest
if: always()
needs: [e2e-tests]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Dependencies
uses: ./.github/actions/prepare
- name: Download Playwright Blob Reports
uses: actions/download-artifact@v3
with:
name: all-blob-reports
path: e2e/all-blob-reports
- name: Merge Playwright Blob Reports Into HTML Report and GitHub Annotations
run: npx playwright merge-reports --reporter=html,github ./all-blob-reports
working-directory: e2e
- name: Upload Merged Reports
uses: actions/upload-artifact@v3
with:
name: merged-report-attempt-${{ github.run_attempt }}
path: e2e/playwright-report
retention-days: 3