69 lines
2.1 KiB
YAML
69 lines
2.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
tags-ignore: ["**"]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: https://github.com/astral-sh/setup-uv@v6
|
|
with:
|
|
# Exact version: avoids an unauthenticated GitHub API lookup for "latest".
|
|
version: "0.7.21"
|
|
- run: uv sync --locked
|
|
- run: uv run ruff check
|
|
- run: uv run ruff format --check
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: scrobbler
|
|
POSTGRES_PASSWORD: scrobbler
|
|
POSTGRES_DB: scrobbler_test
|
|
options: >-
|
|
--health-cmd "pg_isready -U scrobbler"
|
|
--health-interval 5s
|
|
--health-timeout 3s
|
|
--health-retries 10
|
|
env:
|
|
DATABASE_URL: postgresql+psycopg://scrobbler:scrobbler@postgres:5432/scrobbler_test
|
|
TEST_DATABASE_URL: postgresql+psycopg://scrobbler:scrobbler@postgres:5432/scrobbler_test
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: https://github.com/astral-sh/setup-uv@v6
|
|
with:
|
|
# Exact version: avoids an unauthenticated GitHub API lookup for "latest".
|
|
version: "0.7.21"
|
|
- run: uv sync --locked
|
|
- name: Migrations are in sync with the models
|
|
run: |
|
|
uv run flask --app scrobbler db upgrade
|
|
uv run flask --app scrobbler db check
|
|
- run: uv run pytest
|
|
|
|
notify:
|
|
needs: [lint, test]
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: ./.gitea/actions/notify
|
|
with:
|
|
status: ${{ (needs.lint.result == 'success' && needs.test.result == 'success') && 'success' || ((needs.lint.result == 'cancelled' || needs.test.result == 'cancelled') && 'cancelled' || 'failure') }}
|
|
title: CI ${{ github.ref_name }}
|
|
message: "lint: ${{ needs.lint.result }} · test: ${{ needs.test.result }}"
|
|
url: ${{ vars.NTFY_URL }}
|
|
topic: ${{ vars.NTFY_TOPIC }}
|
|
user: ${{ secrets.NTFY_USER }}
|
|
password: ${{ secrets.NTFY_PASSWORD }}
|