77
88permissions : {}
99
10+ # Both jobs push to main, so a manual dispatch landing on top of the hourly
11+ # schedule would otherwise race the other run's push.
12+ concurrency :
13+ group : update-pricing
14+ cancel-in-progress : false
15+
1016jobs :
1117 update-pricing :
1218 runs-on : blacksmith-32vcpu-ubuntu-2404
19+ timeout-minutes : 60
1320 permissions :
1421 contents : write
15- pull-requests : write
1622 steps :
1723 - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1824 with :
25+ fetch-depth : 0
1926 persist-credentials : false
2027 - uses : ./.github/actions/setup-nix-cache
2128 - name : Capture current LiteLLM pricing JSON
@@ -28,64 +35,61 @@ jobs:
2835 run : |
2936 nix flake update litellm
3037 - name : Skip lock-only LiteLLM updates
38+ id : litellm
3139 run : |
3240 rev="$(jq -r '.nodes.litellm.locked.rev' flake.lock)"
3341 curl --fail --location --silent --show-error \
3442 "https://raw.githubusercontent.com/BerriAI/litellm/${rev}/model_prices_and_context_window.json" \
3543 --output /tmp/litellm-pricing-after.json
3644
3745 if cmp --silent /tmp/litellm-pricing-before.json /tmp/litellm-pricing-after.json; then
38- echo "LiteLLM pricing JSON is unchanged; skipping PR ."
46+ echo "LiteLLM pricing JSON is unchanged; skipping the update ."
3947 git checkout -- flake.lock
4048 fi
41- - name : Validate updated pricing snapshot
42- run : |
43- if git diff --quiet; then
44- echo "Pricing snapshot is already up to date."
45- exit 0
46- fi
47- nix develop --command just check
48- - name : Create pull request
49- env :
50- GH_TOKEN : ${{ github.token }}
51- run : |
52- if git diff --quiet; then
53- echo "Pricing snapshot is already up to date."
54- exit 0
55- fi
56-
57- git config user.name "github-actions[bot]"
58- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
59- gh auth setup-git
60-
61- branch="automation/litellm-pricing"
62- git checkout -B "$branch"
63- git add flake.lock
64- git commit -m "chore(pricing): update LiteLLM snapshot"
65- git push --force origin "$branch"
6649
67- body="$(printf '%s\n' \
68- 'Updates the locked LiteLLM pricing input used by Nix builds.' \
69- '' \
70- 'Validation:' \
71- '- just check')"
72-
73- if gh pr view "$branch" >/dev/null 2>&1; then
74- printf '%s\n' "$body" | gh pr edit "$branch" --title "chore(pricing): update LiteLLM snapshot" --body-file -
50+ if git diff --quiet; then
51+ echo 'Pricing snapshot is already up to date.'
52+ echo 'changed=false' >> "$GITHUB_OUTPUT"
7553 else
76- printf '%s\n' "$body" | gh pr create --base main --head "$branch" --title "chore(pricing): update LiteLLM snapshot" --body-file -
54+ echo 'changed=true' >> "$GITHUB_OUTPUT"
7755 fi
56+ # The push below cannot trigger ci.yaml, so the checks that would have run
57+ # on a pull request run here instead. Each leg no-ops when the snapshot was
58+ # already up to date.
59+ - parallel :
60+ - name : Run nix flake check
61+ run : |
62+ git diff --quiet && exit 0
63+ nix flake check --print-build-logs
64+ - name : Run Rust tests
65+ run : |
66+ git diff --quiet && exit 0
67+ nix build .#ccusage-tests --no-link --print-build-logs
68+ - name : JS test
69+ run : |
70+ git diff --quiet && exit 0
71+ nix profile install --inputs-from . nixpkgs#pnpm nixpkgs#nodejs nixpkgs#just
72+ pnpm install --frozen-lockfile
73+ mkdir -p "$HOME/.claude/projects"
74+ mkdir -p "$HOME/.config/claude/projects"
75+ just test-node
76+ - uses : ./.github/actions/commit-and-push-main
77+ if : steps.litellm.outputs.changed == 'true'
78+ with :
79+ message : ' chore(pricing): update LiteLLM snapshot'
80+ paths : flake.lock
7881
7982 update-models-dev-pricing :
8083 needs : update-pricing
8184 if : ${{ always() }}
8285 runs-on : blacksmith-32vcpu-ubuntu-2404
86+ timeout-minutes : 60
8387 permissions :
8488 contents : write
85- pull-requests : write
8689 steps :
8790 - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
8891 with :
92+ fetch-depth : 0
8993 persist-credentials : false
9094 - uses : ./.github/actions/setup-nix-cache
9195 - name : Update models.dev input
@@ -95,47 +99,43 @@ jobs:
9599 run : |
96100 nix develop --command just gen-models-dev-pricing
97101 - name : Skip lock-only models.dev updates
102+ id : models-dev
98103 run : |
99104 # Only the compacted snapshot affects the build; if a models.dev bump
100105 # leaves embedded pricing unchanged, drop the lock-only churn.
101106 if git diff --quiet -- rust/crates/ccusage-core/src/models-dev-pricing.json rust/crates/ccusage-adapter-codex/src/codex-auto-review-fallbacks.json; then
102- echo "models.dev pricing snapshots are unchanged; skipping PR ."
107+ echo "models.dev pricing snapshots are unchanged; skipping the update ."
103108 git checkout -- flake.lock rust/crates/ccusage-core/src/models-dev-pricing.json rust/crates/ccusage-adapter-codex/src/codex-auto-review-fallbacks.json
104109 fi
105- - name : Validate updated pricing snapshot
106- run : |
107- if git diff --quiet; then
108- echo "Pricing snapshot is already up to date."
109- exit 0
110- fi
111- nix develop --command just check
112- - name : Create pull request
113- env :
114- GH_TOKEN : ${{ github.token }}
115- run : |
116- if git diff --quiet; then
117- echo "Pricing snapshot is already up to date."
118- exit 0
119- fi
120110
121- git config user.name "github-actions[bot]"
122- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
123- gh auth setup-git
124-
125- branch="automation/models-dev-pricing"
126- git checkout -B "$branch"
127- git add flake.lock rust/crates/ccusage-core/src/models-dev-pricing.json rust/crates/ccusage-adapter-codex/src/codex-auto-review-fallbacks.json
128- git commit -m "chore(pricing): update models.dev snapshot"
129- git push --force origin "$branch"
130-
131- body="$(printf '%s\n' \
132- 'Updates the pinned models.dev input and its committed pricing snapshot.' \
133- '' \
134- 'Validation:' \
135- '- just check')"
136-
137- if gh pr view "$branch" >/dev/null 2>&1; then
138- printf '%s\n' "$body" | gh pr edit "$branch" --title "chore(pricing): update models.dev snapshot" --body-file -
111+ if git diff --quiet; then
112+ echo 'Pricing snapshot is already up to date.'
113+ echo 'changed=false' >> "$GITHUB_OUTPUT"
139114 else
140- printf '%s\n' "$body" | gh pr create --base main --head "$branch" --title "chore(pricing): update models.dev snapshot" --body-file -
115+ echo 'changed=true' >> "$GITHUB_OUTPUT"
141116 fi
117+ - parallel :
118+ - name : Run nix flake check
119+ run : |
120+ git diff --quiet && exit 0
121+ nix flake check --print-build-logs
122+ - name : Run Rust tests
123+ run : |
124+ git diff --quiet && exit 0
125+ nix build .#ccusage-tests --no-link --print-build-logs
126+ - name : JS test
127+ run : |
128+ git diff --quiet && exit 0
129+ nix profile install --inputs-from . nixpkgs#pnpm nixpkgs#nodejs nixpkgs#just
130+ pnpm install --frozen-lockfile
131+ mkdir -p "$HOME/.claude/projects"
132+ mkdir -p "$HOME/.config/claude/projects"
133+ just test-node
134+ - uses : ./.github/actions/commit-and-push-main
135+ if : steps.models-dev.outputs.changed == 'true'
136+ with :
137+ message : ' chore(pricing): update models.dev snapshot'
138+ paths : >-
139+ flake.lock
140+ rust/crates/ccusage-core/src/models-dev-pricing.json
141+ rust/crates/ccusage-adapter-codex/src/codex-auto-review-fallbacks.json
0 commit comments