Skip to content

Commit 5a528ef

Browse files
committed
ci(onnx): stage the LICENSE, and build a cache key that is not empty
Two review findings, both real, and the second is a bug this repo already had. **The archive had no LICENSE, so adopting it would have failed.** `fetch-onnxruntime.mjs:304` throws `LICENSE not found inside …` and then reads the file to confirm the library really is MIT — "asset names are not evidence". The staged archive carried only the dylib and headers, so it would have passed its SHA-256 and then died at vendoring, which is the worst possible place to discover it. `LICENSE` and `ThirdPartyNotices.txt` are now copied, matching what upstream ships. **`${{ env.ImageOS }}` evaluates to the empty string.** The `env` expression context carries only what a workflow, job or step `env:` block defined; `ImageOS`/`ImageVersion` are set by the runner into its own environment, so the expression silently disappears and the cache key loses that component. The proof is this repository's own cache list. `build-whisper-stt.yml` builds its key the same way, and the stored keys read: whisper-stt-build-darwin-arm64---2ca5d2c7… whisper-stt-build-linux-x64---2ca5d2c7… Three hyphens where two values should be. That workflow's comment explains at length that scoping the key to the image version "auto-busts it on every toolchain roll" — and it never has, on any platform, since the day it was written. Filed separately; this commit only fixes the copy of the mistake it was about to add. Here the values are read in a `run:` step, where they are ordinary shell variables, and passed through `GITHUB_OUTPUT`.
1 parent c0a71fa commit 5a528ef

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

‎.github/workflows/build-onnxruntime-macos.yml‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,31 @@ jobs:
8484
submodules: recursive
8585
fetch-depth: 1
8686

87+
- name: Read the runner image
88+
id: image
89+
# `${{ env.ImageOS }}` DOES NOT WORK, and it fails silently. The `env`
90+
# expression context only carries what a workflow, job or step `env:` block
91+
# defined; `ImageOS`/`ImageVersion` are set by the runner in its own
92+
# environment, so the expression evaluates to the empty string and the cache
93+
# key simply loses that component. The evidence is in this repo's own cache
94+
# list: `build-whisper-stt.yml` builds its key the same way and the stored
95+
# keys read `whisper-stt-build-darwin-arm64---<hash>` — three hyphens, both
96+
# values empty. Reading them in a `run:` step, where they are ordinary shell
97+
# variables, is what actually works.
98+
run: |
99+
set -euo pipefail
100+
echo "tag=${ImageOS:-unknown}-${ImageVersion:-unknown}" >> "$GITHUB_OUTPUT"
101+
echo "Runner image: ${ImageOS:-unknown} ${ImageVersion:-unknown}"
102+
87103
- name: Cache the CMake build tree
88104
uses: actions/cache@v6
89105
with:
90106
path: onnxruntime-build
91-
# Keyed on the version, the floor and the runner image: CMake bakes
92-
# absolute SDK paths into the tree, so a toolchain roll must bust it.
93-
key: ort-${{ steps.pin.outputs.version }}-${{ steps.floor.outputs.floor }}-${{ env.ImageOS }}-${{ env.ImageVersion }}
107+
# Keyed on the version, the floor and the runner image. The image matters:
108+
# CMake bakes absolute SDK paths into the tree, so when GitHub rolls Xcode a
109+
# restored tree fails on paths that no longer exist. Scoping the key to the
110+
# image busts it automatically on every roll.
111+
key: ort-${{ steps.pin.outputs.version }}-${{ steps.floor.outputs.floor }}-${{ steps.image.outputs.tag }}
94112

95113
- name: Configure
96114
# Driven straight at CMake rather than through upstream's `build.sh`.
@@ -155,6 +173,14 @@ jobs:
155173
ln -s "libonnxruntime.${V}.dylib" "stage/${DIR}/lib/libonnxruntime.dylib"
156174
ln -s "libonnxruntime.${V}.dylib" "stage/${DIR}/lib/libonnxruntime.1.dylib"
157175
cp onnxruntime-src/include/onnxruntime/core/session/*.h "stage/${DIR}/include/" || true
176+
# NOT optional. `fetch-onnxruntime.mjs` refuses an archive with no LICENSE
177+
# (`LICENSE not found inside …`) and then reads it to confirm the library
178+
# really is MIT — "asset names are not evidence". Without this the archive
179+
# would pass its SHA-256 and fail at vendoring, which is the worst place to
180+
# find out. `ThirdPartyNotices.txt` rides along because upstream ships it and
181+
# THIRD-PARTY-NOTICES.md is what carries the attribution.
182+
cp onnxruntime-src/LICENSE "stage/${DIR}/LICENSE"
183+
cp onnxruntime-src/ThirdPartyNotices.txt "stage/${DIR}/ThirdPartyNotices.txt"
158184
tar -czf "${DIR}.tgz" -C stage "${DIR}"
159185
shasum -a 256 "${DIR}.tgz"
160186

0 commit comments

Comments
 (0)