Files
creator-hub/.gitea/workflows/douyin-release-gate.yaml
T

118 lines
4.3 KiB
YAML

name: douyin-release-gate
on:
push:
branches: [main]
pull_request:
jobs:
verify:
runs-on: ubuntu-latest
services:
postgres:
image: >-
postgres:17-alpine@sha256:18cfe3ef5e6815560c98237d6216d1e5119702fb0f3894c8785dd58b8bbe5d73
env:
POSTGRES_DB: creatorhub
POSTGRES_USER: creatorhub
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd "pg_isready -h 127.0.0.1 -U creatorhub -d creatorhub"
--health-interval 2s --health-timeout 2s --health-retries 15
env:
CREATORHUB_POSTGRES_TEST_URL: >-
postgres://creatorhub@postgres:5432/creatorhub?sslmode=disable
CONTROL_PLANE_USERNAME: ci
CONTROL_PLANE_PASSWORD: ci-password
CREATORHUB_CREDENTIAL_MASTER_KEY: >-
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
with:
go-version: '1.26'
cache: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '22'
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: '3.13'
- name: Go tests and race gate
run: |
set -Eeuo pipefail
git diff --check
go test -p 1 -parallel 1 -count=1 ./...
go vet ./...
go test -p 1 -parallel 1 -race -count=1 ./...
go build ./cmd/control-plane
- name: PostgreSQL integration and coverage gate
run: |
set -Eeuo pipefail
mkdir -p evidence
python3 - <<'PY'
import socket
with socket.create_connection(("postgres", 5432), timeout=5):
pass
PY
go test -p 1 -parallel 1 -count=1 -json \
-coverprofile=evidence/go.cover ./... \
| tee evidence/go-test.jsonl
go tool cover -func=evidence/go.cover | tee evidence/go-cover.txt
python3 - <<'PY'
import json
from pathlib import Path
total = next(
line
for line in Path("evidence/go-cover.txt").read_text().splitlines()
if line.startswith("total:")
)
coverage = float(total.strip().split()[-1].rstrip("%"))
if coverage < 65:
raise SystemExit(f"Go coverage {coverage:.2f}% is below 65%")
skipped = []
for line in Path("evidence/go-test.jsonl").read_text().splitlines():
event = json.loads(line)
is_skip = event.get("Action") == "skip"
is_test = str(event.get("Test", "")).startswith("Test")
if is_skip and is_test:
skipped.append(event)
if skipped:
raise SystemExit(f"Go tests skipped: {skipped[:5]}")
PY
- name: Python gateway tests and coverage gate
run: |
set -Eeuo pipefail
python3 -m pip install -r requirements-gateway.lock coverage==7.16.0
python3 -m coverage erase
python3 -m coverage run \
--source=browser_gateway \
--omit='browser_gateway/test_*.py' \
-m unittest discover -s browser_gateway -t . -p 'test_*.py'
python3 -m coverage report --precision=2 --fail-under=65
python3 -m coverage json -o evidence/python-coverage.json
python3 - <<'PY'
import json
with open("evidence/python-coverage.json") as f:
total = json.load(f)["totals"]
if total["covered_lines"] * 100 < total["num_statements"] * 65:
raise SystemExit(f"Python coverage below 65%: {total}")
PY
- name: Frontend clean install, typecheck, and build
run: |
set -Eeuo pipefail
npm --prefix web ci --ignore-scripts
npm --prefix web run build
- name: Compose configuration gate
run: |
set -Eeuo pipefail
docker compose config --quiet
docker compose -f compose.yaml -f compose.dev.yaml config --quiet
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: always()
with:
name: douyin-release-gate-evidence
path: |
evidence/