Skip to content

Commit 82a0c49

Browse files
juntaoclaude
andcommitted
Fix mlx-c cache key: use step output instead of shell expansion
GitHub Actions `with:` blocks do not evaluate shell expressions like $(brew info ...). The cache key was passed as a literal string containing the $() expression, which failed with "cannot contain commas". Fix: compute the MLX version in a prior step, export it via GITHUB_OUTPUT, and reference it as ${{ steps.mlx-version.outputs.version }}. Affects ci.yml and integration-test.yml (same bug in both). Signed-off-by: Michael Yuan <michael@secondstate.io> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ac6d84f commit 82a0c49

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,12 @@ jobs:
231231
# Install the MLX C++ library and its headers via Homebrew.
232232
# mlx-c (C bindings) is not in Homebrew, so we build it from source below.
233233
- name: Install MLX C++ via Homebrew
234-
run: brew install mlx
234+
id: mlx-version
235+
run: |
236+
brew install mlx
237+
MLX_VER=$(brew info --json mlx | python3 -c "import sys,json; print(json.load(sys.stdin)[0]['versions']['stable'])")
238+
echo "version=$MLX_VER" >> "$GITHUB_OUTPUT"
239+
echo "MLX version: $MLX_VER"
235240
236241
# Cache mlx-c to avoid rebuilding on every run.
237242
# Cache key includes the mlx version so an mlx upgrade triggers a rebuild.
@@ -240,7 +245,7 @@ jobs:
240245
uses: actions/cache@v4
241246
with:
242247
path: /opt/mlx
243-
key: mlxc-${{ runner.os }}-$(brew info --json mlx | python3 -c "import sys,json; print(json.load(sys.stdin)[0]['versions']['stable'])")
248+
key: mlxc-${{ runner.os }}-${{ steps.mlx-version.outputs.version }}
244249
restore-keys: mlxc-${{ runner.os }}-
245250

246251
- name: Build and install mlx-c from source

.github/workflows/integration-test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,19 @@ jobs:
324324
restore-keys: macos-arm64-mlx-integ-cargo-
325325

326326
- name: Install MLX via Homebrew
327-
run: brew install mlx
327+
id: mlx-version
328+
run: |
329+
brew install mlx
330+
MLX_VER=$(brew info --json mlx | python3 -c "import sys,json; print(json.load(sys.stdin)[0]['versions']['stable'])")
331+
echo "version=$MLX_VER" >> "$GITHUB_OUTPUT"
332+
echo "MLX version: $MLX_VER"
328333
329334
- name: Cache mlx-c
330335
id: cache-mlxc
331336
uses: actions/cache@v4
332337
with:
333338
path: /opt/mlx
334-
key: mlxc-${{ runner.os }}-integ-$(brew info --json mlx | python3 -c "import sys,json; print(json.load(sys.stdin)[0]['versions']['stable'])")
339+
key: mlxc-${{ runner.os }}-integ-${{ steps.mlx-version.outputs.version }}
335340
restore-keys: mlxc-${{ runner.os }}-integ-
336341

337342
- name: Build mlx-c (if not cached)

0 commit comments

Comments
 (0)