Skip to content

Commit 9dec96f

Browse files
authored
Separate tests and coverage workflows
Created separate `tests` and `covbadge` workflows due to an unforeseen `upload-artifact` action behaviour (no files matching the specified pattern are found) causing the entire tests job to fail even though tests are passing
1 parent b606531 commit 9dec96f

File tree

5 files changed

+97
-56
lines changed

5 files changed

+97
-56
lines changed

.github/workflows/covbadge.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: covbadge
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
paths:
7+
- .github/workflows/covbadge.yaml
8+
- src/**
9+
- test/**
10+
- tox.ini
11+
12+
jobs:
13+
run_coverage:
14+
name: Run project tests with coverage
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.12"
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install tox tox-gh-actions
29+
30+
- name: Run tox for ${{ matrix.python-version }}
31+
run: |
32+
python -m tox
33+
34+
- name: Upload coverage data
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: covdata-312
38+
path: ./.coverage*
39+
if-no-files-found: error
40+
41+
coverage:
42+
name: Generate coverage status badge
43+
needs: run_coverage
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Check out the repo
47+
uses: actions/checkout@v4
48+
49+
- name: Set up Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: 3.12
53+
54+
- name: Install dependencies
55+
run: |
56+
python -m pip install tox tox-gh-actions
57+
58+
- name: Download coverage data
59+
uses: actions/download-artifact@v4
60+
with:
61+
pattern: covdata-312
62+
63+
- name: Combine coverage data
64+
run: |
65+
python -m tox -e coverage
66+
export TOTAL_COV=$(python -c "import json; print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
67+
echo total_cov=$TOTAL_COV >> $GITHUB_ENV
68+
echo ### Total coverage: ${TOTAL_COV}% >> $GITHUB_STEP_SUMMARY
69+
70+
- name: Generate coverage badge
71+
uses: schneegans/dynamic-badges-action@v1.7.0
72+
with:
73+
auth: ${{ secrets.GIST_TOKEN }}
74+
gistID: f6cec4c4c8e1733cfe45f807918a128a
75+
filename: covbadge.json
76+
label: coverage
77+
message: ${{ env.total_cov }}%
78+
minColorRange: 50
79+
maxColorRange: 90
80+
valColorRange: ${{ env.total_cov }}

.github/workflows/examples.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ jobs:
2727
python-version: ${{ matrix.python-version }}
2828

2929
- name: Install dependencies
30-
run: python -m pip install build
30+
run: |
31+
python -m pip install build
3132
3233
- name: Build the library for ${{ matrix.python-version }}
33-
run: python -m build
34+
run: |
35+
python -m build
3436
3537
- name: Install library
36-
run: python -m pip install dist/pyconstclasses-*-py3-none-any.whl --force-reinstall
38+
run: |
39+
python -m pip install dist/pyconstclasses-*-py3-none-any.whl --force-reinstall
3740
3841
- name: Run the example programs
3942
run: |

.github/workflows/format.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ jobs:
2525
python-version: "3.12"
2626

2727
- name: Install dependencies
28-
run: python -m pip install black isort
28+
run: |
29+
python -m pip install black isort
2930
3031
- name: Run format check
31-
run: python -m black . --check
32+
run: |
33+
python -m black . --check
3234
3335
- name: Run import check
34-
run: python -m isort . --check
36+
run: |
37+
python -m isort . --check

.github/workflows/tests.yaml

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,54 +28,9 @@ jobs:
2828
python-version: ${{ matrix.python-version }}
2929

3030
- name: Install dependencies
31-
run: python -m pip install tox tox-gh-actions
32-
33-
- name: Run tox for ${{ matrix.python-version }}
34-
run: python -m tox
35-
36-
- name: Upload coverage data
37-
uses: actions/upload-artifact@v4
38-
with:
39-
name: covdata-${{ matrix.python-version }}
40-
path: .coverage.*
41-
42-
coverage:
43-
name: Generate coverage status badge
44-
needs: run_tests
45-
runs-on: ubuntu-latest
46-
steps:
47-
- name: Check out the repo
48-
uses: actions/checkout@v4
49-
50-
- name: Set up Python
51-
uses: actions/setup-python@v5
52-
with:
53-
python-version: 3.12
54-
55-
- name: Install dependencies
56-
run: python -m pip install tox tox-gh-actions
57-
58-
- name: Download coverage data
59-
uses: actions/download-artifact@v4
60-
with:
61-
pattern: covdata-*
62-
merge-multiple: true
63-
64-
- name: Combine coverage data
6531
run: |
66-
python -m tox -e coverage
67-
export TOTAL_COV=$(python -c "import json; print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
68-
echo total_cov=$TOTAL_COV >> $GITHUB_ENV
69-
echo ### Total coverage: ${TOTAL_COV}% >> $GITHUB_STEP_SUMMARY
32+
python -m pip install tox
7033
71-
- name: Generate coverage badge
72-
uses: schneegans/dynamic-badges-action@v1.7.0
73-
with:
74-
auth: ${{ secrets.GIST_TOKEN }}
75-
gistID: f6cec4c4c8e1733cfe45f807918a128a
76-
filename: covbadge.json
77-
label: coverage
78-
message: ${{ env.total_cov }}%
79-
minColorRange: 50
80-
maxColorRange: 90
81-
valColorRange: ${{ env.total_cov }}
34+
- name: Run tests for ${{ matrix.python-version }}
35+
run: |
36+
python -m tox

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55

66
[project]
77
name = "pyconstclasses"
8-
version = "1.0.4"
8+
version = "1.0.5"
99
description = "Package with const class decoratos and utility"
1010
authors = [
1111
{name = "SpectraL519"}

0 commit comments

Comments
 (0)