LoVisual/.github/workflows/ci.yml
loki5512344 fa08d50704
ci: make the backend job work on the local Forgejo runner
minio/minio is gone from Docker Hub (use the bitnami image that starts without a command), install psql/protoc/socat in the bare job container (no sudo), forward the services to localhost, and fetch non-mirrored actions from github.com.
2026-10-09 22:15:55 +02:00

136 lines
3.8 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
backend:
name: backend (cargo test + clippy)
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: lovisual
POSTGRES_PASSWORD: lovisual
POSTGRES_DB: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U lovisual"
--health-interval 5s
--health-timeout 5s
--health-retries 10
# minio/minio left Docker Hub and needs a `server /data` command that
# service containers cannot pass; the bitnami image starts on its own.
s3:
image: bitnamilegacy/minio:latest
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
env:
DATABASE_URL: postgres://lovisual:lovisual@localhost:5432/accounts_db
CONFIGS_DATABASE_URL: postgres://lovisual:lovisual@localhost:5432/configs_db
steps:
- uses: actions/checkout@v4
# Jobs run in a bare container as root: no sudo, no psql. The services
# are reachable by name, so socat forwards them to the localhost URLs the
# tests and env use.
- name: Install protoc, psql and socat
run: apt-get update && apt-get install -y protobuf-compiler postgresql-client socat
- name: Expose services on localhost
run: |
socat TCP-LISTEN:5432,fork,reuseaddr TCP:postgres:5432 &
socat TCP-LISTEN:9000,fork,reuseaddr TCP:s3:9000 &
sleep 1
- name: Install Rust toolchain
uses: https://github.com/dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Cache cargo build
uses: https://github.com/Swatinem/rust-cache@v2
with:
workspaces: backend
- name: Create service databases
run: |
psql -h localhost -U lovisual -d postgres -c "CREATE DATABASE accounts_db"
psql -h localhost -U lovisual -d postgres -c "CREATE DATABASE configs_db"
env:
PGPASSWORD: lovisual
- name: cargo fmt --check
run: cargo fmt --check
working-directory: backend
- name: cargo clippy
run: cargo clippy --workspace --all-targets -- -D warnings
working-directory: backend
- name: cargo test
run: cargo test --workspace --no-fail-fast
working-directory: backend
frontend:
name: frontend (lint + test + build)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install bun
uses: https://github.com/oven-sh/setup-bun@v2
- name: Cache bun install
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('frontend/bun.lock') }}
restore-keys: bun-${{ runner.os }}-
- name: Install dependencies
run: bun install --frozen-lockfile
working-directory: frontend
- name: lint
run: bun run lint
working-directory: frontend
- name: test
run: bun run test
working-directory: frontend
- name: build
run: bun run build
working-directory: frontend
mod:
name: mod (gradle test + checkFolderLimit)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install JDK 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25
- name: Setup Gradle (dependency + loom caching)
uses: gradle/actions/setup-gradle@v4
- name: test + checkFolderLimit
run: ./gradlew test checkFolderLimit --console=plain
working-directory: mod