|
| 1 | +name: Testing |
| 2 | +on: [pull_request] |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +jobs: |
| 7 | + |
| 8 | + prepare: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + wheel-path: ${{ steps.distribution-paths.outputs.wheel }} |
| 12 | + tarball-path: ${{ steps.distribution-paths.outputs.tarball }} |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + with: { fetch-depth: 0 } # deep clone for setuptools-scm |
| 16 | + - uses: actions/setup-python@v5 |
| 17 | + with: { python-version: "3.11" } |
| 18 | + - name: Run static analysis and format checkers |
| 19 | + run: pipx run pre-commit run --all-files --show-diff-on-failure |
| 20 | + - name: Install tox-gh plugin |
| 21 | + run: python -m pip install tox-gh>=1.2 |
| 22 | + - name: Build package distribution files |
| 23 | + run: tox -e clean,build |
| 24 | + - name: Record the paths of wheel and source tarball distributions |
| 25 | + id: distribution-paths |
| 26 | + run: | |
| 27 | + echo "wheel=$(ls dist/*.whl)" >> $GITHUB_OUTPUT |
| 28 | + echo "tarball=$(ls dist/*.tar.gz)" >> $GITHUB_OUTPUT |
| 29 | + - name: Store the distribution files for use in other stages |
| 30 | + # `tests`, `pypi-publish`, and `docker-publish` will use the same |
| 31 | + # pre-built distributions, so we make sure to release the exact |
| 32 | + # same package that was tested |
| 33 | + uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: python-distribution-files |
| 36 | + path: dist/ |
| 37 | + retention-days: 1 |
| 38 | + |
| 39 | + test: |
| 40 | + needs: prepare |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + python: |
| 44 | + - "3.10" |
| 45 | + - "3.11" |
| 46 | + platform: |
| 47 | + - ubuntu-latest |
| 48 | + - macos-latest |
| 49 | + env: |
| 50 | + OS: ${{ matrix.platform }} |
| 51 | + PYTHON: ${{ matrix.python }} |
| 52 | + runs-on: ${{ matrix.platform }} |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v3 |
| 55 | + - uses: actions/setup-python@v4 |
| 56 | + with: |
| 57 | + python-version: ${{ matrix.python }} |
| 58 | + - uses: actions/download-artifact@v3 |
| 59 | + with: { name: python-distribution-files, path: dist/ } |
| 60 | + - name: Install tox-gh plugin |
| 61 | + run: python -m pip install tox-gh>=1.2 |
| 62 | + - name: Setup test suite |
| 63 | + run: tox -vv --notest |
| 64 | + - name: Run tests |
| 65 | + env: |
| 66 | + SYNAPSE_AUTH_TOKEN: ${{ secrets.SYNAPSE_AUTH_TOKEN }} |
| 67 | + run: >- |
| 68 | + tox --installpkg '${{ needs.prepare.outputs.wheel-path }}' |
| 69 | + -- -rFEx --durations 10 --color yes |
| 70 | + - name: Upload coverage to Codecov |
| 71 | + uses: codecov/codecov-action@v3 |
| 72 | + with: |
| 73 | + # CodeCov can be flaky, so this step is not required for success |
| 74 | + fail_ci_if_error: false |
| 75 | + files: coverage.xml |
| 76 | + # Using matrix pattern from `codecov/codecov-action` README: |
| 77 | + # https://github.com/codecov/codecov-action#example-workflowyml-with-codecov-action |
| 78 | + env_vars: OS,PYTHON |
| 79 | + verbose: true |
| 80 | + |
| 81 | + |
0 commit comments