mirror of
https://github.com/truewhile/MeBox.git
synced 2026-11-12 19:34:24 +08:00
118 lines
3.0 KiB
YAML
118 lines
3.0 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
backend:
|
|
name: Backend (Go)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.26'
|
|
cache: true
|
|
|
|
# The binary embeds the SPA (web/dist) via go:embed, so the dist must exist
|
|
# before the Go toolchain touches the `web` package.
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: 'npm'
|
|
cache-dependency-path: web/package-lock.json
|
|
- name: Build SPA
|
|
working-directory: web
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: go vet
|
|
run: go vet ./...
|
|
|
|
- name: go build
|
|
run: go build ./...
|
|
|
|
- name: go test
|
|
run: go test ./...
|
|
|
|
database-compatibility:
|
|
name: SQLite / PostgreSQL ${{ matrix.postgres }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
postgres: [16, 17]
|
|
services:
|
|
postgres:
|
|
image: postgres:${{ matrix.postgres }}-alpine
|
|
env:
|
|
POSTGRES_USER: mebox
|
|
POSTGRES_PASSWORD: mebox-test-only
|
|
POSTGRES_DB: mebox_test
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd "pg_isready -U mebox -d mebox_test"
|
|
--health-interval 5s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
env:
|
|
MEBOX_TEST_POSTGRES_DSN: postgres://mebox:mebox-test-only@127.0.0.1:5432/mebox_test?sslmode=disable
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.26'
|
|
cache: true
|
|
|
|
- name: Database regression tests
|
|
run: go test ./internal/database ./internal/repository -count=1
|
|
|
|
frontend:
|
|
name: Frontend (Node)
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: web
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: '.nvmrc'
|
|
cache: 'npm'
|
|
cache-dependency-path: web/package-lock.json
|
|
|
|
- name: Install
|
|
run: npm ci
|
|
|
|
- name: Type-check & build
|
|
run: npm run build
|
|
|
|
smoke:
|
|
name: Deployment smoke test
|
|
runs-on: ubuntu-latest
|
|
needs: [backend, frontend]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Validate single-image compose
|
|
run: docker compose -f docker-compose.simple.yml config --quiet
|
|
- name: Validate tier 1 compose
|
|
run: docker compose -f docker-compose.yml config --quiet
|
|
- name: Validate tier 2 compose
|
|
run: docker compose -f docker-compose.standard.yml config --quiet
|
|
- name: Validate tier 3 compose
|
|
run: docker compose -f docker-compose.search.yml config --quiet
|
|
ci-success:
|
|
name: CI Success
|
|
runs-on: ubuntu-latest
|
|
needs: [backend, frontend, database-compatibility, smoke]
|
|
if: success()
|
|
steps:
|
|
- run: echo "CI passed, ready for release"
|