| 1 |
name: tests |
| 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 |
pre-commit: |
| 13 |
|
| 14 |
runs-on: ubuntu-latest |
| 15 |
|
| 16 |
steps: |
| 17 |
- uses: actions/checkout@v3 |
| 18 |
- name: Set up Python 3.8 |
| 19 |
uses: actions/setup-python@v4 |
| 20 |
with: |
| 21 |
python-version: "3.8" |
| 22 |
- uses: pre-commit/[email protected] |
| 23 |
|
| 24 |
tests: |
| 25 |
|
| 26 |
name: Pytest (${{ matrix.platform }}, Python ${{ matrix.python-version }}) |
| 27 |
|
| 28 |
strategy: |
| 29 |
fail-fast: false |
| 30 |
matrix: |
| 31 |
python-version: ["3.8", "3.9", "3.10", "3.11"] |
| 32 |
platform: [ubuntu-latest] |
| 33 |
include: |
| 34 |
- python-version: "3.8" |
| 35 |
platform: "windows-latest" |
| 36 |
|
| 37 |
runs-on: ${{ matrix.platform }} |
| 38 |
|
| 39 |
steps: |
| 40 |
- uses: actions/checkout@v2 |
| 41 |
- name: Set up Python ${{ matrix.python-version }} |
| 42 |
uses: actions/setup-python@v2 |
| 43 |
with: |
| 44 |
python-version: ${{ matrix.python-version }} |
| 45 |
- name: Install dependencies |
| 46 |
run: | |
| 47 |
python -m pip install --upgrade pip |
| 48 |
pip install -e .[testing] |
| 49 |
- name: Run tests |
| 50 |
run: pytest |
| 51 |
|
| 52 |
# https://github.com/marketplace/actions/alls-green#why |
| 53 |
check: # This job does nothing and is only used for the branch protection |
| 54 |
|
| 55 |
if: always() |
| 56 |
|
| 57 |
needs: |
| 58 |
- pre-commit |
| 59 |
- tests |
| 60 |
|
| 61 |
runs-on: ubuntu-latest |
| 62 |
|
| 63 |
steps: |
| 64 |
- name: Decide whether the needed jobs succeeded or failed |
| 65 |
uses: re-actors/alls-green@release/v1 |
| 66 |
with: |
| 67 |
jobs: ${{ toJSON(needs) }} |
| 68 |
|
| 69 |
publish: |
| 70 |
|
| 71 |
name: Publish to PyPI |
| 72 |
needs: |
| 73 |
- check |
| 74 |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 75 |
runs-on: ubuntu-latest |
| 76 |
steps: |
| 77 |
- name: Checkout source |
| 78 |
uses: actions/checkout@v4 |
| 79 |
- name: Set up Python 3.8 |
| 80 |
uses: actions/setup-python@v4 |
| 81 |
with: |
| 82 |
python-version: "3.8" |
| 83 |
- name: install flit |
| 84 |
run: | |
| 85 |
pip install flit~=3.4 |
| 86 |
- name: Build and publish |
| 87 |
run: | |
| 88 |
flit publish |
| 89 |
env: |
| 90 |
FLIT_USERNAME: __token__ |
| 91 |
FLIT_PASSWORD: ${{ secrets.PYPI_TOKEN }} |