Skip to content

Commit 8031392

Browse files
committed
tests with badges showing in README
1 parent 76b4367 commit 8031392

File tree

3 files changed

+219
-118
lines changed

3 files changed

+219
-118
lines changed

.github/workflows/tests-utils.yml

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

.github/workflows/tests.yml

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