-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (59 loc) · 1.87 KB
/
unit-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
name: Run unit tests
on:
push:
branches:
- main
jobs:
setup-matrix:
runs-on: ubuntu-latest
name: Get changed files
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
with:
json: true
files: |
.github/workflows/gen_matrix.py
.github/workflows/unit-tests.yml
*/src/day*.hpp
*/src/test*.cpp
*/src/lib.h*
*/src/unit_test/*
*/Makefile
# reference: https://stackoverflow.com/a/65094398
- name: Setup matrix combinations
id: setup-matrix-combinations
run: python $GITHUB_WORKSPACE/.github/workflows/gen_matrix.py "test" "${{ steps.changed-files.outputs.all_changed_files }}" $GITHUB_OUTPUT
outputs:
matrix-combinations: ${{ steps.setup-matrix-combinations.outputs.matrix-combinations }}
matrix-job:
runs-on: ubuntu-latest
needs: setup-matrix
if: ${{ needs.setup-matrix.outputs.matrix-combinations != '{}' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix-combinations) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install compiler
run: |
sudo apt-get -qq -y update
if [[ ${{ matrix.compiler }} == clang++ ]]; then
sudo apt-get -qq -y install clang
else
sudo apt-get -qq -y install g++
fi
- name: Build test
run: |
cd ${{ matrix.directory }}
make CXX=${{ matrix.compiler }} DISABLE_BEAR=TRUE build/debug/${{ matrix.target }}
- name: Run test
run: |
cd ${{ matrix.directory }}
make CXX=${{ matrix.compiler }} DISABLE_BEAR=TRUE ${{ matrix.target }}