|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - '[0-9].[0-9]+' # matches to backport branches, e.g. 3.6 |
| 8 | + tags: [ 'v*' ] |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + - '[0-9].[0-9]+' |
| 13 | + |
| 14 | + |
| 15 | +jobs: |
| 16 | + lint: |
| 17 | + name: Linter |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 5 |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + - name: Setup Python |
| 24 | + uses: actions/setup-python@v5 |
| 25 | + with: |
| 26 | + python-version: 3.11 |
| 27 | + cache: 'pip' |
| 28 | + cache-dependency-path: '**/requirements*.txt' |
| 29 | + - name: Pre-Commit hooks |
| 30 | + uses: pre-commit/[email protected] |
| 31 | + - name: Install dependencies |
| 32 | + uses: py-actions/py-dependency-install@v4 |
| 33 | + with: |
| 34 | + path: requirements-dev.txt |
| 35 | + - name: Install itself |
| 36 | + run: | |
| 37 | + pip install . |
| 38 | + - name: Run linter |
| 39 | + run: | |
| 40 | + make lint |
| 41 | + - name: Prepare twine checker |
| 42 | + run: | |
| 43 | + pip install -U build twine wheel |
| 44 | + python -m build |
| 45 | + - name: Run twine checker |
| 46 | + run: | |
| 47 | + twine check dist/* |
| 48 | +
|
| 49 | + test: |
| 50 | + name: Test |
| 51 | + strategy: |
| 52 | + matrix: |
| 53 | + pyver: ['3.9', '3.10', '3.11', '3.12', '3.13'] |
| 54 | + runs-on: ubuntu-latest |
| 55 | + timeout-minutes: 15 |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + - name: Setup Python ${{ matrix.pyver }} |
| 60 | + uses: actions/setup-python@v5 |
| 61 | + with: |
| 62 | + python-version: ${{ matrix.pyver }} |
| 63 | + cache: 'pip' |
| 64 | + cache-dependency-path: '**/requirements*.txt' |
| 65 | + - name: Install dependencies |
| 66 | + uses: py-actions/py-dependency-install@v4 |
| 67 | + with: |
| 68 | + path: requirements-dev.txt |
| 69 | + - name: Run unittests |
| 70 | + run: pytest tests |
| 71 | + env: |
| 72 | + COLOR: 'yes' |
| 73 | + # - run: python -m coverage xml |
| 74 | + # - name: Upload coverage |
| 75 | + # uses: codecov/codecov-action@v5 |
| 76 | + # with: |
| 77 | + # fail_ci_if_error: true |
| 78 | + # token: ${{ secrets.CODECOV_TOKEN }} |
| 79 | + |
| 80 | + check: # This job does nothing and is only used for the branch protection |
| 81 | + if: always() |
| 82 | + |
| 83 | + needs: [lint, test] |
| 84 | + |
| 85 | + runs-on: ubuntu-latest |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: Decide whether the needed jobs succeeded or failed |
| 89 | + uses: re-actors/alls-green@release/v1 |
| 90 | + with: |
| 91 | + jobs: ${{ toJSON(needs) }} |
| 92 | + |
| 93 | + deploy: |
| 94 | + name: Deploy |
| 95 | + environment: release |
| 96 | + runs-on: ubuntu-latest |
| 97 | + needs: [check] |
| 98 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 99 | + steps: |
| 100 | + - name: Checkout |
| 101 | + uses: actions/checkout@v4 |
| 102 | + - name: Setup Python |
| 103 | + uses: actions/setup-python@v5 |
| 104 | + with: |
| 105 | + python-version: 3.9 |
| 106 | + - name: Install dependencies |
| 107 | + run: |
| 108 | + python -m pip install -U pip wheel setuptools build twine |
| 109 | + - name: Build dists |
| 110 | + run: | |
| 111 | + python -m build |
| 112 | + - name: >- |
| 113 | + Publish 🐍📦 to PyPI |
| 114 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 115 | + - name: Sign the dists with Sigstore |
| 116 | + |
| 117 | + with: |
| 118 | + inputs: >- |
| 119 | + ./dist/${{ env.PROJECT_NAME }}*.tar.gz |
| 120 | + ./dist/${{ env.PROJECT_NAME }}*.whl |
| 121 | + - name: Upload artifact signatures to GitHub Release |
| 122 | + # Confusingly, this action also supports updating releases, not |
| 123 | + # just creating them. This is what we want here, since we've manually |
| 124 | + # created the release above. |
| 125 | + uses: softprops/action-gh-release@v2 |
| 126 | + with: |
| 127 | + # dist/ contains the built packages, which smoketest-artifacts/ |
| 128 | + # contains the signatures and certificates. |
| 129 | + files: dist/** |
| 130 | + # - name: Make Release |
| 131 | + # uses: aio-libs/[email protected] |
| 132 | + # with: |
| 133 | + # changes_file: CHANGES.rst |
| 134 | + # name: aiohttp-jinja2 |
| 135 | + # version_file: aiohttp_jinja2/__init__.py |
| 136 | + # github_token: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + # pypi_token: ${{ secrets.PYPI_API_TOKEN }} |
| 138 | + # dist_dir: dist |
| 139 | + # fix_issue_regex: "`#(\\d+) <https://github.com/aio-libs/aiohttp-jinja2/issues/\\1>`" |
| 140 | + # fix_issue_repl: "(#\\1)" |
0 commit comments