Skip to content

Commit 59d566c

Browse files
authored
Merge pull request #2 from PyMoDAQ/actions/activate-tests
github action for tests with badges showing in README
2 parents c24c916 + 897985d commit 59d566c

File tree

3 files changed

+221
-118
lines changed

3 files changed

+221
-118
lines changed

.github/workflows/tests-utils.yml

Lines changed: 0 additions & 118 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Test for serializall
2+
3+
on:
4+
workflow_call:
5+
pull_request:
6+
push:
7+
branches:
8+
- '*'
9+
- '!badges' # to exclude execution if someone pushes on this branch (shouldn't happen)
10+
11+
concurrency:
12+
# github.workflow: name of the workflow
13+
# github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
# Cancel in-progress runs when a new workflow with the same group name is triggered
16+
cancel-in-progress: true
17+
18+
jobs:
19+
tests:
20+
continue-on-error: true
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: ["ubuntu-latest", "windows-latest"]
25+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
26+
runs-on: ${{ matrix.os }}
27+
28+
steps:
29+
30+
# As we work on packages/<package> checkout needs to be first
31+
# to ensure folder existence
32+
- name: Checkout the repo
33+
uses: actions/checkout@v5.0.0
34+
with:
35+
fetch-depth: 0
36+
37+
# Get the branch name for the badge generation
38+
- name: Extract branch name
39+
shell: bash
40+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "${GITHUB_OUTPUT}"
41+
id: extract_branch
42+
43+
- name: Create badge destination directory
44+
run: |
45+
mkdir -p "${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}"
46+
echo ${{ github.workspace }}
47+
48+
- name: Set up Python ${{ matrix.python-version }}
49+
uses: actions/setup-python@v6.0.0
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
53+
- name: Install dependencies
54+
run: |
55+
python -m pip install --upgrade pip
56+
pip install flake8 pytest pytest-cov pytest-xdist wheel numpy h5py
57+
pip install -e .
58+
59+
- name: Linting with flake8
60+
run: |
61+
# stop the build if there are Python syntax errors or undefined names
62+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=docs
63+
64+
- name: Tests with ${{ matrix.os }} ${{ matrix.python-version }}
65+
id: tests
66+
run: |
67+
mkdir ${{ github.workspace }}/coverage
68+
pytest --cov=serializall
69+
mv .coverage ${{ github.workspace }}/coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }}
70+
71+
72+
# - name: Upload coverage artifact
73+
# uses: actions/upload-artifact@v4.6.2
74+
# with:
75+
# name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
76+
# path: ${{ github.workspace }}/coverage/coverage_${{ matrix.os }}_${{ matrix.python-version }}
77+
78+
- name: generate badge (success)
79+
if: ${{ success() }}
80+
uses: emibcn/badge-action@v2.0.3
81+
with:
82+
label: ''
83+
status: 'passing'
84+
color: 'green'
85+
path: '${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg'
86+
87+
- name: generate badge (fail)
88+
if: ${{ failure() }}
89+
uses: emibcn/badge-action@v2.0.3
90+
with:
91+
label: ''
92+
status: 'failing'
93+
color: 'red'
94+
path: '${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg'
95+
96+
97+
- name: Upload badge artifact
98+
if: ${{ always() }}
99+
uses: actions/upload-artifact@v4.6.2
100+
with:
101+
name: tests_${{runner.os}}_${{matrix.python-version}}
102+
path: '${{ github.workspace }}/${{ steps.extract_branch.outputs.branch }}/tests_${{runner.os}}_${{matrix.python-version}}.svg'
103+
if-no-files-found: error
104+
105+
106+
outputs:
107+
branch: ${{ steps.extract_branch.outputs.branch }}
108+
109+
badge-update:
110+
if: github.repository == 'PyMoDAQ/serializall' && !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) && startsWith(github.ref, 'refs/heads/')
111+
runs-on: ubuntu-latest
112+
needs: tests # Ensure this job runs after all matrix jobs complete
113+
steps:
114+
# switch to badges branches to commit
115+
- uses: actions/checkout@v5.0.0
116+
with:
117+
ref: badges
118+
119+
- name: Download badges
120+
uses: actions/download-artifact@v6.0.0
121+
122+
- name: Reorganize badges
123+
run: |
124+
rm -rf coverage* || true
125+
rm -rf $(git ls-files ${{ needs.tests.outputs.branch }}/*) || true
126+
git rm $(git ls-files ${{ needs.tests.outputs.branch }}/*) || true
127+
128+
mkdir -p '${{ needs.tests.outputs.branch }}'
129+
mv tests_*/*.svg '${{ needs.tests.outputs.branch }}'
130+
- name: Commit badges
131+
continue-on-error: true
132+
run: |
133+
git config --local user.email "action@github.com"
134+
git config --local user.name "GitHub Action"
135+
git add ${{ needs.tests.outputs.branch }}
136+
git commit --allow-empty -m "Add/Update badge"
137+
138+
- name: Push badges
139+
uses: ad-m/github-push-action@v1.0.0
140+
if: ${{ success() }}
141+
with:
142+
github_token: ${{ secrets.GITHUB_TOKEN }}
143+
branch: badges
144+
145+
# coverage-update:
146+
# runs-on: ubuntu-latest
147+
# needs: tests # Ensure this job runs after all matrix jobs complete
148+
149+
# steps:
150+
# - name: Checkout the repo
151+
# uses: actions/checkout@v5.0.0
152+
153+
# - name: Download all coverage artifacts
154+
# uses: actions/download-artifact@v5.0.0
155+
# with:
156+
# path: ./coverage-reports
157+
158+
# - name: Reorganize reports
159+
# run: |
160+
# cd coverage-reports
161+
# rm -rf tests_*
162+
# for folder in *; do
163+
# mv "${folder}"/* .;
164+
# done;
165+
# rmdir --ignore-fail-on-non-empty * || true
166+
# cd ..
167+
# - name: Combine coverage reports
168+
# run: |
169+
# python -m pip install coverage
170+
# coverage combine ./coverage-reports/coverage_*
171+
# coverage xml -i
172+
173+
# - name: Upload combined coverage report to Codecov
174+
# uses: codecov/codecov-action@v5.5.1
175+
# with:
176+
# token: ${{ secrets.CODECOV_TOKEN }}
177+
# files: coverage.xml

README.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,50 @@ serialization using builtins (see example).
1212

1313
It is currently used in projects such as PyMoDAQ and pyqtgraph.
1414

15+
16+
Compatibility
17+
+++++++++++++
18+
19+
+-------------+-------------+---------------+
20+
| | Linux | Windows |
21+
+=============+=============+===============+
22+
| Python 3.9 | |39-linux| | |39-windows| |
23+
+-------------+-------------+---------------+
24+
| Python 3.10 | |310-linux| | |310-windows| |
25+
+-------------+-------------+---------------+
26+
| Python 3.11 | |311-linux| | |311-windows| |
27+
+-------------+-------------+---------------+
28+
| Python 3.12 | |312-linux| | |312-windows| |
29+
+-------------+-------------+---------------+
30+
31+
32+
33+
34+
35+
.. |39-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.9.svg
36+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
37+
38+
.. |310-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.10.svg
39+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
40+
41+
.. |311-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.11.svg
42+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
43+
44+
.. |312-linux| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Linux_3.12.svg
45+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
46+
47+
.. |39-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.9.svg
48+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
49+
50+
.. |310-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.10.svg
51+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
52+
53+
.. |311-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.11.svg
54+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
55+
56+
.. |312-windows| image:: https://raw.githubusercontent.com/PyMoDAQ/serializall/main/tests_Windows_3.12.svg
57+
:target: https://github.com/PyMoDAQ/serializall/actions/workflows/tests.yml
58+
1559
Usage
1660
+++++
1761

0 commit comments

Comments
 (0)