The brief asked for one. docs/api.md is complete and hand-written, and there was nothing a tool could read. Written by hand rather than generated from annotations, which would have meant every handler carrying a second copy of itself in a comment. The risk with a hand-written spec is that it goes stale, so it does not depend on anybody remembering: openapi_test.go walks the chi router and fails both on a route nothing describes and on a description with no route behind it. CI separately checks it is a valid OpenAPI document. The test reads the file with a forty-line scanner rather than pulling in a YAML library. It needs two things — which paths are listed and which methods each has — and both sit at fixed indentation in a document the test also owns, which is worth more than a dependency in a project whose whole shape is one static binary. The CalDAV routes are excluded deliberately: PROPFIND and REPORT are outside what OpenAPI can describe, and docs/caldav.md covers them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
120 lines
3.1 KiB
YAML
120 lines
3.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
# A second push to the same branch makes the first run's result irrelevant.
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
go:
|
|
name: Go
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.26"
|
|
cache: true
|
|
|
|
- name: Formatting
|
|
run: |
|
|
unformatted=$(gofmt -l .)
|
|
if [ -n "$unformatted" ]; then
|
|
echo "These files are not gofmt'd:"
|
|
echo "$unformatted"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
# -race is the whole point of running tests in CI for a server with a
|
|
# WebSocket fan-out: a data race is exactly the bug that passes locally.
|
|
- name: Test
|
|
run: go test -race -count=1 ./...
|
|
|
|
- name: Build
|
|
run: CGO_ENABLED=0 go build ./...
|
|
|
|
spec:
|
|
name: OpenAPI is valid
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
|
|
# Structural validity only. That the spec matches the *router* is checked by
|
|
# a Go test, which is the half that actually goes stale.
|
|
- run: npx --yes @redocly/cli@latest lint docs/openapi.yaml
|
|
|
|
e2e:
|
|
name: End-to-end
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.26"
|
|
cache: true
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22"
|
|
cache: npm
|
|
cache-dependency-path: web/package-lock.json
|
|
|
|
- name: Install
|
|
working-directory: web
|
|
run: npm ci --no-audit --no-fund
|
|
|
|
# Chromium only. A smoke test exists to catch a build that does not work at
|
|
# all; running it three times in three engines finds the same breakage three
|
|
# times and costs three times as much.
|
|
- name: Install Chromium
|
|
working-directory: web
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
# The suite builds the frontend, embeds it and starts the real binary — see
|
|
# playwright.config.js. There is nothing to build here first.
|
|
- name: Test
|
|
working-directory: web
|
|
run: npm run test:e2e
|
|
|
|
- if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report
|
|
path: |
|
|
web/test-results/
|
|
web/playwright-report/
|
|
retention-days: 7
|
|
|
|
docker:
|
|
name: Docker image builds
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
# Build only — publishing happens on a tag, in release.yml. This job exists
|
|
# so a Dockerfile that no longer builds fails on the pull request rather
|
|
# than at release time.
|
|
- uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: false
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|