Files
openfsd/.github/workflows/ci.yml
Reese Norris acee8e7066 ci: fix geo coverage floor and harden GHCR push job
Cover QuantizeDeg non-positive quantum path so internal/geo hits 100%
(floor was failing at 96.9%). Grant actions:write for GHA cache, allow
optional GHCR_TOKEN, and document package Actions access for write_package.
2026-07-17 13:50:39 -04:00

99 lines
3.3 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@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Race tests
run: go test -race -count=1 ./...
- name: Coverage floor ≥80% (exclude cmd/)
run: bash scripts/check-coverage.sh 80
- 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@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3
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@v5
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@v6
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@v4
- uses: actions/setup-go@v5
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