xtablo-source/.forgejo/workflows/backend-ci.yml
Arthur Belleville 5d0c201e86
Some checks failed
backend-ci / Backend tests (pull_request) Failing after 53s
backend-ci / Backend tests (push) Failing after 1s
Some work
2026-05-23 17:26:01 +02:00

84 lines
2.4 KiB
YAML

# Backend-only CI for Forgejo Actions (self-hosted runner on VPS).
# Triggers only when files under backend/ change.
name: backend-ci
on:
push:
paths:
- "backend/**"
- ".forgejo/workflows/backend-ci.yml"
pull_request:
paths:
- "backend/**"
- ".forgejo/workflows/backend-ci.yml"
concurrency:
group: backend-ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Backend tests
runs-on: self-hosted
defaults:
run:
working-directory: backend
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: xtablo
POSTGRES_USER: xtablo
POSTGRES_PASSWORD: xtablo
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U xtablo -d xtablo"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
# Service hostname is the job service name, not localhost.
DATABASE_URL: postgres://xtablo:xtablo@postgres:5432/xtablo?sslmode=disable
TEST_DATABASE_URL: postgres://xtablo:xtablo@postgres:5432/xtablo?sslmode=disable
timeout-minutes: 25
steps:
- name: Checkout
uses: https://data.forgejo.org/actions/checkout@v4
- name: Set up Go
uses: https://data.forgejo.org/actions/setup-go@v5
with:
go-version-file: backend/go.mod
cache-dependency-path: backend/go.sum
- name: Install codegen tools
run: |
go install github.com/a-h/templ/cmd/templ@v0.3.1020
go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.31.1
- name: Generate (templ, sqlc, tailwind, htmx)
run: |
set -euo pipefail
mkdir -p bin static
case "$(uname -m)" in
x86_64|amd64) tw_arch=x64 ;;
aarch64|arm64) tw_arch=arm64 ;;
*) echo "unsupported arch"; exit 1 ;;
esac
curl -fsSL -o bin/tailwindcss \
"https://github.com/tailwindlabs/tailwindcss/releases/download/v4.0.0/tailwindcss-linux-${tw_arch}"
chmod +x bin/tailwindcss
templ generate
sqlc generate
./bin/tailwindcss -i tailwind.input.css -o static/tailwind.css
curl -fsSL -o static/htmx.min.js "https://unpkg.com/htmx.org@2/dist/htmx.min.js"
- name: go test
run: go test ./...