-
-
Notifications
You must be signed in to change notification settings - Fork 9
116 lines (112 loc) · 3.67 KB
/
run-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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Run tests
on:
pull_request:
types: [ opened, synchronize, reopened ]
push:
branches: [ main ]
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
run-tests:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
version: ['3.8', '3.9', '3.10', '3.11', '3.12']
include:
- version: '3.8'
tox-env: py38,py38-mypy,py38-lint,safety
- version: '3.9'
tox-env: py39,py39-mypy,py39-lint,safety
- version: '3.10'
tox-env: py310,py310-mypy,py310-lint,safety
- version: '3.11'
tox-env: py311,py311-mypy,py311-lint,safety
- version: '3.12'
tox-env: py312,py312-mypy,format,safety
- os: windows-latest
version: '3.12'
tox-env: py312,safety
- os: macos-latest
version: '3.12'
tox-env: py312,safety
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.version }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/share/pypoetry
key: ${{ runner.os }}-python-${{ matrix.version }}-poetry-${{ hashFiles('pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true' && ! startsWith (matrix.os, 'windows')
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Poetry (Windows)
if: steps.cache-deps.outputs.cache-hit != 'true' && startsWith (matrix.os, 'windows')
shell: pwsh
run: |
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Run tests
env:
TOX_PARALLEL_NO_SPINNER: 1
TOX_SHOW_OUTPUT: "True"
TOXENV: ${{ matrix.tox-env }}
run: |
tox run-parallel -p 2
mkdir coverage
mv .coverage.* "coverage/.coverage.py${{ matrix.version }}"
- name: Archive code coverage results
if: "startsWith (matrix.os, 'ubuntu')"
uses: actions/upload-artifact@v3
with:
name: code-coverage
path: coverage/.coverage.py*
report-coverage:
runs-on: ubuntu-latest
needs: run-tests
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ vars.PYTHON_VERSION }}
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v3
with:
path: |
.tox
~/.cache/pip
~/.cache/pypoetry
~/.local/share/pypoetry
key: ${{ runner.os }}-python-coverage-poetry-${{ hashFiles('pyproject.toml', 'tox.ini') }}
- name: Install Poetry
if: steps.cache-deps.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install Tox
run: |
pip install -U pip
pip install tox
- name: Download code coverage
uses: actions/download-artifact@v3
with:
name: code-coverage
- name: Combine Coverage files from all supported Python versions
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: tox run -v -e coverage
- name: Report Combined Coverage
uses: coverallsapp/github-action@v2
with:
file: coverage.xml