name: AIOps CI on: push: branches: [main, master, dev] pull_request: branches: [main, master, dev] workflow_dispatch: permissions: contents: read concurrency: group: aiops-ci-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: backend: name: Backend (test, vet, build) runs-on: ubuntu-latest defaults: run: working-directory: backend steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: "1.25.x" cache-dependency-path: backend/go.sum - name: Download modules run: go mod download - name: Unit tests run: go test ./... - name: Vet run: go vet ./... - name: Build run: go build -buildvcs=false -o "$RUNNER_TEMP/aiops" . agent: name: Agent (test, vet, build) runs-on: ubuntu-latest defaults: run: working-directory: agent steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: "1.25.x" cache-dependency-path: agent/go.sum - name: Download modules run: go mod download - name: Unit tests run: go test ./... - name: Vet run: go vet ./... - name: Build Linux binary run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "$RUNNER_TEMP/aiops-agent" . frontend: name: Frontend (typecheck, lint, build) runs-on: ubuntu-latest defaults: run: working-directory: frontend steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: "20" cache: npm cache-dependency-path: frontend/package-lock.json - name: Install dependencies run: npm ci - name: Type check run: npm run typecheck # ESLint 错误必须阻断 CI,禁止以 continue-on-error 掩盖质量问题。 # Logan.Li - name: Lint run: npm run lint - name: Production build run: npm run build api-integration: name: API integration (SQLite + redka) runs-on: ubuntu-latest env: AIOPS_TEST_USERNAME: admin AIOPS_TEST_PASSWORD: "123456" AIOPS_TEST_PORT: "18080" steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version: "1.25.x" cache-dependency-path: backend/go.sum - name: Build disposable test server working-directory: backend run: go build -buildvcs=false -o "$RUNNER_TEMP/aiops" . - name: Start disposable local service run: | nohup "$RUNNER_TEMP/aiops" --mode local --port "$AIOPS_TEST_PORT" --db-name "$RUNNER_TEMP/aiops-ci.sqlite3" --jwt-secret "ci-only-jwt-secret" --log-level warn > "$RUNNER_TEMP/aiops.log" 2>&1 & echo $! > "$RUNNER_TEMP/aiops.pid" - name: Wait for health endpoint run: | for attempt in $(seq 1 30); do if curl --fail --silent --show-error "http://127.0.0.1:${AIOPS_TEST_PORT}/health" > /dev/null; then exit 0 fi sleep 1 done cat "$RUNNER_TEMP/aiops.log" exit 1 - name: Run critical API integration tests run: python3 tests/integration_test.py --host 127.0.0.1 --port "$AIOPS_TEST_PORT" - name: Show service log on failure if: failure() run: cat "$RUNNER_TEMP/aiops.log" - name: Stop disposable local service if: always() run: | if [ -f "$RUNNER_TEMP/aiops.pid" ]; then kill "$(cat "$RUNNER_TEMP/aiops.pid")" || true fi