-
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (77 loc) · 2.59 KB
/
openapi.yml
File metadata and controls
88 lines (77 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
name: openapi
# Validate the embedded OpenAPI specification on every change.
# Two checks run:
# * redocly lint — schema-level validation against the OpenAPI 3.1
# meta-spec (broken refs, missing required fields, malformed
# types, etc.).
# * Go drift test — asserts every fiber route registered in
# `cmd/hypercache-server/main.go` has a matching path in
# `cmd/hypercache-server/openapi.yaml` (and vice-versa).
#
# Together they prevent the spec from silently drifting from the
# binary — neither one alone catches both classes of breakage.
on:
pull_request:
paths:
- "cmd/hypercache-server/openapi.yaml"
- "cmd/hypercache-server/openapi.go"
- "cmd/hypercache-server/openapi_test.go"
- "cmd/hypercache-server/main.go"
- ".github/workflows/openapi.yml"
push:
branches: [ main ]
paths:
- "cmd/hypercache-server/openapi.yaml"
- "cmd/hypercache-server/openapi.go"
- "cmd/hypercache-server/openapi_test.go"
- "cmd/hypercache-server/main.go"
- ".github/workflows/openapi.yml"
permissions:
contents: read
jobs:
spec-lint:
name: redocly lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "22"
# Pin a known-good redocly major. Patch updates are picked up
# automatically on next run; major bumps are explicit so a
# breaking change in the linter can't silently fail the build.
- name: redocly lint
run: npx --yes @redocly/cli@1 lint cmd/hypercache-server/openapi.yaml
drift-test:
name: code↔spec drift
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- name: Load project settings
id: settings
run: |
set -a
source .project-settings.env
set +a
echo "go_version=${GO_VERSION}" >> "$GITHUB_OUTPUT"
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "${{ steps.settings.outputs.go_version }}"
check-latest: true
- name: Cache Go modules
uses: actions/cache@v5
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ steps.settings.outputs.go_version }}-${{
hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ steps.settings.outputs.go_version }}-
- name: Drift test
run: go test -run TestOpenAPISpecMatchesRoutes ./cmd/hypercache-server/ -count=1