docs: API conformance test update

This commit is contained in:
Alexey Rybak 2025-10-01 08:38:43 -07:00
parent e474aa6558
commit 2b6e431927

View file

@ -94,57 +94,40 @@ jobs:
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq sudo chmod +x /usr/local/bin/yq
# Stitch together complete API specs for conformance testing # Verify API specs exist for conformance testing
# This handles cases where APIs have been split across multiple files - name: Check API Specs
- name: Create Complete API Specs for Comparison
run: | run: |
# Function to create complete spec from split files or use existing monolithic spec echo "Checking for API specification files..."
create_complete_spec() {
local source_dir="$1"
local output_file="$2"
# Check if split specs exist # Check current branch
if [ -f "${source_dir}/docs/static/stable-llama-stack-spec.yaml" ] && if [ -f "docs/static/stable-llama-stack-spec.yaml" ]; then
[ -f "${source_dir}/docs/static/experimental-llama-stack-spec.yaml" ] && echo "✓ Found stable API spec in current branch"
[ -f "${source_dir}/docs/static/deprecated-llama-stack-spec.yaml" ]; then CURRENT_SPEC="docs/static/stable-llama-stack-spec.yaml"
echo "Found split specs in ${source_dir}, stitching together..." elif [ -f "docs/static/llama-stack-spec.yaml" ]; then
echo "✓ Found monolithic API spec in current branch"
# Start with stable spec as base CURRENT_SPEC="docs/static/llama-stack-spec.yaml"
cp "${source_dir}/docs/static/stable-llama-stack-spec.yaml" "${output_file}"
# Merge paths from experimental spec
if [ -s "${source_dir}/docs/static/experimental-llama-stack-spec.yaml" ]; then
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' \
"${output_file}" \
"${source_dir}/docs/static/experimental-llama-stack-spec.yaml" > "${output_file}.tmp"
mv "${output_file}.tmp" "${output_file}"
fi
# Merge paths from deprecated spec
if [ -s "${source_dir}/docs/static/deprecated-llama-stack-spec.yaml" ]; then
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' \
"${output_file}" \
"${source_dir}/docs/static/deprecated-llama-stack-spec.yaml" > "${output_file}.tmp"
mv "${output_file}.tmp" "${output_file}"
fi
elif [ -f "${source_dir}/docs/static/llama-stack-spec.yaml" ]; then
echo "Using monolithic spec from ${source_dir}..."
cp "${source_dir}/docs/static/llama-stack-spec.yaml" "${output_file}"
else else
echo "ERROR: No API specs found in ${source_dir}" echo "❌ No API specs found in current branch"
ls -la "${source_dir}/docs/static/" || true
exit 1 exit 1
fi fi
}
# Create complete specs for both base and current # Check base branch
create_complete_spec "base" "base-complete-spec.yaml" if [ -f "base/docs/static/stable-llama-stack-spec.yaml" ]; then
create_complete_spec "." "current-complete-spec.yaml" echo "✓ Found stable API spec in base branch"
BASE_SPEC="base/docs/static/stable-llama-stack-spec.yaml"
elif [ -f "base/docs/static/llama-stack-spec.yaml" ]; then
echo "✓ Found monolithic API spec in base branch"
BASE_SPEC="base/docs/static/llama-stack-spec.yaml"
else
echo "❌ No API specs found in base branch"
exit 1
fi
echo "Generated complete specs for comparison:" # Export for next step
echo "Base spec size: $(wc -l < base-complete-spec.yaml) lines" echo "BASE_SPEC=${BASE_SPEC}" >> $GITHUB_ENV
echo "Current spec size: $(wc -l < current-complete-spec.yaml) lines" echo "CURRENT_SPEC=${CURRENT_SPEC}" >> $GITHUB_ENV
echo "Will compare: ${BASE_SPEC} -> ${CURRENT_SPEC}"
# Run oasdiff to detect breaking changes in the API specification # Run oasdiff to detect breaking changes in the API specification
# This step will fail if incompatible changes are detected, preventing breaking changes from being merged # This step will fail if incompatible changes are detected, preventing breaking changes from being merged
@ -157,4 +140,4 @@ jobs:
- name: Report skip reason - name: Report skip reason
if: steps.skip-check.outputs.skip == 'true' if: steps.skip-check.outputs.skip == 'true'
run: | run: |
echo "Conformance test skipped due to breaking change indicator" oasdiff breaking --fail-on ERR $BASE_SPEC $CURRENT_SPEC --match-path '^/v1/'