| 1 |
--- |
| 2 |
name: Tests |
| 3 |
|
| 4 |
on: |
| 5 |
push: |
| 6 |
branches: |
| 7 |
- main |
| 8 |
pull_request: |
| 9 |
|
| 10 |
jobs: |
| 11 |
tests: |
| 12 |
runs-on: ubuntu-latest |
| 13 |
strategy: |
| 14 |
fail-fast: false |
| 15 |
matrix: |
| 16 |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
| 17 |
|
| 18 |
steps: |
| 19 |
- uses: actions/checkout@v4 |
| 20 |
- name: Set up Python ${{ matrix.python-version }} |
| 21 |
uses: actions/setup-python@v5 |
| 22 |
with: |
| 23 |
python-version: ${{ matrix.python-version }} |
| 24 |
- name: Ensure latest setuptools |
| 25 |
run: | |
| 26 |
python -m pip install --upgrade pip setuptools |
| 27 |
- name: Install dependencies |
| 28 |
run: | |
| 29 |
python -m pip install coverage[toml] tox tox-py unittest-xml-reporting |
| 30 |
- name: Run tox |
| 31 |
run: | |
| 32 |
python -m pip --version |
| 33 |
python -m tox --version |
| 34 |
python -m tox --py current |
| 35 |
- name: Coverage reporting |
| 36 |
run: | |
| 37 |
coverage combine |
| 38 |
coverage report --show-missing |
| 39 |
mv .coverage .coverage.${{ matrix.python-version }} |
| 40 |
- name: Store coverage file |
| 41 |
uses: actions/upload-artifact@v4 |
| 42 |
with: |
| 43 |
include-hidden-files: true |
| 44 |
name: coverage-${{ matrix.python-version }} |
| 45 |
path: .coverage.${{ matrix.python-version }} |
| 46 |
|
| 47 |
coverage: |
| 48 |
name: Coverage |
| 49 |
runs-on: ubuntu-latest |
| 50 |
needs: tests |
| 51 |
permissions: |
| 52 |
# If the author is a maintainer, the permission level is set by the |
| 53 |
# values below. |
| 54 |
# `pull-requests: write` is needed for publishing new comments in pull |
| 55 |
# requests. |
| 56 |
# `contents: write` is needed for pushing data to the |
| 57 |
# `python-coverage-comment-action` branch, and for editing existing |
| 58 |
# comments (to avoid publishing multiple comments in the same PR) |
| 59 |
# In case the pull request comes from a forked repository, the maximum |
| 60 |
# permission level is read, so the permissions below won't be acted upon |
| 61 |
# by GitHub. |
| 62 |
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token |
| 63 |
pull-requests: write |
| 64 |
contents: write |
| 65 |
steps: |
| 66 |
- uses: actions/checkout@v4 |
| 67 |
|
| 68 |
- uses: actions/download-artifact@v4 |
| 69 |
id: download |
| 70 |
with: |
| 71 |
pattern: coverage-* |
| 72 |
merge-multiple: true |
| 73 |
|
| 74 |
- name: Coverage comment |
| 75 |
id: coverage_comment |
| 76 |
uses: py-cov-action/python-coverage-comment-action@v3 |
| 77 |
with: |
| 78 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 |
MERGE_COVERAGE_FILES: true |
| 80 |
|
| 81 |
- name: Store Pull Request comment to be posted |
| 82 |
uses: actions/upload-artifact@v4 |
| 83 |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' |
| 84 |
with: |
| 85 |
name: python-coverage-comment-action |
| 86 |
path: python-coverage-comment-action.txt |
| 87 |
|
| 88 |
isort: |
| 89 |
runs-on: ubuntu-latest |
| 90 |
steps: |
| 91 |
- uses: actions/checkout@v4 |
| 92 |
- name: Set up Python |
| 93 |
uses: actions/setup-python@v5 |
| 94 |
with: |
| 95 |
python-version: "3.13" |
| 96 |
- name: Ensure latest setuptools |
| 97 |
run: | |
| 98 |
python -m pip install --upgrade pip setuptools |
| 99 |
- name: Install dependencies |
| 100 |
run: | |
| 101 |
python -m pip install tox |
| 102 |
- name: Run tox |
| 103 |
run: | |
| 104 |
python -m pip --version |
| 105 |
python -m tox --version |
| 106 |
python -m tox -e isort,lint,docs |
| 107 |
|
| 108 |
|
| 109 |
warnings: |
| 110 |
runs-on: ubuntu-latest |
| 111 |
steps: |
| 112 |
- uses: actions/checkout@v4 |
| 113 |
- name: Set up Python |
| 114 |
uses: actions/setup-python@v5 |
| 115 |
with: |
| 116 |
python-version: "3.13" |
| 117 |
- name: Ensure latest setuptools |
| 118 |
run: | |
| 119 |
python -m pip install --upgrade pip setuptools |
| 120 |
- name: Install dependencies |
| 121 |
run: | |
| 122 |
python -m pip install tox |
| 123 |
- name: Run tox |
| 124 |
run: | |
| 125 |
python -m pip --version |
| 126 |
python -m tox --version |
| 127 |
python -m tox -e warnings |