Skip to content

Commit d06355c

Browse files
Badge upload only once
1 parent c0f7ddb commit d06355c

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

.github/workflows/ci-tests.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,39 @@ jobs:
7979
else
8080
echo "color=critical" >> $GITHUB_OUTPUT
8181
fi
82-
82+
83+
- name: Upload coverage artifact
84+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: coverage-data
88+
path: |
89+
coverage_quick.xml
90+
retention-days: 1
91+
92+
update-badge:
93+
needs: tests-with-vcr
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: Download coverage artifact
97+
uses: actions/download-artifact@v3
98+
with:
99+
name: coverage-data
100+
101+
- name: Extract coverage
102+
id: get_coverage
103+
run: |
104+
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; print(round(float(ET.parse('coverage_quick.xml').getroot().attrib['line-rate'])*100))")
105+
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
106+
# Determine badge color based on coverage percentage
107+
if [ $COVERAGE -ge 80 ]; then
108+
echo "color=success" >> $GITHUB_OUTPUT
109+
elif [ $COVERAGE -ge 60 ]; then
110+
echo "color=yellow" >> $GITHUB_OUTPUT
111+
else
112+
echo "color=critical" >> $GITHUB_OUTPUT
113+
fi
114+
83115
- name: Update coverage badge
84116
uses: schneegans/dynamic-badges-action@v1.7.0
85117
with:

0 commit comments

Comments
 (0)