62 lines
1.5 KiB
YAML

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install poetry
poetry config virtualenvs.create false
if [ -f poetry.lock ]; then poetry install --no-dev; else pip install .; fi
pip install flake8 mypy
- name: Lint with flake8
run: flake8 .
- name: Static analysis with mypy
run: mypy .
- name: Run tests
run: |
pip install pytest
pytest -q
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
run: |
IMAGE_TAG=ghcr.io/${{ github.repository_owner }}/${{ github.repository_name }}:$(git rev-parse --short HEAD)
docker build -t $IMAGE_TAG .
- name: Push Docker image
if: success()
run: |
IMAGE_TAG=ghcr.io/${{ github.repository_owner }}/${{ github.repository_name }}:$(git rev-parse --short HEAD)
docker push $IMAGE_TAG