| 1 |
name: continuous-integration |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: [main] |
| 6 |
tags: |
| 7 |
- 'v*' |
| 8 |
pull_request: |
| 9 |
|
| 10 |
jobs: |
| 11 |
|
| 12 |
pre-commit: |
| 13 |
|
| 14 |
runs-on: ubuntu-latest |
| 15 |
|
| 16 |
steps: |
| 17 |
- uses: actions/checkout@v4 |
| 18 |
- name: Set up Python |
| 19 |
uses: actions/setup-python@v5 |
| 20 |
with: |
| 21 |
python-version: "3.11" |
| 22 |
- uses: pre-commit/[email protected] |
| 23 |
|
| 24 |
tests: |
| 25 |
|
| 26 |
strategy: |
| 27 |
fail-fast: false |
| 28 |
matrix: |
| 29 |
os: [ubuntu-latest] |
| 30 |
python-version: ["3.11", "3.12", "3.13", "3.14"] |
| 31 |
sphinx-version: ["~=7.0", "~=8.0", "~=9.0"] |
| 32 |
extras: ["testing"] |
| 33 |
include: |
| 34 |
- os: windows-latest |
| 35 |
python-version: "3.11" |
| 36 |
sphinx-version: "~=7.0" |
| 37 |
extras: "testing" |
| 38 |
- os: windows-latest |
| 39 |
python-version: "3.13" |
| 40 |
sphinx-version: "~=8.0" |
| 41 |
extras: "testing" |
| 42 |
- os: windows-latest |
| 43 |
python-version: "3.14" |
| 44 |
sphinx-version: "~=9.0" |
| 45 |
extras: "testing" |
| 46 |
|
| 47 |
runs-on: ${{ matrix.os }} |
| 48 |
|
| 49 |
name: Tests (py${{ matrix.python-version }}, Sphinx${{ matrix.sphinx-version }}, on ${{ matrix.os }}) |
| 50 |
|
| 51 |
steps: |
| 52 |
- uses: actions/checkout@v4 |
| 53 |
- name: Set up Python ${{ matrix.python-version }} |
| 54 |
uses: actions/setup-python@v5 |
| 55 |
with: |
| 56 |
python-version: ${{ matrix.python-version }} |
| 57 |
cache: pip |
| 58 |
- name: Install dependencies |
| 59 |
run: | |
| 60 |
python -m pip install --upgrade pip |
| 61 |
pip install --upgrade "sphinx${{ matrix.sphinx-version }}" -e .[${{ matrix.extras}}] |
| 62 |
- name: Run pytest |
| 63 |
run: | |
| 64 |
pytest --cov=sphinx_design --cov-report=xml --cov-report=term-missing |
| 65 |
- name: Upload to Codecov |
| 66 |
if: github.event.pull_request.head.repo.full_name == github.repository && matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest' |
| 67 |
uses: codecov/codecov-action@v3 |
| 68 |
with: |
| 69 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 70 |
name: pytests |
| 71 |
flags: pytests |
| 72 |
file: ./coverage.xml |
| 73 |
fail_ci_if_error: true |
| 74 |
|
| 75 |
docs-build-format: |
| 76 |
|
| 77 |
runs-on: ubuntu-latest |
| 78 |
strategy: |
| 79 |
matrix: |
| 80 |
format: [html, latex, man] |
| 81 |
|
| 82 |
steps: |
| 83 |
- uses: actions/checkout@v4 |
| 84 |
- name: Set up Python |
| 85 |
uses: actions/setup-python@v5 |
| 86 |
with: |
| 87 |
python-version: "3.11" |
| 88 |
cache: pip |
| 89 |
- name: Install dependencies |
| 90 |
run: | |
| 91 |
python -m pip install --upgrade pip |
| 92 |
pip install -e .[rtd] |
| 93 |
- name: Build documentation |
| 94 |
run: sphinx-build -nW --keep-going -b ${{ matrix.format }} docs/ docs/_build/${{ matrix.format }} |
| 95 |
|
| 96 |
# https://github.com/marketplace/actions/alls-green#why |
| 97 |
check: # This job does nothing and is only used for the branch protection |
| 98 |
|
| 99 |
if: always() |
| 100 |
|
| 101 |
needs: |
| 102 |
- pre-commit |
| 103 |
- tests |
| 104 |
- docs-build-format |
| 105 |
|
| 106 |
runs-on: ubuntu-latest |
| 107 |
|
| 108 |
steps: |
| 109 |
- name: Decide whether the needed jobs succeeded or failed |
| 110 |
uses: re-actors/alls-green@release/v1 |
| 111 |
with: |
| 112 |
jobs: ${{ toJSON(needs) }} |
| 113 |
|
| 114 |
publish: |
| 115 |
|
| 116 |
name: Publish to PyPi |
| 117 |
needs: [pre-commit, tests] |
| 118 |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 119 |
runs-on: ubuntu-latest |
| 120 |
steps: |
| 121 |
- name: Checkout source |
| 122 |
uses: actions/checkout@v4 |
| 123 |
- name: Set up Python |
| 124 |
uses: actions/setup-python@v5 |
| 125 |
with: |
| 126 |
python-version: "3.11" |
| 127 |
- name: install flit |
| 128 |
run: | |
| 129 |
pip install flit~=3.4 |
| 130 |
- name: Build and publish |
| 131 |
run: | |
| 132 |
flit publish |
| 133 |
env: |
| 134 |
FLIT_USERNAME: __token__ |
| 135 |
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }} |