-
Notifications
You must be signed in to change notification settings - Fork 8
339 lines (312 loc) · 11.8 KB
/
pull-request.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
name: Pull Request
on:
workflow_dispatch:
pull_request:
branches: [main]
env:
TARGET: Release
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
github: ${{ steps.filter.outputs.github }}
apps: ${{ steps.filter.outputs.apps }}
bindings: ${{ steps.filter.outputs.bindings }}
cmake: ${{ steps.filter.outputs.cmake }}
include: ${{ steps.filter.outputs.include }}
libs: ${{ steps.filter.outputs.libs }}
root: ${{ steps.filter.outputs.root }}
scripts: ${{ steps.filter.outputs.scripts }}
source: ${{ steps.filter.outputs.source }}
typescript: ${{ steps.filter.outputs.typescript }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
github:
- '.github/workflows/pull-request.yml'
apps:
- 'apps/**'
bindings:
- 'bindings/netstandard/**'
- 'src/electionguard-ui/ElectionGuard.UI.Lib/**'
cmake:
- 'cmake/**'
include:
- 'include/**'
libs:
- 'libs/**'
root:
- 'CMakeLists.txt'
- 'Makefile'
scripts:
- 'scripts/**'
source:
- 'src/electionguard/**'
- 'src/CMakeLists.txt'
- 'test/**'
typescript:
- 'bindings/typescript/**'
- 'src/electionguard/wasm/**'
build_and_test:
needs: changes
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name:
[
"ubuntu-22.04-clang-14.0.0",
"ubuntu-22.04-emscripten-3.1",
"ubuntu-22.04-gcc-12.1.0",
"macos-13-xcode-14.2",
"macos-13-xcode-14.2-arm64",
"windows-2022-gcc-11",
"windows-2022-msvc-latest-x86",
"windows-2022-msvc-latest-x64",
"ubuntu-22.04-linter",
]
include:
- name: ubuntu-22.04-clang-14.0.0
os: ubuntu-22.04
processor: x64
compiler: clang
version: "14"
makeReleaseBuild: false
lint: false
runCsTests: false
runTsTests: false
- name: ubuntu-22.04-emscripten-3.1
os: ubuntu-22.04
processor: x64
compiler: emscripten
version: "3.1.35"
makeReleaseBuild: true
lint: false
runCsTests: false
runTsTests: true
- name: ubuntu-22.04-gcc-12.1.0
os: ubuntu-22.04
processor: x64
compiler: gcc
version: "12"
makeReleaseBuild: false
lint: false
runCsTests: false
runTsTests: false
- name: macOS-13-xcode-14.2
os: macOS-13
processor: x64
compiler: xcode
version: "14.2"
makeReleaseBuild: false
lint: false
runCsTests: true
runTsTests: false
- name: macOS-13-xcode-14.2-arm64
os: macOS-13
processor: arm64
compiler: xcode
version: "14.2"
makeReleaseBuild: false
lint: false
runCsTests: false
runTsTests: false
- name: windows-2022-gcc-11
os: windows-2022
processor: x64
compiler: gcc
version: "11"
makeReleaseBuild: false
lint: false
runCsTests: false
runTsTests: false
- name: windows-2022-msvc-latest-x86
os: windows-2022
processor: x86
compiler: msvc
version: "latest"
makeReleaseBuild: false
lint: false
runCsTests: false
runTsTests: false
- name: windows-2022-msvc-latest-x64
os: windows-2022
processor: x64
compiler: msvc
version: "latest"
makeReleaseBuild: false
lint: false
runCsTests: true
runTsTests: false
- name: ubuntu-22.04-linter
os: ubuntu-22.04
processor: x64
compiler: clang
version: "14"
makeReleaseBuild: false
lint: true
runCsTests: true
runTsTests: false
steps:
- name: Configure Change Filter
id: filter
shell: bash
run: |
FILTER_ANY_CHANGE="false" # default value
if [[ "${{ needs.changes.outputs.github }}" == "true" || "${{ needs.changes.outputs.apps }}" == "true" || "${{ needs.changes.outputs.bindings }}" == "true" || "${{ needs.changes.outputs.cmake }}" == "true" || "${{ needs.changes.outputs.include }}" == "true" || "${{ needs.changes.outputs.libs }}" == "true" || "${{ needs.changes.outputs.root }}" == "true" || "${{ needs.changes.outputs.scripts }}" == "true" || "${{ needs.changes.outputs.source }}" == "true" || "${{ needs.changes.outputs.typescript }}" == "true" ]]; then
FILTER_ANY_CHANGE="true"
fi
FILTER_CPP_CHANGE="false" # default value
if [[ "${{ needs.changes.outputs.cmake }}" == "true" || "${{ needs.changes.outputs.include }}" == "true" || "${{ needs.changes.outputs.libs }}" == "true" || "${{ needs.changes.outputs.source }}" == "true" ]]; then
FILTER_CPP_CHANGE="true"
fi
echo "any=$FILTER_ANY_CHANGE" >> $GITHUB_OUTPUT
echo "cpp=$FILTER_CPP_CHANGE" >> $GITHUB_OUTPUT
echo "github=${{ needs.changes.outputs.github }}" >> $GITHUB_OUTPUT
echo "apps=${{ needs.changes.outputs.apps }}" >> $GITHUB_OUTPUT
echo "bindings=${{ needs.changes.outputs.bindings }}" >> $GITHUB_OUTPUT
echo "cmake=${{ needs.changes.outputs.cmake }}" >> $GITHUB_OUTPUT
echo "include=${{ needs.changes.outputs.include }}" >> $GITHUB_OUTPUT
echo "libs=${{ needs.changes.outputs.libs }}" >> $GITHUB_OUTPUT
echo "root=${{ needs.changes.outputs.root }}" >> $GITHUB_OUTPUT
echo "scripts=${{ needs.changes.outputs.scripts }}" >> $GITHUB_OUTPUT
echo "source=${{ needs.changes.outputs.source }}" >> $GITHUB_OUTPUT
echo "typescript=${{ needs.changes.outputs.typescript }}" >> $GITHUB_OUTPUT
# Checkout
- name: Checkout Code
if: (steps.filter.outputs.any == 'true')
uses: actions/checkout@v4
- name: Change Directory
if: (steps.filter.outputs.any == 'true')
run: cd ${{ github.workspace }}
# Cache
- name: Setup Dependency Cache
id: dependency-cache
if: (steps.filter.outputs.any == 'true')
uses: actions/cache@v3
with:
path: |
.cache/
key: ${{ matrix.name }}-dependencies-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
- name: Setup C++ Build Cache
id: build-cache
if: (steps.filter.outputs.any == 'true')
uses: actions/cache@v3
with:
path: |
build/
key: ${{ matrix.name }}-build-${{ hashFiles('**/*.h', '**/*.hpp', '**/*.cpp') }}
- name: Setup Node Cache
id: node-cache
if: (matrix.compiler == 'emscripten' && steps.filter.outputs.typescript == 'true')
uses: actions/cache@v3
with:
path: |
bindings/typescript/node_modules/
key: ${{ matrix.name }}-node-${{ hashFiles('**/package-lock.json') }}
# Runner Configuration
- name: Update Environment (Linux)
if: (runner.os == 'Linux' && steps.filter.outputs.any == 'true')
run: |
sudo apt-get update
if [ "${{ matrix.compiler }}" = "gcc" ]; then
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
elif [ "${{ matrix.compiler }}" = "emscripten" ]; then
make environment-wasm
source ./.cache/emscripten/emsdk_env.sh
# echo "CC=emcc" >> $GITHUB_ENV
# echo "CXX=em++" >> $GITHUB_ENV
else
sudo apt-get install -y clang-${{ matrix.version }} g++-multilib
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
fi
- name: Update Environment (Mac)
if: (runner.os == 'macOS' && steps.filter.outputs.any == 'true')
run: |
ls -ls /Applications/
ls -ls $ANDROID_SDK_ROOT/ndk
sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app
- name: Update Environment (Windows MSYS2)
if: (runner.os == 'Windows' && matrix.compiler == 'clang' && steps.filter.outputs.any == 'true')
uses: msys2/setup-msys2@v2
with:
update: true
msystem: clang64
install: >-
base-devel
mingw-w64-clang-x86_64-gcc
mingw-w64-clang-x86_64-toolchain
mingw-w64-clang-x86_64-clang-14
mingw-w64-clang-x86_64-cmake
mingw-w64-clang-x86_64-llvm-14
make
git
- name: Update Environment (Windows MSVC x64)
if: (runner.os == 'Windows' && matrix.compiler == 'msvc' && matrix.processor == 'x64' && steps.filter.outputs.any == 'true')
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.processor }}
- name: Update Environment (Windows MSVC x86)
if: (runner.os == 'Windows' && matrix.compiler == 'msvc' && matrix.processor == 'x86' && steps.filter.outputs.any == 'true')
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.processor }}
# Tools
- name: Install .NET
uses: actions/setup-dotnet@v3
if: (steps.filter.outputs.any == 'true')
with:
dotnet-version: 7.0.x
# Environment
- name: Configure Environment
if: (steps.filter.outputs.any == 'true')
run: make environment
# Lint
- name: Lint
if: (matrix.lint && steps.filter.outputs.any == 'true')
run: make lint
# Build
- name: Build CLI (Windows)
env:
PROCESSOR: ${{ matrix.processor }}
if: (runner.os == 'Windows' && matrix.compiler == 'msvc' && steps.filter.outputs.apps == 'true')
run: make build-cli
# Tests
- name: Run Tests (Linux)
env:
PROCESSOR: ${{ matrix.processor }}
if: (runner.os == 'Linux' && steps.filter.outputs.cpp == 'true')
run: make test
- name: Run Tests (MacOS)
env:
PROCESSOR: ${{ matrix.processor }}
if: (runner.os == 'macOS' && steps.filter.outputs.cpp == 'true')
run: make test
- name: Run Tests (Windows)
env:
PROCESSOR: ${{ matrix.processor }}
if: (runner.os == 'Windows' && matrix.compiler == 'msvc' && steps.filter.outputs.cpp == 'true')
run: make test
- name: Run Tests (Windows-x86)
env:
PROCESSOR: ${{ matrix.processor }}
if: (runner.os == 'Windows' && matrix.compiler == 'msvc' && matrix.processor == 'x86' && steps.filter.outputs.cpp == 'true')
run: make test-x86
- name: Run .Net Tests
env:
PROCESSOR: ${{ matrix.processor }}
if: (matrix.runCsTests && (steps.filter.outputs.bindings == 'true' || steps.filter.outputs.cpp == 'true'))
run: make test-netstandard
- name: Run Typescript Tests (Linux)
env:
PROCESSOR: ${{ matrix.processor }}
if: (matrix.runTsTests && (steps.filter.outputs.cpp == 'true' || steps.filter.outputs.typescript == 'true'))
run: make build-npm && make test-wasm