aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.coveragerc1
-rw-r--r--.github/workflows/test.yaml59
2 files changed, 39 insertions, 21 deletions
diff --git a/.coveragerc b/.coveragerc
index cc2a148..ce475d7 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,5 +1,6 @@
[run]
branch = true
+data_file = ${COVERAGE_DATAFILE-.coverage}
include = snekbox/*
omit =
snekbox/api/app.py
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 8a4078a..70a7d3c 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -41,37 +41,54 @@ jobs:
- name: Disable swap memory
run: sudo swapoff -a
- # Run tests and generate coverage report in the container.
+ # Run tests with coverage within the container.
+ # Suffix the generated coverage datafile with the name of the runner's OS.
- name: Run tests
id: run_tests
- run: |
- echo '::set-output name=started::true'
- docker exec snekbox_dev /bin/bash -c 'coverage run -m unittest'
+ run: >-
+ docker exec -e COVERAGE_DATAFILE=.coverage.${{ matrix.os }} snekbox_dev /bin/bash -c
+ 'coverage run -m unittest'
+
+ # Upload it so the coverage from all matrix jobs can be combined later.
+ - name: Upload coverage data
+ uses: actions/upload-artifact@v2
+ with:
+ name: coverage
+ path: .coverage.*
+ retention-days: 1
+
+ report:
+ name: Combine and report coverage data
+ runs-on: ubuntu-20.04
+ needs: test
- - name: Generate coverage report
- if: always() && steps.run_tests.outputs.started == 'true'
- run: docker exec snekbox_dev /bin/bash -c 'coverage report -m'
+ steps:
+ # Needed for the .coveragerc file.
+ - name: Checkout code
+ uses: actions/checkout@v2
- # Set up a Python version to process the coverage reports.
- # This action doesn't work on the self-hosted runner, but it already has
- # 3.9, which is sufficient. This step runs even if the test step failed
- # to ensure coverage reports are processed.
- name: Set up Python
- if: matrix.os != 'self-hosted' && always() && steps.run_tests.outputs.started == 'true'
- id: python
uses: actions/setup-python@v2
with:
- python-version: '3.10'
+ python-version: "3.10"
+
+ - name: Install dependencies
+ run: pip install coverage~=6.0 coveralls~=3.3
+
+ - name: Download coverage data
+ uses: actions/download-artifact@v2
+ with:
+ name: coverage
+
+ - name: Combine coverage data
+ run: coverage combine .coverage.*
+
+ - name: Display coverage report
+ run: coverage report -m
# Comment on the PR with the coverage results and register a GitHub check
# which links to the coveralls.io job.
- #
- # coveralls is only needed in CI, so install it directly instead of
- # including it in the Pipfile.
- name: Publish coverage report to coveralls.io
- if: always() && steps.run_tests.outputs.started == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- pip install coveralls~=2.1
- coveralls
+ run: coveralls