-
Notifications
You must be signed in to change notification settings - Fork 14
189 lines (155 loc) · 4.81 KB
/
pre-merge.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
name: Pre-merge
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- dev
- freezing
- main
push:
branches:
- dev
- freezing
workflow_dispatch:
env:
HUSKY: 0
jobs:
run-tests:
runs-on: ubuntu-latest
container:
image: node:18-alpine3.18
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install SO deps
run: apk add curl bash git
- name: Install dependencies
run: yarn ci
- name: Run lint
run: yarn lint
- name: Run tests
run: yarn test:unit:coverage
- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: coverage_unit_report
path: |
coverage/unit/lcov.info
coverage/unit/sonar-report.xml
retention-days: 1
run-prod-e2e-tests:
name: Run Dev E2E Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
group: [2, 3, 4, 5, 6, 7]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Run Cypress Tests
uses: cypress-io/github-action@v6
env:
PROD_CYPRESS_EMAIL: ${{ secrets.PROD_CYPRESS_EMAIL }}
PROD_CYPRESS_PASSWORD: ${{ secrets.PROD_CYPRESS_PASSWORD }}
VITE_ENVIRONMENT: 'production'
with:
build: yarn build
start: yarn dev --logLevel=warn
browser: chrome
wait-on: 'http://localhost:5173/'
wait-on-timeout: 120
config-file: cypress.config.prod.js
env: environment=prod,grepTags=@dev${{ matrix.group }}+-@xfail+-@dont_run_prod
- name: Generate Specs JSON
run: yarn generate-specs-json
- name: Validate Specs Tags
run: node ./scripts/check_tags.js specs.json
- name: Move Coverage Files
run: mv .nyc_output/out.json .nyc_output/out_${{ matrix.group }}.json
- name: Upload Cypress Screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: cypress_screenshots_${{ matrix.group }}
path: cypress/screenshots
retention-days: 4
- name: Upload Cypress Videos
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: cypress_videos_${{ matrix.group }}
path: cypress/videos
retention-days: 1
- name: Upload Coverage Files
uses: actions/upload-artifact@v4
with:
name: coverage_report_${{ matrix.group }}
path: .nyc_output/*
retention-days: 1
include-hidden-files: true
download_and_merge:
name: Download and Merge Coverage Reports
needs: run-prod-e2e-tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Dependencies
run: npm install --global nyc
- name: Download Coverage Artifacts
uses: actions/download-artifact@v4
with:
path: coverage_report
pattern: coverage_report_*
merge-multiple: true
- name: Merge Coverage Reports
run: npx nyc merge ./coverage_report .nyc_output/out.json
- name: Generate Text Coverage Report
run: npx nyc report --reporter=text-summary
- name: Generate HTML Coverage Report
run: npx nyc report --reporter=html --report-dir=./coverage/e2e
- name: Generate LCOV Report
run: npx nyc report --reporter=lcovonly --report-dir=./coverage/e2e
- name: Check E2E Test Coverage
if: ${{ always() }}
run: node ./scripts/check_coverage.js ./coverage/e2e/lcov.info 20
- name: Compress Coverage Reports
if: ${{ always() }}
run: zip -r coverage.zip coverage
- name: Upload Coverage Report Artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: coverage_e2e_report
path: coverage.zip
retention-days: 7
sonarcloud:
needs: [run-tests, download_and_merge]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: coverage_unit_report
- uses: actions/download-artifact@v4
with:
name: coverage_e2e_report
- name: Extract E2E Coverage Report
run: |
unzip coverage.zip -d coverage_e2e
pwd
find ./
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@v2.3.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }}