Files
xinfra/.github/workflows/ci.yml
T

129 lines
3.0 KiB
YAML

name: CI
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
backend-unit:
name: Backend unit tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: server/go.mod
cache: true
cache-dependency-path: server/go.sum
- name: Download Go modules
run: go mod download
- name: Go vet
run: go vet ./...
- name: Run Go unit tests
run: go test -race -covermode=atomic -coverprofile=coverage.out ./...
- name: Upload Go coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-coverage
path: server/coverage.out
if-no-files-found: ignore
frontend-validation:
name: Frontend typecheck and build
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: npm ci
- name: Build frontend
run: npm run build
integration:
name: Backend integration smoke test
runs-on: ubuntu-latest
needs:
- backend-unit
- frontend-validation
services:
mysql:
image: mysql:8.0.46
env:
MYSQL_ROOT_PASSWORD: root123456
MYSQL_DATABASE: authserver
MYSQL_USER: auth
MYSQL_PASSWORD: auth
TZ: Asia/Shanghai
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -uroot -proot123456"
--health-interval=10s
--health-timeout=5s
--health-retries=12
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: server/go.mod
cache: true
cache-dependency-path: server/go.sum
- name: Download Go modules
working-directory: server
run: go mod download
- name: Run integration smoke test
working-directory: server
env:
APP_ENV: test
HTTP_ADDR: 127.0.0.1:8080
MYSQL_DSN: "auth:auth@tcp(127.0.0.1:3306)/authserver?charset=utf8mb4&parseTime=True&loc=Local"
AUTO_MIGRATE: true
SSO_ENABLED: false
JWT_SECRET: ci-only-secret
DELIVERY_SCHEDULER_ENABLED: false
WAYNE_API_BASE_URL: ""
SINA_BASE_URL: ""
run: ../scripts/ci/integration.sh