misc: Test for actual failure vs skipped #10
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: Test Materials | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
find-files: | |
runs-on: ubuntu-latest | |
outputs: | |
files: ${{ steps.get-materials.outputs.files }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Get list of materials | |
id: get-materials | |
run: | | |
files=$(find materials/ -path "*/completed/*.py" -type f -not -path "*/archive/*" | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
echo "files=$files" >> $GITHUB_OUTPUT | |
run-tests: | |
needs: find-files | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/gem5/devcontainer:bootcamp-2024 | |
strategy: | |
matrix: | |
file: ${{ fromJson(needs.find-files.outputs.files) }} | |
continue-on-error: true | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Run test | |
id: run-test | |
continue-on-error: true | |
run: | | |
python3 materials/test-material.py "${{ matrix.file }}" | |
echo "${{ matrix.file }}=$?" >> results.txt | |
- name: Upload test results | |
uses: actions/upload-artifact@v2 | |
with: | |
name: test-results | |
path: results.txt | |
aggregate-results: | |
needs: run-tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download test results | |
uses: actions/download-artifact@v2 | |
with: | |
name: test-results | |
path: ./results | |
- name: Aggregate test results | |
run: | | |
failed=0 | |
for test in $(cat ./results/results.txt); do | |
result=$(echo $test | cut -d'=' -f2) | |
if [ "$result" -eq 1]; then | |
failed=1 | |
echo "Test failed for $(echo $test | cut -d'=' -f1)" | |
fi | |
done | |
exit $failed |