Skip to content

Commit a8928b6

Browse files
committed
feat(api): oasdiff OpenAI openAPI spec against ours
diff the `/v1/` routes that are OpenAI compatible against the OpenAI openAPI spec. This will of course only trigger on PRs where the spec is changed. This will catch errors with new handwritten additions to our openAI compat routes. Instead of fetching the OpenAPI spec from a dynamic URL, which could cause non-deterministic build failures, this change uses a local copy stored at `docs/static/openai-spec.yml`. This makes the conformance check fully reproducible and prevents CI failures caused by uncontrolled upstream changes. Signed-off-by: Charlie Doern <[email protected]>
1 parent b83184f commit a8928b6

File tree

3 files changed

+2744
-0
lines changed

3 files changed

+2744
-0
lines changed

.github/workflows/conformance.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
ref: ${{ github.event.pull_request.base.ref }}
6565
path: 'base'
6666

67+
6768
# Cache oasdiff to avoid checksum failures and speed up builds
6869
- name: Cache oasdiff
6970
if: steps.skip-check.outputs.skip != 'true'
@@ -136,6 +137,23 @@ jobs:
136137
run: |
137138
oasdiff breaking --fail-on ERR $BASE_SPEC $CURRENT_SPEC --match-path '^/v1/'
138139
140+
# Run oasdiff to detect breaking changes in the API specification when compared to the OpenAI openAPI spec
141+
- name: Run OpenAPI Breaking Change Diff Against OpenAI API
142+
if: steps.skip-check.outputs.skip != 'true'
143+
continue-on-error: true
144+
shell: bash
145+
run: |
146+
OPENAI_SPEC=docs/static/openai-spec.yml
147+
LOCAL_SPEC=docs/static/llama-stack-spec.yaml
148+
149+
# Compare Llama Stack spec against OpenAI spec.
150+
# This finds breaking changes in our implementation of common endpoints.
151+
# By using our spec as the base, we avoid errors for endpoints we don't implement.
152+
oasdiff breaking --fail-on ERR \
153+
"$LOCAL_SPEC" \
154+
"$OPENAI_SPEC" \
155+
--strip-prefix-base "/v1"
156+
139157
# Report when test is skipped
140158
- name: Report skip reason
141159
if: steps.skip-check.outputs.skip == 'true'

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ repos:
1919
- id: no-commit-to-branch
2020
- id: check-yaml
2121
args: ["--unsafe"]
22+
exclude: 'docs/static/openai-spec.yml'
2223
- id: detect-private-key
2324
- id: mixed-line-ending
2425
args: [--fix=lf] # Forces to replace line ending by LF (line feed)

0 commit comments

Comments
 (0)