Skip to content

Commit 9e564c6

Browse files
committed
ci: rename workflow, replace genbadge with anybadge, fix badge steps on failure
1 parent bcf092c commit 9e564c6

3 files changed

Lines changed: 18 additions & 220 deletions

File tree

.github/workflows/run-tests-and-linter.yml renamed to .github/workflows/ci.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,28 @@ jobs:
1919
run: uv run pytest --ignore=test/availability
2020

2121
- name: Generate badges
22+
if: always()
2223
run: |
23-
uv run genbadge tests -i junit.xml -o pytest.svg
24-
uv run genbadge coverage -i coverage.xml -o coverage.svg
24+
PASSED=$(python -c "import xml.etree.ElementTree as ET; r=ET.parse('junit.xml').getroot(); ts=r.findall('testsuite'); print(sum(int(t.get('tests',0))-int(t.get('failures',0))-int(t.get('errors',0)) for t in ts))")
25+
FAILED=$(python -c "import xml.etree.ElementTree as ET; r=ET.parse('junit.xml').getroot(); ts=r.findall('testsuite'); print(sum(int(t.get('failures',0))+int(t.get('errors',0)) for t in ts))")
26+
if [ "$FAILED" -eq 0 ]; then
27+
uv run anybadge --label=pytest --value="${PASSED} passed" --color=green --file=pytest.svg
28+
else
29+
uv run anybadge --label=pytest --value="${PASSED} passed, ${FAILED} failed" --color=red --file=pytest.svg
30+
fi
31+
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; t=ET.parse('coverage.xml').getroot(); print(round(float(t.get('line-rate',0))*100))")
32+
uv run anybadge --value=$COVERAGE --file=coverage.svg coverage
2533
2634
- name: Upload pytest badge
35+
if: always()
2736
uses: actions/upload-artifact@v4
2837
with:
2938
name: pytest
3039
path: pytest.svg
3140
overwrite: true
3241

3342
- name: Upload coverage badge
43+
if: always()
3444
uses: actions/upload-artifact@v4
3545
with:
3646
name: coverage
@@ -71,9 +81,10 @@ jobs:
7181
run: uv sync --dev --frozen
7282

7383
- name: Lint with ruff
74-
run: uv run ruff check --exit-zero --output-format=concise > ruff.txt
84+
run: uv run ruff check --output-format=concise > ruff.txt
7585

7686
- name: Generate badge
87+
if: always()
7788
run: |
7889
VIOLATIONS=$(tail -1 ruff.txt | grep -oP '\d+')
7990
if [ "$VIOLATIONS" -eq 0 ]; then
@@ -83,6 +94,7 @@ jobs:
8394
fi
8495
8596
- name: Upload ruff badge
97+
if: always()
8698
uses: actions/upload-artifact@v4
8799
with:
88100
name: ruff
@@ -98,7 +110,7 @@ jobs:
98110
contents: read
99111
steps:
100112
- name: Checkout
101-
uses: actions/checkout@v4
113+
uses: actions/checkout@v5
102114

103115
- name: Resolve build metadata
104116
id: meta

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "bughog"
33
version = "0.1.0"
4-
requires-python = "==3.13"
4+
requires-python = "==3.13.*"
55
dependencies = [
66
"docker==7.1.0",
77
"flask==3.1.3",
@@ -25,7 +25,6 @@ dev = [
2525
"anybadge==1.16.0",
2626
"coverage[toml]==7.13.4",
2727
"debugpy==1.8.20",
28-
"genbadge[coverage,tests]==1.1.2",
2928
"pylint==4.0.5",
3029
"pytest==9.0.2",
3130
"pytest-cov==7.0.0",

0 commit comments

Comments
 (0)