Fix/dashboard #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Coverage | |
on: | |
push: | |
branches: | |
- '*' | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[test] | |
- name: Run tests with coverage | |
run: | | |
coverage run -m pytest | |
coverage xml | |
coverage report > coverage_report.txt | |
- name: Generate coverage badge | |
run: | | |
COVERAGE=$(grep "TOTAL" coverage_report.txt | awk '{print $NF}' | sed 's/%//') | |
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV | |
mkdir -p .github/badges | |
echo "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100\" height=\"20\"> | |
<linearGradient id=\"b\" x2=\"0\" y2=\"100%\"> | |
<stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"/> | |
<stop offset=\"1\" stop-opacity=\".1\"/> | |
</linearGradient> | |
<mask id=\"a\"> | |
<rect width=\"100\" height=\"20\" rx=\"3\" fill=\"#fff\"/> | |
</mask> | |
<g mask=\"url(#a)\"> | |
<path fill=\"#555\" d=\"M0 0h63v20H0z\"/> | |
<path fill=\"#4c1\" d=\"M63 0h37v20H63z\"/> | |
<path fill=\"url(#b)\" d=\"M0 0h100v20H0z\"/> | |
</g> | |
<g fill=\"#fff\" text-anchor=\"middle\" font-family=\"DejaVu Sans,Verdana,Geneva,sans-serif\" font-size=\"11\"> | |
<text x=\"31.5\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">coverage</text> | |
<text x=\"31.5\" y=\"14\">coverage</text> | |
<text x=\"80.5\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">$COVERAGE%</text> | |
<text x=\"80.5\" y=\"14\">$COVERAGE%</text> | |
</g> | |
</svg>" > .github/badges/coverage.svg | |
- name: Upload coverage badge | |
uses: actions/upload-artifact@v2 | |
with: | |
name: coverage-badge | |
path: .github/badges/coverage.svg |