ci: add GitHub Actions workflow (Gitea Actions compatible)
This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, 'fix/**', 'feat/**']
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
backend:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:16
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: booklib
|
||||||
|
POSTGRES_PASSWORD: booklib
|
||||||
|
POSTGRES_DB: booklib
|
||||||
|
ports: ['5432:5432']
|
||||||
|
options: >-
|
||||||
|
--health-cmd pg_isready
|
||||||
|
--health-interval 5s
|
||||||
|
--health-timeout 3s
|
||||||
|
--health-retries 10
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
ports: ['6379:6379']
|
||||||
|
options: >-
|
||||||
|
--health-cmd "redis-cli ping"
|
||||||
|
--health-interval 5s
|
||||||
|
--health-timeout 3s
|
||||||
|
--health-retries 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: backend/go.mod
|
||||||
|
- name: Format check
|
||||||
|
run: |
|
||||||
|
cd backend
|
||||||
|
OUT=$(gofmt -l .)
|
||||||
|
if [ -n "$OUT" ]; then echo "gofmt violations:"; echo "$OUT"; exit 1; fi
|
||||||
|
- name: Vet
|
||||||
|
run: cd backend && go vet ./...
|
||||||
|
- name: Test
|
||||||
|
run: cd backend && go test -p 1 -count=1 ./...
|
||||||
|
env:
|
||||||
|
DATABASE_URL: postgres://booklib:booklib@localhost:5432/booklib?sslmode=disable
|
||||||
|
REDIS_URL: redis://localhost:6379/0
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
- run: cd frontend && npm ci
|
||||||
|
- run: cd frontend && npm run check
|
||||||
Reference in New Issue
Block a user