ci: add Forgejo Actions test workflow with Postgres service

This commit is contained in:
2026-04-18 18:07:50 +00:00
parent e1bfbaa3ea
commit fba1366537
+73
View File
@@ -0,0 +1,73 @@
name: test
on:
push:
branches: [dev]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: minstrel
POSTGRES_PASSWORD: minstrel
POSTGRES_DB: minstrel_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U minstrel"
--health-interval 10s
--health-timeout 5s
--health-retries 10
env:
MINSTREL_TEST_DATABASE_URL: postgres://minstrel:minstrel@localhost:5432/minstrel_test?sslmode=disable
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect Go project
id: gomod
shell: bash
run: |
if [ -f go.mod ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> "$GITHUB_OUTPUT"
echo "::notice::No go.mod yet — Go steps will be skipped until the skeleton lands"
fi
- name: Set up Go
if: steps.gomod.outputs.present == 'true'
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: go vet
if: steps.gomod.outputs.present == 'true'
run: go vet ./...
- name: golangci-lint
if: steps.gomod.outputs.present == 'true'
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: go test (race + coverage)
if: steps.gomod.outputs.present == 'true'
run: go test -race -coverprofile=coverage.out ./...
- name: Upload coverage artifact
if: steps.gomod.outputs.present == 'true'
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.out
if-no-files-found: ignore