Skip to content

Type check and Build #553

Type check and Build

Type check and Build #553

Workflow file for this run

name: Type check and Build
on:
push:
paths:
- "**.py"
- "**.html"
- "**.css"
- "**.yaml"
- "uv.lock"
- "package-lock.json"
- "Dockerfile"
pull_request:
paths:
- "**.py"
- "**.html"
- "**.css"
- "**.yaml"
- "uv.lock"
- "package-lock.json"
- "Dockerfile"
release:
types: [created]
jobs:
test:
name: Test types
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.8.22"
- name: Install sqlite3
run: |
sudo apt-get update
sudo apt-get install -y sqlite3
- run: uv sync --all-extras
- name: Run Type Checks
run: uv run basedpyright
- name: Check if Jinjax parameters are defined
run: uv run app/util/test_jinjax.py templates -g getattr version json_regexp base_url changelog content -f toJSstring
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Check SQLite Alembic Migrations
run: |
uv run alembic upgrade heads
uv run alembic check
uv run alembic downgrade base
uv run alembic upgrade heads
uv run alembic check
- name: Check PSQL Alembic Migrations
run: |
uv run alembic upgrade heads
uv run alembic check
uv run alembic downgrade base
uv run alembic upgrade heads
uv run alembic check
env:
ABR_DB__POSTGRES_HOST: localhost
ABR_DB__POSTGRES_PORT: 5432
ABR_DB__POSTGRES_USER: postgres
ABR_DB__POSTGRES_PASSWORD: postgres
ABR_DB__POSTGRES_DB: postgres
ABR_DB__USE_POSTGRES: true
build:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Determine tags
id: vars
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
# Remove leading 'v' if present
VERSION="${VERSION#v}"
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
PATCH=$(echo $VERSION | cut -d. -f3)
echo "tags=${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:$VERSION,${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:$MAJOR.$MINOR,${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:$MAJOR,${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:latest" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "tags=${{ secrets.DOCKER_HUB_USERNAME }}/audiobookrequest:nightly" >> $GITHUB_OUTPUT
github_sha_hash=${{ github.sha }}
echo "version=nightly:${github_sha_hash:0:7}" >> $GITHUB_OUTPUT
fi
- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.vars.outputs.tags }}
build-args: |
VERSION=${{ steps.vars.outputs.version }}