-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (79 loc) · 2.73 KB
/
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
name: tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
run-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python # Set Python version
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Install pip and pytest
- name: Install dependencies
run: |
python -m pip install -Ur requirements-dev.txt
- name: Test with pytest
run: |
python -m coverage run --context=python${{ matrix.python-version }} -a -m unittest tests/test_*
mv .coverage .coverage.${{ matrix.python-version }}.${{github.ref_name}}.dat
- name: Upload test coverage results
uses: actions/upload-artifact@v3
with:
name: ".coverage.${{ matrix.python-version }}.${{github.ref_name}}.dat"
path: ".coverage.${{ matrix.python-version }}.${{github.ref_name}}.dat"
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
merge-coverage:
needs: [ run-test ]
runs-on: ubuntu-latest
steps:
- name: Install coverage
run: |
python -m pip install -U coverage
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}/downloaded/
- name: Unwrap generated nesting
run: |
find ./downloaded/ -type f -name "*.dat" -exec mv {} ${{ github.workspace }}/ \;
- name: Display structure of workspace
run: ls -lAp ${{ github.workspace }}
- name: Combine tests
run: |
python -m coverage combine
python -m coverage xml -o coverage-${{github.ref_name}}.xml
- name: Upload combined coverage artefact
uses: actions/upload-artifact@v3
with:
name: coverage-${{github.ref_name}}.xml
path: coverage-${{github.ref_name}}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
upload-to-codecov:
needs: [ merge-coverage ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: coverage-${{github.ref_name}}.xml
- name: Display structure of workspace
run: ls -lAp ${{ github.workspace }}
- name: Upload to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}