Skip to content

Fix final markdownlint errors and add running pre-commit in CI #876

Fix final markdownlint errors and add running pre-commit in CI

Fix final markdownlint errors and add running pre-commit in CI #876

Workflow file for this run

# actions can be run locally using act and docker, on Fedora 37 also with podman, using:
# https://github.com/nektos/act
# sudo dnf install -y act-cli podman-docker
# act --bind --container-daemon-socket $XDG_RUNTIME_DIR/podman/podman.sock -W .github/workflows/main.yml
name: Unit tests
concurrency: # On new workflow, cancel old workflows from the same PR, branch or tag:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Checks can be skipped by adding "skip-checks: true" to a commit message,
# or requested by adding "request-checks: true" if disabled by default for pushes:
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks#skipping-and-requesting-checks-for-individual-commits
on: [push, pull_request]
permissions:
contents: read
pull-requests: write
env:
PYTHONWARNINGS: "ignore:DEPRECATION"
PIP_ROOT_USER_ACTION: "ignore" # For local testing using act-cli
PIP_NO_WARN_SCRIPT_LOCATION: "0" # For local testing using act-cli
PIP_DISABLE_PIP_VERSION_CHECK: "1" # Reduce noise in logs
jobs:
pre-commit:
env:
SKIP: pytest,pytype,tox,no-commit-to-branch
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: pre-commit/[email protected]
- uses: pre-commit-ci/[email protected]
if: always()
test:
strategy:
# See: https://github.com/xenserver/python-libs/pull/26#discussion_r1179482169
# max-parallel: 1
# Want to get the results of all the tests, don't terminate all on a fail:
fail-fast: false
matrix:
include:
- python-version: '3.11'
os: ubuntu-22.04
- python-version: '3.12'
os: ubuntu-22.04
- python-version: '3.13'
os: ubuntu-22.04
runs-on: ${{ matrix.os }}
env:
PYTHON_VERSION_USED_FOR_COVERAGE: ${{ '3.11' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed by diff-cover to get the changed lines: origin/master..HEAD
- name: Set up Python ${{ matrix.python-version }}
# Python 3.11 is not supported in the nektos/act container, so we skip this step
if: ${{ !(matrix.python-version == '3.11' && github.actor == 'nektos/act') }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install missing cpio in containers of nektos/act
if: ${{ (github.actor == 'nektos/act' && matrix.python-version != '3.11') }}
run: apt-get update && apt-get install -y cpio
- name: Run tox to run pytest in the defined tox environments
# Python 3.11 is not supported in the nektos/act container, so we skip this step
if: ${{ !(matrix.python-version == '3.11' && github.actor == 'nektos/act') }}
run: |
pip install tox tox-gh-actions
tox --workdir .github/workflows/.tox --recreate
env:
DIFF_COVERAGE_MIN: 0 # Let the reviewdog and codecov show uncovered lines
- uses: aki77/reviewdog-action-code-coverage@v2
continue-on-error: true
if: |
matrix.python-version == env.PYTHON_VERSION_USED_FOR_COVERAGE &&
!cancelled() && github.event_name == 'pull_request'
with:
lcov_path: coverage.lcov
- uses: codecov/codecov-action@v5
id: codecov
if: |
matrix.python-version == env.PYTHON_VERSION_USED_FOR_COVERAGE &&
!cancelled() && github.actor != 'nektos/act'
- uses: codecov/test-results-action@v1
if: steps.codecov.outcome == 'success'
- if: |
matrix.python-version == env.PYTHON_VERSION_USED_FOR_COVERAGE &&
!cancelled() && github.actor != 'nektos/act'
name: Upload coverage reports to Coveralls
env:
COVERALLS_FLAG_NAME: ${{ format('python{0}', steps.python.outputs.python-version ) }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pip install coveralls && coveralls --service=github
continue-on-error: true # Coveralls.io is currently overloaded
- name: Render docs if master was updated and the deploy_webhook_url is set
# See https://render.com/docs/deploy-hooks on how to deploy using a webhook:
env:
docs_deploy_branch: refs/heads/master
deploy_webhook_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
if: |
env.deploy_webhook_url && github.ref == env.docs_deploy_branch &&
matrix.python-version == env.PYTHON_VERSION_USED_FOR_COVERAGE
run: |
curl "$deploy_webhook_url"