Ignore certain lines in coverage analysis #1385
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: Continuous Integration | |
on: | |
push: | |
release: | |
types: [published] | |
jobs: | |
# Run linters and unit tests on all supported Python versions. | |
checks: | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies with apt | |
run: | | |
sudo apt-get install nginx-core openssl | |
- name: Install dependencies with pip | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run black | |
run: | | |
black --check aiotus tests | |
- name: Run flake8 | |
run: | | |
flake8 aiotus tests | |
- name: Run isort | |
run: | | |
isort aiotus tests | |
- name: Run mypy | |
run: | | |
mypy --strict aiotus | |
mypy tests | |
- name: Run bandit | |
run: | | |
bandit --recursive aiotus | |
- name: Download tusd | |
run: | | |
make tusd | |
- name: Create test certificates | |
run: | | |
make tests/nginx.key tests/selfsigned.crt | |
- name: Run pytest (1st try) | |
id: pytest1 | |
run: | | |
PYTHONPATH=. pytest --cov=aiotus --cov-report=xml:coverage/coverage-${{ matrix.python-version }}.xml tests | |
continue-on-error: true | |
- name: Run pytest (2nd try) | |
id: pytest2 | |
if: steps.pytest1.outcome == 'failure' | |
run: | | |
PYTHONPATH=. pytest --cov=aiotus --cov-report=xml:coverage/coverage-${{ matrix.python-version }}.xml tests | |
continue-on-error: true | |
- name: Run pytest (3rd try) | |
if: steps.pytest2.outcome == 'failure' | |
run: | | |
PYTHONPATH=. pytest --cov=aiotus --cov-report=xml:coverage/coverage-${{ matrix.python-version }}.xml tests | |
- name: Upload coverage information artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ matrix.python-version }} | |
path: coverage/coverage-*.xml | |
- name: Generate documentation | |
if: matrix.python-version > '3.9' | |
run: | | |
make -C docs html | |
# Upload coverage information to external services. A separate job is used because | |
# SonarCloud does not like to be triggered multiple times for the same commit. | |
upload-coverage: | |
needs: checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Get the complete history so that SonarCloud can figure out what has | |
# changed on a feature branch compared to the main branch. | |
fetch-depth: 0 | |
- name: Download coverage information artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-* | |
path: coverage/ | |
merge-multiple: true | |
- name: Run SonarCloud scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Upload coverage information to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
directory: coverage/ | |
token: ${{ secrets.CODECOV_TOKEN }} | |
# Package the code on the lowest supported Python version. | |
package: | |
needs: checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Get the complete history so that setuptools-scm works properly. | |
fetch-depth: 0 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Package | |
run: | | |
python -m build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: dist/ | |
# Publish packages built from the master branch to TestPyPi. | |
publish-testpypi: | |
if: (github.ref == 'refs/heads/master') || (github.event_name == 'release' && github.event.action == 'released') | |
needs: package | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/project/aiotus | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
path: dist/ | |
- name: Publish to TestPyPi | |
uses: pypa/gh-action-pypi-publish@release/v1.10 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
# Publish releases to PyPi. | |
publish-pypi: | |
if: github.event_name == 'release' && github.event.action == 'released' | |
needs: package | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/project/aiotus | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
path: dist/ | |
- name: Publish to PyPi | |
uses: pypa/gh-action-pypi-publish@release/v1.10 |