-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (82 loc) · 2.66 KB
/
run_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Run tests
on: [ push ]
jobs:
list-tests:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
aoc_utils:
- aoc_utils/**
year_2016:
- 'year_2016/**'
year_2017:
- 'year_2017/**'
year_2018:
- 'year_2018/**'
year_2019:
- 'year_2019/**'
year_2023:
- 'year_2023/**'
year_2024:
- 'year_2024/**'
- id: set-matrix
run: echo "::set-output name=matrix::$(./list_test_combinations.sh ${{ join(fromJSON(steps.filter.outputs.changes), ' ') }})"
test:
runs-on: ubuntu-latest
needs: [ list-tests ]
if: ${{ needs.list-tests.outputs.matrix != '[]' && needs.list-tests.outputs.matrix != '' }}
strategy:
matrix:
include: ${{ fromJSON(needs.list-tests.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
if: ${{ matrix.language == 'python' }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
- name: Install dependencies
if: ${{ matrix.language == 'python' }}
run: |
python -m pip install --upgrade pip virtualenv
python -m pip install -r requirements.txt
- name: Run Tests
if: ${{ matrix.language == 'python'}}
run: python -m unittest discover -t . -s ${{ matrix.folder }} -p "*.py"
- name: Setup Rust
if: ${{ matrix.language == 'rust' }}
uses: moonrepo/setup-rust@v1
with:
channel: ${{ matrix.version }}
- name: Build
if: ${{ matrix.language == 'rust' }}
working-directory: ${{ matrix.folder }}
run: cargo build
- name: Run tests
if: ${{ matrix.language == 'rust' }}
working-directory: ${{ matrix.folder }}
run: cargo test
- name: Run binary
if: ${{ matrix.language == 'rust' && matrix.folder != 'aoc_utils' }}
working-directory: ${{ matrix.folder }}
run: cargo run
all-tests:
runs-on: ubuntu-latest
needs: [ list-tests, test ]
if: always()
steps:
- name: Failed tests
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: Cancelled tests
if: ${{ contains(needs.*.result, 'cancelled') }}
run: exit 1
- name: Successful tests
if: ${{ !(contains(needs.*.result, 'failure')) && !(contains(needs.*.result, 'cancelled')) }}
run: exit 0