-
-
Notifications
You must be signed in to change notification settings - Fork 5
154 lines (142 loc) · 4.89 KB
/
build-and-test.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
# Github Action to build and run tests
name: Build
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-20.04"]
dotnet_version: ["8.0.x"]
node_version: ["18.20.2"]
npm_version: ["10.9.0"]
# Continue building in other environments to see which are working.
fail-fast: false
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Deps: .NET"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{matrix.dotnet_version}}
- name: "Deps: Node"
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node_version}}
- name: "Deps: npm"
run: npm install --global npm@${{matrix.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.
run: |
set -xueo pipefail
[[ $(node --version) == v${{matrix.node_version}} ]]
[[ $(npm --version) == ${{matrix.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 \
-p:CollectCoverage=true \
-e:CoverletOutputFormat=opencover \
-e:Exclude=\"[NUnit3.TestAdapter]*,[SIL.XForge.*.Views]*,[SIL.XForge.Tests]*\"
- name: "Test: Frontend"
run: cd src/SIL.XForge.Scripture/ClientApp && npm run test:gha
- name: "Coverage: Backend"
run: |
reportgenerator \
-reports:test/*/coverage.opencover.xml \
-targetdir:coverage \
"-reporttypes:HTML;TeamCitySummary"
- name: "Coverage: Publish to Codecov"
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
build-production:
name: "Production build and test"
strategy:
matrix:
os: ["ubuntu-20.04"]
dotnet_version: ["8.0.x"]
node_version: ["18.20.2"]
npm_version: ["10.9.0"]
fail-fast: false
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Deps: .NET"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{matrix.dotnet_version}}
- name: "Deps: Node"
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node_version}}
- name: "Deps: npm"
run: npm install --global npm@${{matrix.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"
run: |
set -xueo pipefail
[[ $(node --version) == v${{matrix.node_version}} ]]
[[ $(npm --version) == ${{matrix.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