CI #179
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [master] | |
tags: [v*] | |
pull_request: | |
branches: [master] | |
pull_request_target: | |
branches: [master] | |
schedule: | |
- cron: 0 4 * * * | |
concurrency: | |
group: ci-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
name: Linter | |
runs-on: ubuntu-latest | |
# 5 mins for the linter run, possibly 10 min for pre-commit env reinitialization | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Setup Python 3.13 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.13 | |
- name: Install poetry | |
run: | | |
pip install poetry | |
- name: Get poetry cache dir | |
id: poetry-cache | |
run: | | |
echo "dir=$(poetry config cache-dir)" >> $GITHUB_OUTPUT # - name: Cache | |
shell: bash | |
- name: Cache PyPI | |
uses: actions/cache@v4 | |
with: | |
key: 3.13-${{ hashFiles('pyproject.toml') }} | |
path: ${{ steps.poetry-cache.outputs.dir }} | |
restore-keys: | | |
3.13- | |
- name: Cache pre-commit hooks | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pre-commit | |
key: lint-${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Install dependencies | |
run: poetry install --with dev | |
- name: Run pre-commit | |
run: | | |
poetry run pre-commit run --all-files | |
- name: Run mypy | |
run: | | |
poetry run mypy | |
unit: | |
name: Unit | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
continue-on-error: [false] | |
# include: | |
# - python-version: '3.13' | |
# continue-on-error: true | |
fail-fast: false | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
continue-on-error: ${{ matrix.continue-on-error }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install poetry | |
run: | | |
pip install poetry | |
- name: Get poetry cache dir | |
id: poetry-cache | |
run: | | |
echo "dir=$(poetry config cache-dir)" >> $GITHUB_OUTPUT # - name: Cache | |
shell: bash | |
- name: Cache PyPI | |
uses: actions/cache@v4 | |
with: | |
key: ${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') | |
}} | |
path: ${{ steps.poetry-cache.outputs.dir }} | |
restore-keys: | | |
${{ matrix.python-version }}- | |
- name: Install dependencies | |
run: | | |
poetry install --with dev | |
- name: Run unittests | |
env: | |
COLOR: yes | |
run: | | |
poetry run pytest tests/unit | |
e2e: | |
name: E2E | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
continue-on-error: [false] | |
# include: | |
# - python-version: '3.14' | |
# continue-on-error: true | |
fail-fast: false | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
continue-on-error: ${{ matrix.continue-on-error }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install poetry | |
run: | | |
pip install poetry | |
- name: Get poetry cache dir | |
id: poetry-cache | |
run: | | |
echo "dir=$(poetry config cache-dir)" >> $GITHUB_OUTPUT # - name: Cache | |
shell: bash | |
- name: Cache PyPI | |
uses: actions/cache@v4 | |
with: | |
key: ${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') | |
}} | |
path: ${{ steps.poetry-cache.outputs.dir }} | |
restore-keys: | | |
${{ matrix.python-version }}- | |
- name: Install dependencies | |
run: | | |
poetry install --with dev | |
- name: Run unittests | |
env: | |
COLOR: yes | |
E2E_AUDIENCE: ${{ secrets.E2E_AUDIENCE }} | |
E2E_AUTH0_URL: ${{ secrets.E2E_AUTH0_URL }} | |
E2E_CLIENT_ID: ${{ secrets.E2E_CLIENT_ID }} | |
E2E_CLIENT_SECRET: ${{ secrets.E2E_CLIENT_SECRET }} | |
run: | | |
poetry run pytest tests/e2e | |
all-tests-passed: | |
name: All tests passed | |
needs: [lint, unit, e2e] | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo OK | |
deploy: | |
name: Deploy | |
needs: all-tests-passed | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write # Run only on pushing a tag | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Setup Python 3.13 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.13 | |
- name: Install poetry | |
run: | | |
pip install poetry | |
poetry self add "poetry-dynamic-versioning[plugin]" | |
- name: Build | |
run: | | |
poetry build | |
- name: Configure upload token | |
run: | | |
poetry config pypi-token.pypi ${TOKEN} | |
env: | |
TOKEN: ${{ secrets.PYPI_TOKEN }} | |
- name: Publish package distributions to PyPI | |
run: | | |
poetry publish |