chore: improve pre-commit setup (#167) #467
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: | |
tags: ["v*.*.*"] | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/poetry | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/actions/python | |
with: | |
python-version: "3.10" | |
- run: make install | |
- uses: pre-commit/[email protected] | |
- uses: pre-commit-ci/[email protected] | |
if: always() && github.event_name == 'pull_request' | |
with: | |
msg: "chore: apply pre-commit fixes" | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/actions/python | |
with: | |
python-version: "3.10" | |
- run: make install | |
- run: echo "::add-matcher::.github/matcher-python.json" | |
- run: make lint | |
test: | |
needs: lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/actions/python | |
with: | |
python-version: ${{ matrix.python-version }} | |
- run: make install | |
- run: make test | |
- run: make e2e | |
- run: make examples | |
publish: | |
needs: test | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags') | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/actions/python | |
with: | |
python-version: "3.10" | |
- run: make install | |
- run: > | |
POETRY_PYPI_TOKEN_PYPI=${{ secrets.PYPI_TOKEN }} | |
make ci-publish | |
publish-docker: | |
needs: test | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags') | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |