-
-
Notifications
You must be signed in to change notification settings - Fork 5
197 lines (184 loc) · 6.35 KB
/
build-and-test.yml
File metadata and controls
197 lines (184 loc) · 6.35 KB
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
192
193
194
195
196
197
# Github Action to build and run tests
name: Build
permissions: {}
on:
push:
branches: [develop, master, sf-qa, sf-live]
pull_request:
workflow_dispatch:
jobs:
build-development:
name: "Build and test"
strategy:
matrix:
# Environments in which to run, such as those used in development and production, or which are candidates to
# move to.
os: ["ubuntu-22.04"]
dotnet_version: ["8.0.x"]
node_version: ["22.13.0"]
npm_version: ["10.9.2"]
# Continue building in other environments to see which are working.
fail-fast: false
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: "Deps: .NET"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{matrix.dotnet_version}}
cache: true
cache-dependency-path: src/SIL.XForge.Scripture/packages.lock.json
- name: "Deps: Node"
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node_version}}
cache: "npm"
cache-dependency-path: |
src/SIL.XForge.Scripture/ClientApp/package-lock.json
src/RealtimeServer/package-lock.json
- name: "Deps: npm"
env:
NPM_VERSION: ${{matrix.npm_version}}
run: |
set -xueo pipefail
npm install --global npm@${NPM_VERSION}
- name: Pre-build report
run: |
set -xueo pipefail
lsb_release -a
which dotnet
dotnet --version
dpkg -l dotnet\*
dotnet --list-sdks
dotnet --list-runtimes
which node
node --version
which npm
npm --version
which chromium-browser
chromium-browser --version
- name: "Ensure desired tool versions"
# The build machine may come with newer tools than we are ready for.
env:
NODE_VERSION: ${{matrix.node_version}}
NPM_VERSION: ${{matrix.npm_version}}
run: |
set -xueo pipefail
[[ $(node --version) == v${NODE_VERSION} ]]
[[ $(npm --version) == ${NPM_VERSION} ]]
- name: "Deps: reportgenerator tool"
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: "Deps: RealtimeServer npm"
run: cd src/RealtimeServer && (npm ci || (sleep 3m && npm ci))
- name: "Deps: Backend nuget"
run: dotnet restore
- name: "Deps: Frontend npm"
run: cd src/SIL.XForge.Scripture/ClientApp && (npm ci || (sleep 3m && npm ci))
- name: "Build: Backend, RealtimeServer"
run: dotnet build xForge.sln
- name: "Build: Frontend"
run: cd src/SIL.XForge.Scripture/ClientApp && npm run build
- name: "Test: Ensure tests not focused on a subset"
# grep returns code 123 when no matches are found. The operator ! negates the exit code.
run: |
! git ls-files | grep "\\.spec\\.ts" | xargs grep -P "^\s*(fdescribe|fit)\("
- name: "Test: RealtimeServer"
run: cd src/RealtimeServer && npm run test:ci
- name: "Test: Backend"
run: |
dotnet test \
--logger:"junit;LogFileName=junit.xml" \
-p:CollectCoverage=true \
-e:CoverletOutputFormat=opencover \
-e:Exclude=\"[NUnit3.TestAdapter]*,[SIL.XForge.*.Views]*,[SIL.XForge.Tests]*\"
# Run the tests while making sure none of the common/known warnings are printed
- name: "Test: Frontend"
run: |
set -euo pipefail
cd src/SIL.XForge.Scripture/ClientApp
npm run test:gha | tee test_output.log
! grep -P 'NG\d+|ERROR:|WARN:|LOG:|INFO:' test_output.log
- name: "Coverage: Backend"
run: |
reportgenerator \
-reports:test/*/coverage.opencover.xml \
-targetdir:coverage \
"-reporttypes:HTML;TeamCitySummary"
- name: "Coverage: Publish to Codecov"
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: "Test: Publish test results to Codecov"
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
build-production:
name: "Production build and test"
strategy:
matrix:
os: ["ubuntu-22.04"]
dotnet_version: ["8.0.x"]
node_version: ["22.13.0"]
npm_version: ["10.9.2"]
fail-fast: false
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: "Deps: .NET"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{matrix.dotnet_version}}
cache: true
cache-dependency-path: src/SIL.XForge.Scripture/packages.lock.json
- name: "Deps: Node"
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node_version}}
cache: "npm"
cache-dependency-path: |
src/SIL.XForge.Scripture/ClientApp/package-lock.json
src/RealtimeServer/package-lock.json
- name: "Deps: npm"
env:
NPM_VERSION: ${{matrix.npm_version}}
run: |
set -xueo pipefail
npm install --global npm@${NPM_VERSION}
- name: Pre-build report
run: |
set -xueo pipefail
lsb_release -a
which dotnet
dotnet --version
dpkg -l dotnet\*
dotnet --list-sdks
dotnet --list-runtimes
which node
node --version
which npm
npm --version
which chromium-browser
chromium-browser --version
- name: "Ensure desired tool versions"
env:
NODE_VERSION: ${{matrix.node_version}}
NPM_VERSION: ${{matrix.npm_version}}
run: |
set -xueo pipefail
[[ $(node --version) == v${NODE_VERSION} ]]
[[ $(npm --version) == ${NPM_VERSION} ]]
- name: "Production build"
run: scripts/build-production
- name: "Test: Backend"
run: dotnet test xForge.sln
- name: "Test: RealtimeServer"
run: cd src/RealtimeServer && npm run test:ci
- name: "Test: Frontend"
run: cd src/SIL.XForge.Scripture/ClientApp && npm run test:gha