Skip to content

Commit 712ba58

Browse files
committed
test: introduce api conformance test
this test runs on each PR and uses the openapi-diff-action to compare the base (main) branch openapi spec to the one on this PR if one of our "stable" APIs change, the test will fail. As a follow up to this, we can add an optional way to make it so that it is OK to make these change if properly documented or in a changelog or something. related to #3237 Signed-off-by: Charlie Doern <[email protected]>
1 parent 1eb1ac0 commit 712ba58

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Llama Stack uses GitHub Actions for Continuous Integration (CI). Below is a tabl
55
| Name | File | Purpose |
66
| ---- | ---- | ------- |
77
| Update Changelog | [changelog.yml](changelog.yml) | Creates PR for updating the CHANGELOG.md |
8+
| API Conformance Tests | [conformance.yml](conformance.yml) | Run the API Conformance test suite on the changes. |
89
| Installer CI | [install-script-ci.yml](install-script-ci.yml) | Test the installation script |
910
| Integration Auth Tests | [integration-auth-tests.yml](integration-auth-tests.yml) | Run the integration test suite with Kubernetes authentication |
1011
| SqlStore Integration Tests | [integration-sql-store-tests.yml](integration-sql-store-tests.yml) | Run the integration test suite with SqlStore |

.github/workflows/conformance.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: API Conformance Tests
2+
3+
run-name: Run the API Conformance test suite on the changes.
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
types: [opened, synchronize, reopened]
11+
paths:
12+
- 'llama_stack/**'
13+
- '!llama_stack/ui/**'
14+
- 'tests/**'
15+
- 'uv.lock'
16+
- 'pyproject.toml'
17+
- '.github/workflows/conformance.yml' # This workflow
18+
- '.github/actions/setup-ollama/action.yml'
19+
- '.github/actions/setup-test-environment/action.yml'
20+
- '.github/actions/run-and-record-tests/action.yml'
21+
schedule:
22+
# If changing the cron schedule, update the provider in the test-matrix job
23+
- cron: '0 0 * * *' # (test latest client) Daily at 12 AM UTC
24+
- cron: '1 0 * * 0' # (test vllm) Weekly on Sunday at 1 AM UTC
25+
26+
concurrency:
27+
# Skip concurrency for pushes to main - each commit should be tested independently
28+
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}
29+
cancel-in-progress: true
30+
31+
jobs:
32+
check-schema-compatibility:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout PR Code
36+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
37+
38+
- name: Checkout Base Branch
39+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
40+
with:
41+
ref: ${{ github.event.pull_request.base.ref }}
42+
path: 'base'
43+
44+
# does this include yq?
45+
- name: Install dependencies
46+
uses: ./.github/actions/setup-runner
47+
48+
- name: Filter Schemas
49+
run: |
50+
# Define the filter to match all paths that start with the specified prefixes.
51+
FILTER_CONDITION='
52+
.paths |= with_entries(select(
53+
(.key | startswith("/v1/inference")) or
54+
(.key | startswith("/v1/vector-io")) or
55+
(.key | startswith("/v1/vector-dbs")) or
56+
(.key | startswith("/v1/openai/v1/responses")) or
57+
(.key | startswith("/v1/openai/chat"))
58+
))
59+
'
60+
61+
# Filter the base and revision schema files
62+
yq eval "$FILTER_CONDITION" base/docs/_static/llama-stack-spec.yaml > base-filtered.yaml
63+
yq eval "$FILTER_CONDITION" docs/_static/llama-stack-spec.yaml > revision-filtered.yaml
64+
65+
- name: Run OpenAPI Diff on Filtered Schemas
66+
uses: OpenAPITools/openapi-diff-action@c71c94cb937760c067818cdc5e14b3a1115fb840 # v2.1.2
67+
with:
68+
base: 'base-filtered.yaml'
69+
revision: 'revision-filtered.yaml'
70+
fail-on-incompatible: true

0 commit comments

Comments
 (0)