Skip to content

Commit bc6a756

Browse files
authored
ci: lint openapi specs using redocly (#12510)
We need to lint specs for pageserver, endpoint storage, and safekeeper #0000
1 parent 8f3351f commit bc6a756

File tree

4 files changed

+41
-52
lines changed

4 files changed

+41
-52
lines changed

.github/workflows/build_and_test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ jobs:
8787
uses: ./.github/workflows/build-build-tools-image.yml
8888
secrets: inherit
8989

90+
lint-openapi-spec:
91+
runs-on: ubuntu-22.04
92+
needs: [ meta, check-permissions ]
93+
# We do need to run this in `.*-rc-pr` because of hotfixes.
94+
if: ${{ contains(fromJSON('["pr", "push-main", "storage-rc-pr", "proxy-rc-pr", "compute-rc-pr"]'), needs.meta.outputs.run-kind) }}
95+
steps:
96+
- name: Harden the runner (Audit all outbound calls)
97+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
98+
with:
99+
egress-policy: audit
100+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
101+
- uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
102+
with:
103+
registry: ghcr.io
104+
username: ${{ github.actor }}
105+
password: ${{ secrets.GITHUB_TOKEN }}
106+
- run: make lint-openapi-spec
107+
90108
check-codestyle-python:
91109
needs: [ meta, check-permissions, build-build-tools-image ]
92110
# No need to run on `main` because we this in the merge queue. We do need to run this in `.*-rc-pr` because of hotfixes.

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ neon-pgindent: postgres-v17-pg-bsd-indent neon-pg-ext-v17
220220
setup-pre-commit-hook:
221221
ln -s -f $(ROOT_PROJECT_DIR)/pre-commit.py .git/hooks/pre-commit
222222

223+
.PHONY: lint-openapi-spec
224+
lint-openapi-spec:
225+
# operation-2xx-response: pageserver timeline delete returns 404 on success
226+
find . -iname "openapi_spec.y*ml" -exec\
227+
docker run --rm -v ${PWD}:/spec ghcr.io/redocly/cli:1.34.4\
228+
--skip-rule=operation-operationId --skip-rule=operation-summary --extends=minimal\
229+
--skip-rule=no-server-example.com --skip-rule=operation-2xx-response\
230+
lint {} \+
231+
223232
# Targets for building PostgreSQL are defined in postgres.mk.
224233
#
225234
# But if the caller has indicated that PostgreSQL is already

compute_tools/src/http/openapi_spec.yaml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,6 @@ components:
416416
total_startup_ms:
417417
type: integer
418418

419-
Info:
420-
type: object
421-
description: Information about VM/Pod.
422-
required:
423-
- num_cpus
424-
properties:
425-
num_cpus:
426-
type: integer
427-
428419
DbsAndRoles:
429420
type: object
430421
description: Databases and Roles
@@ -642,26 +633,6 @@ components:
642633
description: Promote error, if any
643634
type: string
644635

645-
InstalledExtensions:
646-
type: object
647-
properties:
648-
extensions:
649-
description: Contains list of installed extensions.
650-
type: array
651-
items:
652-
type: object
653-
properties:
654-
extname:
655-
type: string
656-
version:
657-
type: string
658-
items:
659-
type: string
660-
n_databases:
661-
type: integer
662-
owned_by_superuser:
663-
type: integer
664-
665636
SetRoleGrantsRequest:
666637
type: object
667638
required:

pageserver/src/http/openapi_spec.yml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,6 @@ paths:
116116
schema:
117117
type: string
118118

119-
/v1/tenant/{tenant_id}/timeline:
120-
parameters:
121-
- name: tenant_id
122-
in: path
123-
required: true
124-
schema:
125-
type: string
126-
get:
127-
description: Get timelines for tenant
128-
responses:
129-
"200":
130-
description: TimelineInfo
131-
content:
132-
application/json:
133-
schema:
134-
type: array
135-
items:
136-
$ref: "#/components/schemas/TimelineInfo"
137-
138-
139119
/v1/tenant/{tenant_id}/timeline/{timeline_id}:
140120
parameters:
141121
- name: tenant_id
@@ -618,7 +598,7 @@ paths:
618598
schema:
619599
$ref: "#/components/schemas/SecondaryProgress"
620600

621-
/v1/tenant/{tenant_id}/timeline/:
601+
/v1/tenant/{tenant_id}/timeline:
622602
parameters:
623603
- name: tenant_id
624604
in: path
@@ -685,6 +665,17 @@ paths:
685665
application/json:
686666
schema:
687667
$ref: "#/components/schemas/Error"
668+
get:
669+
description: Get timelines for tenant
670+
responses:
671+
"200":
672+
description: TimelineInfo
673+
content:
674+
application/json:
675+
schema:
676+
type: array
677+
items:
678+
$ref: "#/components/schemas/TimelineInfo"
688679

689680
/v1/tenant/{tenant_shard_id}/timeline/{timeline_id}/detach_ancestor:
690681
parameters:
@@ -767,7 +758,7 @@ paths:
767758
$ref: "#/components/schemas/ServiceUnavailableError"
768759

769760

770-
/v1/tenant/:
761+
/v1/tenant:
771762
get:
772763
description: Get tenants list
773764
responses:
@@ -847,7 +838,7 @@ paths:
847838
items:
848839
$ref: "#/components/schemas/TenantInfo"
849840

850-
/v1/tenant/{tenant_id}/config/:
841+
/v1/tenant/{tenant_id}/config:
851842
parameters:
852843
- name: tenant_id
853844
in: path

0 commit comments

Comments
 (0)