Repository navigation
ci(pricing): refuse to publish when bundled prices are behind LiteLLM #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Pricing freshness check | ||
| description: >- | ||
| Fails when a price bundled in model_prices_and_context_window.json is behind | ||
| LiteLLM, or when a bundle copy differs from the canonical file. Requires pnpm | ||
| dependencies to be installed and Bun to be available. Missing LiteLLM data | ||
| only warns, so an unreachable host cannot block a release by itself. | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Check bundled prices against LiteLLM | ||
| shell: bash | ||
| run: | | ||
| log="$RUNNER_TEMP/pricing-check.log" | ||
| code=0 | ||
| pnpm sync-pricing --check > "$log" 2>&1 || code=$? | ||
| cat "$log" | ||
| case "$code" in | ||
| 0) verdict="Bundled prices are up to date with LiteLLM." ;; | ||
| 1) verdict="Pricing check failed: bundled prices are behind LiteLLM, or a bundle copy differs from the canonical file. Details below." ;; | ||
| 2) verdict="LiteLLM data was not usable, bundled prices were not verified." ;; | ||
| *) verdict="The pricing check did not run (exit code $code). This is a tooling failure, not a pricing result." ;; | ||
| esac | ||
| { | ||
| echo "### Pricing freshness" | ||
| echo | ||
| echo "$verdict" | ||
| echo | ||
| echo '```' | ||
| grep '^\[sync-pricing\]' "$log" || true | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| if [ "$code" -eq 2 ]; then | ||
| echo "::warning::$verdict" | ||
| exit 0 | ||
| fi | ||
| if [ "$code" -ne 0 ]; then | ||
| echo "::error::$verdict" | ||
| exit 1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: pricing-check | ||
|
|
||
| # Runs the same check the release workflow applies before publishing, so it | ||
| # can be exercised on pull requests and on demand instead of first at release | ||
| # time. A pull request that syncs the bundle should show this check green. | ||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: | ||
| - ".github/actions/pricing-check/**" | ||
| - ".github/workflows/pricing-check.yaml" | ||
| - ".github/workflows/release.yaml" | ||
| - "packages/internal/model_prices_and_context_window.json" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include both bundle copies in the PR path filter.
|
||
| - "packages/internal/src/pricing.ts" | ||
| - "packages/internal/src/pricing-fetch-utils.ts" | ||
| - "packages/internal/src/remote-pricing.ts" | ||
| - "scripts/sync-pricing.ts" | ||
|
|
||
| jobs: | ||
| pricing-check: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 | ||
| - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: pnpm install --no-frozen-lockfile | ||
| - uses: ./.github/actions/pricing-check | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check bundle copies before accepting exit code 2.
If a bundle copy differs and LiteLLM cannot be fetched,
sync-pricing.tsexits 2 before it checks the copies. An undersized dataset also bypasses the comparison. This branch then permits publishing despite the required copy-consistency failure. (raw.githubusercontent.com)Run the local copy checks before the remote-data early exits. Keep warning-only success when remote data is unavailable and the copies match.