Skip to content

Commit

Permalink
ci: Add coverage badge and update it on releases (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc authored and titom73 committed Jul 24, 2023
1 parent 4a4cdbd commit 7cfe463
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ on:
- published

jobs:
release-coverage:
name: Updated ANTA release coverage badge
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: pip install genbadge[coverage] tox tox-gh-actions
- name: "Run pytest via tox for ${{ matrix.python }}"
run: tox
- name: Generate coverage badge
run: genbadge coverage -i .coverage.xml -o badge/latest-release-coverage.svg
- name: Publish coverage badge to gh-pages branch
uses: JamesIves/github-pages-deploy-action@v4
with:
# branch: coverage-badge
folder: badge
release-doc:
name: "Publish documentation for release ${{github.ref_name}}"
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](https://github.com/arista-netdevops-community/anta/blob/main/LICENSE)
[![Linting and Testing Anta](https://github.com/arista-netdevops-community/anta/actions/workflows/code-testing.yml/badge.svg)](https://github.com/arista-netdevops-community/anta/actions/workflows/code-testing.yml)
[![github release](https://img.shields.io/github/release/arista-netdevops-community/anta.svg)](https://github.com/arista-netdevops-community/anta/releases/)
![coverage](https://github.com/arista-netdevops-community/anta/blob/gh-pages/latest-release-coverage.svg)

# Arista Network Test Automation (ANTA) Framework

Expand Down
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ ignore_errors = true
[tool.coverage.html]
directory = "coverage_html_report"

[tool.coverage.xml]
output = ".coverage.xml"

################################
# Tox
################################
Expand All @@ -228,8 +231,8 @@ envlist =
python =
3.8: py38
3.9: py39
3.10: erase, py310, report
3.11: py311
3.10: py310
3.11: erase, py311, report
[testenv]
description = Run pytest with {basepython}
Expand All @@ -242,8 +245,7 @@ description = Check the code style
commands =
black --check --diff --color .
isort --check --diff --color .
flake8 --max-line-length=165 --config=/dev/null anta
flake8 --max-line-length=165 --config=/dev/null tests
flake8 --max-line-length=165 --config=/dev/null anta tests
pylint anta
[testenv:type]
Expand All @@ -263,6 +265,7 @@ deps = coverage[toml]
commands =
coverage --version
coverage report --rcfile=pyproject.toml
coverage xml --rcfile=pyproject.toml
# add the following to make the report fail under some percentage
# commands = coverage report --fail-under=80
depends = py311
Expand Down

0 comments on commit 7cfe463

Please sign in to comment.