forked from PyMoDAQ/PyMoDAQ
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (163 loc) · 6.55 KB
/
Copy pathtests.yml
File metadata and controls
190 lines (163 loc) · 6.55 KB
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
183
184
185
186
187
188
189
190
name: tests
on:
workflow_call:
pull_request:
push:
branches:
- '*'
- '!badges' # to exclude execution if someone pushes on this branch (shouldn't happen)
concurrency:
# github.workflow: name of the workflow
# github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Cancel in-progress runs when a new workflow with the same group name is triggered
cancel-in-progress: true
jobs:
tests:
continue-on-error: true
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
qt-backend: ["pyqt5", "pyqt6", "pyside6"]
runs-on: ${{ matrix.os }}
env:
DISPLAY: ':99'
QT_DEBUG_PLUGINS: 1
steps:
# Get the branch name for the badge generation
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "${GITHUB_OUTPUT}"
id: extract_branch
- name: Checkout the repo
uses: actions/checkout@v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.4.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb pytest-xdist setuptools wheel numpy h5py ${{ matrix.qt-backend }}
pip install -e .
# Create folder and set permissions on Ubuntu
- name: Create local pymodaq folder setup env (Linux)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install -y libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-cursor0 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils libgl1 libegl1
export QT_DEBUG_PLUGINS=1
sudo mkdir -p /etc/.pymodaq
sudo chmod uo+rw /etc/.pymodaq
- name: Exporting debug variables (Windows)
if: runner.os == 'Windows'
run: |
set QT_DEBUG_PLUGINS=1
- name: Linting with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=docs
- name: Tests with ${{ matrix.os }} ${{ matrix.python-version }} ${{ matrix.qt-backend}}
id: tests
run: |
mkdir coverage
pytest -vv --cov=pymodaq -n 1
mv .coverage coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }}_${{ matrix.qt-backend }}
- name: Upload coverage artifact
uses: actions/upload-artifact@v4.6.1
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}_${{ matrix.qt-backend }}
path: coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }}_${{ matrix.qt-backend }}
- name: Create destination directory
if: ${{ always() }}
run: |
mkdir -p "${{ steps.extract_branch.outputs.branch }}"
- name: generate badge (success)
if: ${{ success() }}
uses: emibcn/badge-action@v2.0.3
with:
label: ''
status: 'passing'
color: 'green'
path: '${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}_${{matrix.qt-backend}}.svg'
- name: generate badge (fail)
if: ${{ failure() }}
uses: emibcn/badge-action@v2.0.3
with:
label: ''
status: 'failing'
color: 'red'
path: '${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}_${{matrix.qt-backend}}.svg'
- name: Upload badge artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4.6.1
with:
name: tests_${{runner.os}}_${{matrix.python-version}}_${{matrix.qt-backend}}
path: '${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}_${{matrix.qt-backend}}.svg'
if-no-files-found: error
outputs:
branch: ${{ steps.extract_branch.outputs.branch }}
badge-update:
runs-on: ubuntu-latest
needs: tests # Ensure this job runs after all matrix jobs complete
steps:
# switch to badges branches to commit
- uses: actions/checkout@v4.2.2
with:
ref: badges
- name: Download badges
uses: actions/download-artifact@v4.1.9
- name: Reorganize badges
run: |
rm -rf coverage* || true
rm -rf $(git ls-files ${{ needs.tests.outputs.branch }}/*) || true
git rm $(git ls-files ${{ needs.tests.outputs.branch }}/*) || true
mkdir -p '${{ needs.tests.outputs.branch }}'
mv tests_*/*.svg '${{ needs.tests.outputs.branch }}'
- name: Commit badges
continue-on-error: true
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add ${{ needs.tests.outputs.branch }}
git commit --allow-empty -m "Add/Update badge"
- name: Push badges
uses: ad-m/github-push-action@v0.8.0
if: ${{ success() }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges
coverage-update:
runs-on: ubuntu-latest
needs: tests # Ensure this job runs after all matrix jobs complete
steps:
- name: Checkout the repo
uses: actions/checkout@v4.2.2
- name: Download all coverage artifacts
uses: actions/download-artifact@v4.1.9
with:
path: ./coverage-reports
- name: Reorganize reports
run: |
cd coverage-reports
rm -rf tests_*
for folder in *; do
mv "${folder}"/* .;
done;
rmdir --ignore-fail-on-non-empty * || true
cd ..
# We only combine linux reports otherwise the tool complains about windows directories ...
- name: Combine coverage reports
run: |
python -m pip install coverage
coverage combine ./coverage-reports/coverage_*
coverage xml -i
- name: Upload combined coverage report to Codecov
uses: codecov/codecov-action@v5.4.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml