Skip to content

Commit e138a1e

Browse files
refactor(pricing): share the GITHUB_OUTPUT report helper between lock scripts
Both update scripts carried a byte-identical `report` definition, so any change to the GITHUB_OUTPUT format had to be made twice. Move it to a `.github/scripts/pricing-lock.nu` module both scripts import. Nushell resolves relative `use` paths against the importing file, so the module loads regardless of the workflow's working directory. Co-authored-by: Codesmith <[email protected]>
1 parent 30b629d commit e138a1e

3 files changed

Lines changed: 16 additions & 22 deletions

File tree

‎.github/scripts/pricing-lock.nu‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Shared helpers for the pricing lock update scripts driven by update-pricing.yaml.
2+
3+
# Hand the workflow both the verdict and the paths to commit, so the file list
4+
# lives in one place instead of being repeated in the workflow.
5+
export def report [result: record]: nothing -> nothing {
6+
[
7+
$"changed=($result.changed)"
8+
$"paths=($result.paths | str join ' ')"
9+
]
10+
| each {|line| $"($line)(char nl)" | save --append $env.GITHUB_OUTPUT }
11+
| ignore
12+
}

‎.github/scripts/update-litellm-lock.nu‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env nix
22
#! nix shell --inputs-from ../.. nixpkgs#nushell nixpkgs#git --command nu
33

4+
use ./pricing-lock.nu report
5+
46
# Bump the pinned LiteLLM input and report whether it moved the pricing JSON that
57
# the build embeds, so the workflow can skip validating lock-only churn.
68
def main [] {
@@ -27,14 +29,3 @@ def locked-pricing []: nothing -> record {
2729
let rev = open --raw flake.lock | from json | get nodes.litellm.locked.rev
2830
http get $"https://raw.githubusercontent.com/BerriAI/litellm/($rev)/model_prices_and_context_window.json"
2931
}
30-
31-
# Hand the workflow both the verdict and the paths to commit, so the file list
32-
# lives in one place instead of being repeated in the workflow.
33-
def report [result: record]: nothing -> nothing {
34-
[
35-
$"changed=($result.changed)"
36-
$"paths=($result.paths | str join ' ')"
37-
]
38-
| each {|line| $"($line)(char nl)" | save --append $env.GITHUB_OUTPUT }
39-
| ignore
40-
}

‎.github/scripts/update-models-dev-lock.nu‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env nix
22
#! nix shell --inputs-from ../.. nixpkgs#nushell nixpkgs#git --command nu
33

4+
use ./pricing-lock.nu report
5+
46
const SNAPSHOTS = [
57
'rust/crates/ccusage-core/src/models-dev-pricing.json'
68
'rust/adapters/codex/src/codex-auto-review-fallbacks.json'
@@ -44,14 +46,3 @@ def main [] {
4446
def dirty [...paths: string]: nothing -> bool {
4547
(^git diff --quiet -- ...$paths | complete).exit_code != 0
4648
}
47-
48-
# Hand the workflow both the verdict and the paths to commit, so the file list
49-
# lives in one place instead of being repeated in the workflow.
50-
def report [result: record]: nothing -> nothing {
51-
[
52-
$"changed=($result.changed)"
53-
$"paths=($result.paths | str join ' ')"
54-
]
55-
| each {|line| $"($line)(char nl)" | save --append $env.GITHUB_OUTPUT }
56-
| ignore
57-
}

0 commit comments

Comments
 (0)