2024 Day 8 part 2 WIP #87
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |