Files
openfsd/.github/workflows/ci.yml
Reese Norris b1f4d09291 ci: fix check-hygiene.sh exit status; gate gofmt, hygiene, import-graph
Convert all five scan_files pipelines to process substitution so failed
is set in the parent shell. CI runs gofmt, hygiene, and import-graph
before race tests.
2026-07-27 13:45:42 -04:00

110 lines
3.7 KiB
YAML

name: CI
on:
push:
branches: [main, dev]
pull_request:
schedule:
# Weekly stress baselines (optional; does not gate PRs on latency).
- cron: "0 6 * * 1"
workflow_dispatch:
# GITHUB_TOKEN scopes for this workflow. The docker job elevates further.
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: gofmt
run: test -z "$(gofmt -l .)"
- name: Hygiene (no panic/reflect/fmt.Print in library code)
run: bash scripts/check-hygiene.sh
- name: Import graph
run: bash scripts/check-import-graph.sh
- name: Race tests
run: go test -race -count=1 ./...
- name: Coverage floor ≥80% (exclude cmd/)
run: bash scripts/check-coverage.sh 80
- name: Web JS unit tests (airport-editor pure modules)
run: bash scripts/check-webjs.sh
- name: Build binary
run: go build -o /tmp/openfsd ./cmd/openfsd
docker:
# Build and publish the single openfsd image on every push to main/dev.
# PRs only build (no push) to verify the Dockerfile stays green.
#
# If push fails with permission_denied: write_package, grant this repo
# Write under the package's "Manage Actions access":
# https://github.com/users/renorris/packages/container/openfsd/settings
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# GHA cache (type=gha) needs actions write.
actions: write
steps:
- uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
# Prefer optional PAT (write:packages) when an existing GHCR package
# lacks Actions write access; else job GITHUB_TOKEN (packages: write).
password: ${{ secrets.GHCR_TOKEN || secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
# Always publish branch tip tags; main also updates :latest.
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
# While primary work is on dev, keep :latest in sync with dev too.
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha,prefix=sha-
type=ref,event=branch
type=ref,event=pr
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Ensure image is attributable to this repo (helps package linking).
provenance: false
sbom: false
stress:
# Optional: scheduled or manual. Never fails on absolute latency thresholds.
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
- name: Stress baselines (build tag)
run: go test -tags=stress -count=1 -timeout=120s ./internal/server/ -run 'TestStress' -v