-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (151 loc) · 5.57 KB
/
test.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Test and Deploy
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
ALLOW_PLOTTING: true
SHELLOPTS: "errexit:pipefail"
jobs:
test:
if: "!startsWith(github.event.head_commit.message, '🚀 bump:')"
strategy:
matrix:
os: [Windows, macOS, Ubuntu]
python-version: ["3.8", "3.9", "3.10"]
qt-lib: [pyqt5, pyqt6, pyside2, pyside6]
include:
- os: Ubuntu
image: ubuntu-22.04
- os: Windows
image: windows-2022
- os: MacOS
image: macos-12
- python-version: "3.8"
tox-env: "py38"
- python-version: "3.9"
tox-env: "py39"
- python-version: "3.10"
tox-env: "py310"
fail-fast: false
defaults:
run:
shell: bash
name: Test - ${{ matrix.os }} / ${{ matrix.python-version }}-${{ matrix.qt-lib }}
runs-on: ${{ matrix.image }}
steps:
- name: Check out the Repository
uses: actions/checkout@v3
- name: Update Ubuntu
if: matrix.os == 'Ubuntu'
run: |
sudo apt update -y
sudo apt install -y libgles2-mesa-dev
- name: Install `python` ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Print `python` Version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and Configure Poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Print `poetry` Version
run: poetry --version
- name: Setup `python` Cache
uses: actions/cache@v3
id: python-cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ matrix.qt-lib }}-${{ hashFiles('**/poetry.lock') }}
- name: Verify `python` Cache is Healthy
if: steps.python-cache.outputs.cache-hit == 'true'
run: |
# `timeout` is not available on macOS, so we define a custom function.
[ "$(command -v timeout)" ] || function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
# Using `timeout` is a safeguard against the Poetry command hanging for some reason.
timeout 10s poetry run pip --version || rm -rf .venv
- name: Setup `tox` Cache
uses: actions/cache@v3
id: tox-cache
with:
path: .tox
key: tox-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ matrix.qt-lib }}-${{ hashFiles('**/poetry.lock') }}
- name: Install GitHub Actions Dependencies
run: |
poetry run pip install --upgrade pip
poetry run python -m pip install tox-gh-actions
poetry run python -m pip install pytest-github-actions-annotate-failures
- name: Copy Stubs to `.venv/lib/python*/site-packages`` (MacOS/Ubuntu)
if: matrix.os != 'Windows'
run: |
cp -R stubs/PySide6-stubs/* .venv/lib/python*/site-packages/
cp -R stubs/pytestqt-stubs/* .venv/lib/python*/site-packages/
- name: Copy Stubs to `.venv/Lib/site-packages` (Windows)
if: matrix.os == 'Windows'
run: |
cp -R stubs/PySide6-stubs/* .venv/Lib/site-packages/
cp -R stubs/pytestqt-stubs/* .venv/Lib/site-packages/
- name: Setup Headless Display
uses: pyvista/setup-headless-display-action@v1
- name: Run tests
env:
QT_QPA_PLATFORM: "offscreen"
PYTEST_QT_API: ${{ matrix.qt-lib }}
QT_API: ${{ matrix.qt-lib }}
run: poetry run tox -e ${{ matrix.tox-env }}-${{ matrix.qt-lib }}
- name: Upload Coverage Artifacts
uses: actions/upload-artifact@v3
with:
name: coverage_data
path: tox-.coverage.*
coverage:
name: Coverage
needs: test
defaults:
run:
shell: bash
runs-on: ubuntu-latest
steps:
- name: Check out the Repository
uses: actions/checkout@v3
- name: Install `python` ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox coverage
python -m pip install pytest-github-actions-annotate-failures
- name: Download Coverage Artifacts
uses: actions/download-artifact@v3
with:
name: coverage_data
- name: Combine Coverage Results
run: |
python -m tox -e coverage
export TOTAL=$(python -c "import json;print(json.load(open('logs/coverage/coverage.json'))['totals']['percent_covered_display'])")
echo "total_coverage=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: Make Coverage Badge
uses: schneegans/[email protected]
with:
# `GIST_TOKEN` is simply a personal access token with a scope of "gist".
auth: ${{ secrets.GIST_SECRET }}
gistID: 93a225b73dfa5ee041e6786dfbeff9ad
filename: coverage_badge.json
label: Coverage
message: ${{ env.total_coverage }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total_coverage }}