Skip to content

Commit c5bd55e

Browse files
committed
feat(api): oasdiff OpenAI openAPI spec against ours
diff the `/v1/openai/v1` routes 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. Signed-off-by: Charlie Doern <[email protected]>
1 parent 65f7b81 commit c5bd55e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/conformance.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ jobs:
4040
ref: ${{ github.event.pull_request.base.ref }}
4141
path: 'base'
4242

43+
44+
# Cache openai spec
45+
- name: Cache openai openapi spec
46+
id: cache-openapi
47+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
48+
with:
49+
path: ~/openai-openapi
50+
key: openai-openapi.yml
51+
4352
# Cache oasdiff to avoid checksum failures and speed up builds
4453
- name: Cache oasdiff
4554
id: cache-oasdiff
@@ -55,6 +64,12 @@ jobs:
5564
curl -fsSL https://raw.githubusercontent.com/oasdiff/oasdiff/main/install.sh | sh
5665
cp /usr/local/bin/oasdiff ~/oasdiff
5766
67+
- name: Get openai openapi spec
68+
if: steps.cache-openapi.outputs.cache-hit != 'true'
69+
run: |
70+
mkdir -p ~/openai-openapi
71+
curl -L https://app.stainless.com/api/spec/documented/openai/openapi.documented.yml -o ~/openai-openapi/openai-openapi.yml
72+
5873
# Setup cached oasdiff
5974
- name: Setup cached oasdiff
6075
if: steps.cache-oasdiff.outputs.cache-hit == 'true'
@@ -69,3 +84,27 @@ jobs:
6984
oasdiff breaking --fail-on ERR base/docs/static/llama-stack-spec.yaml docs/static/llama-stack-spec.yaml --match-path '^/v1/openai/v1' \
7085
--match-path '^/v1/vector-io' \
7186
--match-path '^/v1/vector-dbs'
87+
88+
# Run oasdiff to detect breaking changes in the API specification when compared to the OpenAI openAPI spec
89+
- name: Run OpenAPI Breaking Change Diff Against OpenAI API
90+
continue-on-error: true
91+
shell: bash
92+
run: |
93+
OPENAI_SPEC=~/openai-openapi/openai-openapi.yml
94+
LOCAL_SPEC=docs/static/llama-stack-spec.yaml
95+
96+
# Extract base OpenAI endpoint paths from the spec file (remove path parameters)
97+
BASE_PATHS=$(grep -o '/v1/openai/v1/[^:]*' "$LOCAL_SPEC" | sed 's|/v1/openai/v1/||' | sed 's|/{[^}]*}.*||' | sort -u)
98+
99+
# Build single regex pattern from extracted base paths
100+
PATTERN=$(echo "$BASE_PATHS" | tr '\n' '|' | sed 's/|$//')
101+
102+
echo "Debug: Extracted base paths:"
103+
echo "$BASE_PATHS"
104+
echo "Debug: Generated pattern: (^/v1/openai/v1)?/($PATTERN)(/.*)?$"
105+
106+
oasdiff breaking --fail-on ERR \
107+
"$OPENAI_SPEC" \
108+
"$LOCAL_SPEC" \
109+
--strip-prefix-revision "/v1/openai/v1" \
110+
--match-path "(^/v1/openai/v1)?/($PATTERN)(/.*)?$"

0 commit comments

Comments
 (0)