2024-06-30 21:11:55 +00:00
|
|
|
---
|
|
|
|
name: Unit-Tests
|
|
|
|
|
|
|
|
on: workflow_call
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
unit-tests:
|
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
fail-fast: false # Allows for matrix sub-jobs to fail without cancelling the rest
|
|
|
|
matrix:
|
|
|
|
platform: [ubuntu-latest, windows-latest]
|
2024-07-13 11:20:54 +00:00
|
|
|
python-version: ["3.11", "3.12"]
|
2024-06-30 21:11:55 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Setup poetry
|
|
|
|
id: poetry_setup
|
|
|
|
uses: ItsDrike/setup-poetry@v1
|
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2024-07-13 11:16:32 +00:00
|
|
|
install-args: "--without lint"
|
2024-06-30 21:11:55 +00:00
|
|
|
|
|
|
|
- name: Run pytest
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2024-07-13 11:29:54 +00:00
|
|
|
poetry run poe test
|
2024-06-30 21:11:55 +00:00
|
|
|
|
|
|
|
python .github/scripts/normalize_coverage.py
|
|
|
|
mv .coverage .coverage.${{ matrix.platform }}.${{ matrix.python-version }}
|
|
|
|
|
|
|
|
- name: Upload coverage artifact
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: coverage.${{ matrix.platform }}.${{ matrix.python-version }}
|
|
|
|
path: .coverage.${{ matrix.platform }}.${{ matrix.python-version }}
|
|
|
|
retention-days: 1
|
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
upload-coverage:
|
|
|
|
needs: [unit-tests]
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Setup poetry
|
|
|
|
id: poetry_setup
|
|
|
|
uses: ItsDrike/setup-poetry@v1
|
|
|
|
with:
|
|
|
|
python-version: 3.12
|
|
|
|
install-args: "--no-root --only test"
|
|
|
|
|
|
|
|
- name: Download all coverage artifacts
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
pattern: coverage.*
|
|
|
|
merge-multiple: true # support downloading multiple artifacts to same dir
|
|
|
|
|
|
|
|
# Combine all of the coverage files (for each os, python version - from matrix)
|
|
|
|
# into a single coverage file (.coverage), and produce a final (combined) coverage report.
|
|
|
|
- name: Combine coverage
|
|
|
|
run: |
|
|
|
|
coverage combine
|
|
|
|
coverage xml
|
|
|
|
coverage report
|
|
|
|
|
|
|
|
- name: Upload coverage to codeclimate
|
|
|
|
uses: paambaati/codeclimate-action@v8.0.0
|
|
|
|
env:
|
2024-07-13 16:03:06 +00:00
|
|
|
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
2024-06-30 21:11:55 +00:00
|
|
|
with:
|
|
|
|
coverageLocations: .coverage.xml:coverage.py
|
|
|
|
|
|
|
|
tests-done:
|
|
|
|
needs: [unit-tests]
|
|
|
|
if: always() && !cancelled()
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Set status based on required jobs
|
|
|
|
env:
|
|
|
|
RESULTS: ${{ join(needs.*.result, ' ') }}
|
|
|
|
run: |
|
|
|
|
for result in $RESULTS; do
|
|
|
|
if [ "$result" != "success" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|