| 1 |
name: Unit tests and release |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: [ master ] |
| 6 |
tags: |
| 7 |
- '*' |
| 8 |
pull_request: |
| 9 |
branches: [ master ] |
| 10 |
|
| 11 |
|
| 12 |
permissions: |
| 13 |
contents: read |
| 14 |
|
| 15 |
|
| 16 |
jobs: |
| 17 |
unit_tests: |
| 18 |
runs-on: ${{ matrix.os }} |
| 19 |
|
| 20 |
strategy: |
| 21 |
matrix: |
| 22 |
python-version: ['pypy-3.9', 'pypy-3.10', 'pypy-3.11', |
| 23 |
'3.9', '3.10', '3.11', '3.12', '3.13'] |
| 24 |
os: [ubuntu-latest, windows-latest, macos-latest] |
| 25 |
include: |
| 26 |
- python-version: "3.14-dev" |
| 27 |
os: "ubuntu-latest" |
| 28 |
- python-version: "3.14-dev" |
| 29 |
os: "macos-latest" |
| 30 |
|
| 31 |
steps: |
| 32 |
- uses: actions/checkout@v4 |
| 33 |
|
| 34 |
- name: Set up Python |
| 35 |
uses: actions/setup-python@v5 |
| 36 |
with: |
| 37 |
python-version: ${{ matrix.python-version }} |
| 38 |
|
| 39 |
- name: Install tox |
| 40 |
run: | |
| 41 |
python -m pip install --upgrade pip tox |
| 42 |
|
| 43 |
- name: Log system information |
| 44 |
run: | |
| 45 |
test -r /etc/os-release && sh -c '. /etc/os-release && echo "OS: $PRETTY_NAME"' |
| 46 |
python --version |
| 47 |
python -c "print('\nENVIRONMENT VARIABLES\n=====================\n')" |
| 48 |
python -c "import os; [print(f'{k}={v}') for k, v in os.environ.items()]" |
| 49 |
|
| 50 |
- name: Run unit tests and coverage reports |
| 51 |
run: | |
| 52 |
tox -e test-cov |
| 53 |
|
| 54 |
- name: Run unit tests with latest Twisted version |
| 55 |
run: | |
| 56 |
tox -e test-latest-twisted |
| 57 |
|
| 58 |
- name: Publish code coverage |
| 59 |
uses: codecov/codecov-action@v4 |
| 60 |
with: |
| 61 |
fail_ci_if_error: true |
| 62 |
files: ./coverage.xml |
| 63 |
name: unit-${{ matrix.os }}-${{matrix.python-version}} |
| 64 |
# Check the secret defined in GHA here |
| 65 |
# https://github.com/twisted/pydoctor/settings/secrets/actions |
| 66 |
# And get it from Codecov.io here |
| 67 |
# https://app.codecov.io/gh/twisted/pydoctor/settings |
| 68 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 69 |
verbose: true |
| 70 |
|
| 71 |
release: |
| 72 |
|
| 73 |
needs: [unit_tests] |
| 74 |
runs-on: ubuntu-latest |
| 75 |
|
| 76 |
permissions: |
| 77 |
contents: read |
| 78 |
# The `id-token` permission is mandatory for trusted publishing |
| 79 |
# See https://github.com/pypa/gh-action-pypi-publish |
| 80 |
id-token: write |
| 81 |
|
| 82 |
steps: |
| 83 |
- uses: actions/checkout@v4 |
| 84 |
|
| 85 |
- name: Set up Python |
| 86 |
uses: actions/setup-python@v5 |
| 87 |
with: |
| 88 |
python-version: 3.12 |
| 89 |
|
| 90 |
- name: Log system information |
| 91 |
run: | |
| 92 |
test -r /etc/os-release && sh -c '. /etc/os-release && echo "OS: $PRETTY_NAME"' |
| 93 |
python --version |
| 94 |
python -c "print('\nENVIRONMENT VARIABLES\n=====================\n')" |
| 95 |
python -c "import os; [print(f'{k}={v}') for k, v in os.environ.items()]" |
| 96 |
|
| 97 |
- name: Install deps |
| 98 |
run: | |
| 99 |
python -m pip install --upgrade pip setuptools wheel |
| 100 |
|
| 101 |
- name: Build pydoctor |
| 102 |
run: | |
| 103 |
python setup.py --quiet build check sdist bdist_wheel |
| 104 |
ls -alh ./dist/ |
| 105 |
|
| 106 |
- name: Publish to PyPI - on tag |
| 107 |
if: startsWith(github.ref, 'refs/tags/') |
| 108 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 109 |
|
| 110 |
# This is a meta-job to simplify PR CI enforcement configuration in GitHub. |
| 111 |
# Inside the GitHub config UI you only configure this job as required. |
| 112 |
# All the extra requirements are defined "as code" as part of the `needs` |
| 113 |
# list for this job. |
| 114 |
gha-required: |
| 115 |
name: GHA Required |
| 116 |
runs-on: ubuntu-latest |
| 117 |
# The `if` condition is very important. |
| 118 |
# If not set, the job will be skipped on failing dependencies. |
| 119 |
if: ${{ !cancelled() }} |
| 120 |
needs: |
| 121 |
# This is the list of CI job that we are interested to pass before |
| 122 |
# a merge. |
| 123 |
# pypi-publish is skipped since this is only executed for a tag. |
| 124 |
- unit_tests |
| 125 |
steps: |
| 126 |
- name: Require all successes |
| 127 |
uses: re-actors/alls-green@3a2de129f0713010a71314c74e33c0e3ef90e696 |
| 128 |
with: |
| 129 |
jobs: ${{ toJSON(needs) }} |