|
40 | 40 | ref: ${{ github.event.pull_request.base.ref }} |
41 | 41 | path: 'base' |
42 | 42 |
|
| 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 | + |
43 | 52 | # Cache oasdiff to avoid checksum failures and speed up builds |
44 | 53 | - name: Cache oasdiff |
45 | 54 | id: cache-oasdiff |
|
55 | 64 | curl -fsSL https://raw.githubusercontent.com/oasdiff/oasdiff/main/install.sh | sh |
56 | 65 | cp /usr/local/bin/oasdiff ~/oasdiff |
57 | 66 |
|
| 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 | +
|
58 | 73 | # Setup cached oasdiff |
59 | 74 | - name: Setup cached oasdiff |
60 | 75 | if: steps.cache-oasdiff.outputs.cache-hit == 'true' |
|
69 | 84 | oasdiff breaking --fail-on ERR base/docs/static/llama-stack-spec.yaml docs/static/llama-stack-spec.yaml --match-path '^/v1/openai/v1' \ |
70 | 85 | --match-path '^/v1/vector-io' \ |
71 | 86 | --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