|
| 1 | +name: continuous-integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: |
| 7 | + - "v[0-9]+.[0-9]+.[0-9]+*" |
| 8 | + pull_request: |
| 9 | + |
| 10 | +jobs: |
| 11 | + |
| 12 | + pytest: |
| 13 | + |
| 14 | + name: Unit tests (python=${{matrix.python}}, sphinx${{matrix.sphinx}}) |
| 15 | + |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + python: ["3.8", "3.11"] |
| 22 | + sphinx: ["", "~=7.0", "~=6.0", "~=5.0"] |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v4 |
| 28 | + with: |
| 29 | + python-version: ${{matrix.python}} |
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + python -m pip install --upgrade pip |
| 33 | + pip install sphinx${{matrix.sphinx}} -e ".[testing]" |
| 34 | + - name: Run sphinx-build |
| 35 | + run: pytest --cov=src --cov-report=xml --cov-report=term-missing |
| 36 | + |
| 37 | + docs-html: |
| 38 | + |
| 39 | + name: Build docs (sphinx${{matrix.sphinx}}) |
| 40 | + |
| 41 | + runs-on: ubuntu-latest |
| 42 | + |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + sphinx: ["", "~=7.0", "~=5.0"] |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@v4 |
| 52 | + with: |
| 53 | + python-version: 3.8 |
| 54 | + - name: Install dependencies |
| 55 | + run: | |
| 56 | + python -m pip install --upgrade pip |
| 57 | + pip install sphinx${{matrix.sphinx}} -e ".[docs]" |
| 58 | + - name: Run sphinx-build |
| 59 | + run: sphinx-build -nW --keep-going -b html docs/ docs/_build/html |
| 60 | + |
| 61 | + check: |
| 62 | + # https://github.com/marketplace/actions/alls-green#why |
| 63 | + # This job does nothing and is only used for the branch protection |
| 64 | + |
| 65 | + if: always() |
| 66 | + |
| 67 | + needs: |
| 68 | + - pytest |
| 69 | + - docs-html |
| 70 | + |
| 71 | + runs-on: ubuntu-latest |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Decide whether the needed jobs succeeded or failed |
| 75 | + uses: re-actors/alls-green@release/v1 |
| 76 | + with: |
| 77 | + jobs: ${{ toJSON(needs) }} |
| 78 | + |
| 79 | + |
| 80 | + publish: |
| 81 | + |
| 82 | + name: Publish to PyPI |
| 83 | + needs: |
| 84 | + - check |
| 85 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 86 | + runs-on: ubuntu-latest |
| 87 | + steps: |
| 88 | + - name: Checkout source |
| 89 | + uses: actions/checkout@v4 |
| 90 | + - name: Set up Python 3.8 |
| 91 | + uses: actions/setup-python@v4 |
| 92 | + with: |
| 93 | + python-version: "3.8" |
| 94 | + - name: install flit |
| 95 | + run: | |
| 96 | + pip install flit~=3.4 |
| 97 | + - name: Build and publish |
| 98 | + run: | |
| 99 | + flit publish |
| 100 | + env: |
| 101 | + FLIT_USERNAME: __token__ |
| 102 | + FLIT_PASSWORD: ${{ secrets.PYPI_KEY }} |
0 commit comments