mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-21 01:52:25 +00:00
feat(api): ensure StackRunConfig
StackRunConfig is part of our public API, ensure stability of this datatype using a pytest snapshot test. If the pydantic model changes, it will fail. A snapshot can be re-generated via `@github-actions regenerate snapshots` by a code owner. The API conformance test will then re-run and pass. Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
parent
0dbf79c328
commit
af94606828
14 changed files with 2427 additions and 104 deletions
148
.github/workflows/regenerate-snapshot-trigger.yml
vendored
Normal file
148
.github/workflows/regenerate-snapshot-trigger.yml
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
name: Run Snapshot Regeneration
|
||||
|
||||
run-name: Run Snapshot Regeneration via PR comment
|
||||
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
pr_number:
|
||||
required: true
|
||||
type: string
|
||||
description: 'PR number'
|
||||
pr_head_ref:
|
||||
required: true
|
||||
type: string
|
||||
description: 'PR head branch ref'
|
||||
pr_head_sha:
|
||||
required: true
|
||||
type: string
|
||||
description: 'PR head SHA'
|
||||
pr_head_repo:
|
||||
required: true
|
||||
type: string
|
||||
description: 'PR head repository full name'
|
||||
is_fork:
|
||||
required: true
|
||||
type: string
|
||||
description: 'Whether PR is from a fork (true/false)'
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Comment starting
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: ${{ inputs.pr_number }},
|
||||
body: `⏳ Regenerating snapshots for PR #${{ inputs.pr_number }}...`
|
||||
});
|
||||
|
||||
- name: Checkout PR branch (same-repo)
|
||||
if: inputs.is_fork == 'false'
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
ref: ${{ inputs.pr_head_ref }}
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Checkout PR branch (fork)
|
||||
if: inputs.is_fork == 'true'
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
repository: ${{ inputs.pr_head_repo }}
|
||||
ref: ${{ inputs.pr_head_ref }}
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Verify checkout
|
||||
run: |
|
||||
echo "Current SHA: $(git rev-parse HEAD)"
|
||||
echo "Expected SHA: ${{ inputs.pr_head_sha }}"
|
||||
if [[ "$(git rev-parse HEAD)" != "${{ inputs.pr_head_sha }}" ]]; then
|
||||
echo "::error::Checked out SHA does not match expected SHA"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/setup-runner
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Run snapshot test with regeneration
|
||||
id: snapshot_test
|
||||
run: |
|
||||
uv run --no-sync ./scripts/snapshot-test.sh tests/api/test_pydantic_models.py true
|
||||
|
||||
- name: Check for changes
|
||||
id: changes
|
||||
run: |
|
||||
if ! git diff --exit-code tests/api/snapshots/ || [ -n "$(git ls-files --others --exclude-standard tests/api/snapshots/)" ]; then
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
echo "Changes detected in snapshots"
|
||||
else
|
||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||
echo "No snapshot changes"
|
||||
fi
|
||||
|
||||
- name: Commit and push changes
|
||||
if: steps.changes.outputs.has_changes == 'true'
|
||||
run: |
|
||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
|
||||
git add tests/api/snapshots/
|
||||
git commit -m "chore: regenerate snapshots for schema changes
|
||||
|
||||
🤖 Applied by @github-actions bot via snapshot-regenerate workflow"
|
||||
|
||||
# Push changes
|
||||
git push origin HEAD:${{ inputs.pr_head_ref }}
|
||||
|
||||
- name: Comment success with changes
|
||||
if: steps.changes.outputs.has_changes == 'true'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: ${{ inputs.pr_number }},
|
||||
body: `✅ Snapshot regeneration completed successfully!\n\n🔧 Updated snapshots have been committed and pushed to the PR branch.`
|
||||
});
|
||||
|
||||
- name: Comment success without changes
|
||||
if: steps.changes.outputs.has_changes == 'false'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: ${{ inputs.pr_number }},
|
||||
body: `✅ Snapshot test passed!\n\n✨ No changes needed - snapshots are already up to date.`
|
||||
});
|
||||
|
||||
- name: Comment failure
|
||||
if: failure()
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: ${{ inputs.pr_number }},
|
||||
body: `❌ Snapshot regeneration workflow failed!\n\nPlease check the [workflow logs](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for details.`
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue