Skip to content

Commit 7af8998

Browse files
committed
test: introduce api conformance test
this test runs on each PR and uses a new conformance workflow 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. this workflow uses `oasdiff` to identify breaking changes for paths we want to ensure comptability for. specifically this is using `oasdiff breaking` with `--match-path` which only checks breaking changes for the specified paths. 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 5c873d5 commit 7af8998

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-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: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# API Conformance Tests
2+
# This workflow ensures that API changes maintain backward compatibility and don't break existing integrations
3+
# It runs schema validation and OpenAPI diff checks to catch breaking changes early
4+
5+
name: API Conformance Tests
6+
7+
run-name: Run the API Conformance test suite on the changes.
8+
9+
on:
10+
push:
11+
branches: [ main ]
12+
pull_request:
13+
branches: [ main ]
14+
types: [opened, synchronize, reopened]
15+
paths:
16+
- 'llama_stack/**'
17+
- '!llama_stack/ui/**'
18+
- 'tests/**'
19+
- 'uv.lock'
20+
- 'pyproject.toml'
21+
- '.github/workflows/conformance.yml' # This workflow itself
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}
25+
# Cancel in-progress runs when new commits are pushed to avoid wasting CI resources
26+
cancel-in-progress: true
27+
28+
jobs:
29+
# Job to check if API schema changes maintain backward compatibility
30+
check-schema-compatibility:
31+
runs-on: ubuntu-latest
32+
steps:
33+
# Using specific version 4.1.7 because 5.0.0 fails when trying to run this locally using `act`
34+
# This ensures consistent behavior between local testing and CI
35+
- name: Checkout PR Code
36+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
37+
38+
# Checkout the base branch to compare against (usually main)
39+
# This allows us to diff the current changes against the previous state
40+
- name: Checkout Base Branch
41+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
42+
with:
43+
ref: ${{ github.event.pull_request.base.ref }}
44+
path: 'base'
45+
46+
# Build a custom container that includes both openapi-diff and yq tools
47+
# The default openapi-diff container doesn't have yq, which we need for advanced YAML filtering
48+
- name: Install oasdiff
49+
run: |
50+
curl -fsSL https://raw.githubusercontent.com/oasdiff/oasdiff/main/install.sh | sh
51+
52+
# Run the OpenAPI diff tool to detect breaking changes in the API specification
53+
# This step will fail if incompatible changes are detected, preventing breaking changes from being merged
54+
- name: Run OpenAPI Breaking Change Diff
55+
run: |
56+
oasdiff breaking --fail-on ERR base/docs/_static/llama-stack-spec.yaml docs/_static/llama-stack-spec.yaml --match-path '^/v1/openai/v1' \
57+
--match-path '^/v1/vector-io' \
58+
--match-path '^/v1/vector-dbs'

0 commit comments

Comments
 (0)