69 lines
2.1 KiB
YAML
69 lines
2.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
lint-and-test:
|
|
name: Lint & Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
- name: Install uv
|
|
run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
- name: Add uv to PATH
|
|
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
- name: Install dependencies
|
|
run: uv sync --all-groups
|
|
- name: Run mypy type check
|
|
run: uv run mypy .
|
|
- name: Run ruff check
|
|
run: uvx ruff check .
|
|
- name: Run ruff format
|
|
run: uvx ruff format --check .
|
|
- name: Run pytest
|
|
run: uv run pytest --verbose --tb=short
|
|
|
|
build-and-push:
|
|
name: Build and push Docker image
|
|
runs-on: ubuntu-latest
|
|
needs: [lint-and-test]
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: https://github.com/actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: https://github.com/docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Forgejo Container Registry
|
|
uses: https://github.com/docker/login-action@v3
|
|
with:
|
|
registry: git.tomfos.tr
|
|
username: ${{ gitea.repository_owner }}
|
|
password: ${{ secrets.FORGEJO_TOKEN }}
|
|
|
|
- name: Determine image metadata
|
|
id: meta
|
|
uses: https://github.com/docker/metadata-action@v5
|
|
with:
|
|
images: git.tomfos.tr/${{ gitea.repository }}
|
|
tags: |
|
|
type=ref,event=branch,if=ref==refs/heads/main,format=latest
|
|
type=ref,event=branch,format={{ref_name}}
|
|
|
|
- name: Build and push Docker image
|
|
uses: https://github.com/docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=registry,ref=git.tomfos.tr/${{ gitea.repository }}:build-cache
|
|
cache-to: type=registry,ref=git.tomfos.tr/${{ gitea.repository }}:build-cache,mode=max
|