Skip to content

Commit 79bed32

Browse files
committed
chore(ci): create sfw-free shims for all supported package managers
Move the pnpm shim from inline workflow blocks into the shared install action. Create shims for all sfw-free supported package managers (npm, yarn, pnpm, pip, uv, cargo) using resolved absolute paths to avoid recursive lookup. Shims are added to GITHUB_PATH so they persist across all job steps. Includes Windows .cmd shim support.
1 parent 3fef6f4 commit 79bed32

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

.github/actions/install/action.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ runs:
4040
fi
4141
echo "SFW_BIN=$SFW_BIN" >> "${GITHUB_ENV:-/dev/null}"
4242
43+
- name: Create sfw shims
44+
shell: bash
45+
run: | # zizmor: ignore[github-env]
46+
SHIM_DIR="${RUNNER_TEMP:-/tmp}/sfw-shim"
47+
rm -rf "$SHIM_DIR"
48+
mkdir -p "$SHIM_DIR"
49+
IS_WINDOWS=false
50+
[[ "$OSTYPE" == msys* || "$OSTYPE" == cygwin* ]] && IS_WINDOWS=true
51+
CLEAN_PATH="${PATH//$SHIM_DIR:/}"
52+
for CMD in npm yarn pnpm pip uv cargo; do
53+
REAL="$(PATH="$CLEAN_PATH" which "$CMD" 2>/dev/null || true)"
54+
[ -z "$REAL" ] && continue
55+
printf '#!/bin/bash\nexport PATH="%s"\nexec "%s" "%s" "$@"\n' "$CLEAN_PATH" "$SFW_BIN" "$REAL" > "$SHIM_DIR/$CMD"
56+
chmod +x "$SHIM_DIR/$CMD"
57+
if $IS_WINDOWS; then
58+
printf '@echo off\r\nset "PATH=%s"\r\n"%s" "%s" %%*\r\n' "$CLEAN_PATH" "$SFW_BIN" "$REAL" > "$SHIM_DIR/$CMD.cmd"
59+
fi
60+
done
61+
echo "$SHIM_DIR" >> "${GITHUB_PATH:-/dev/null}"
62+
echo "SFW_SHIM_DIR=$SHIM_DIR" >> "${GITHUB_ENV:-/dev/null}"
63+
4364
- name: Install dependencies
4465
shell: bash
4566
working-directory: ${{ inputs.working-directory }}

.github/workflows/_local-not-for-reuse-ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ jobs:
4848
- name: Build registry
4949
shell: bash
5050
run: |
51-
alias pnpm="$SFW_BIN pnpm"
5251
pnpm run build
5352
5453
- name: Run npm package tests
5554
shell: bash
5655
run: |
57-
alias pnpm="$SFW_BIN pnpm"
5856
node scripts/npm/test-npm-packages.mjs

.github/workflows/_local-not-for-reuse-weekly-update.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
id: check
3131
shell: bash
3232
run: |
33-
alias pnpm="$SFW_BIN pnpm"
3433
echo "Checking for npm package updates..."
3534
HAS_UPDATES=false
3635
NPM_UPDATES=$(pnpm outdated 2>/dev/null || true)
@@ -74,13 +73,6 @@ jobs:
7473
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
7574
GITHUB_ACTIONS: 'true'
7675
run: |
77-
if [ -n "$SFW_BIN" ]; then
78-
mkdir -p /tmp/sfw-bin
79-
printf '#!/bin/bash\nexec "%s" pnpm "$@"\n' "$SFW_BIN" > /tmp/sfw-bin/pnpm
80-
chmod +x /tmp/sfw-bin/pnpm
81-
export PATH="/tmp/sfw-bin:$PATH"
82-
fi
83-
8476
if [ -z "$ANTHROPIC_API_KEY" ]; then
8577
echo "ANTHROPIC_API_KEY not set - skipping automated update"
8678
echo "success=false" >> $GITHUB_OUTPUT
@@ -107,13 +99,6 @@ jobs:
10799
id: tests
108100
if: steps.update.outputs.success == 'true'
109101
run: |
110-
if [ -n "$SFW_BIN" ]; then
111-
mkdir -p /tmp/sfw-bin
112-
printf '#!/bin/bash\nexec "%s" pnpm "$@"\n' "$SFW_BIN" > /tmp/sfw-bin/pnpm
113-
chmod +x /tmp/sfw-bin/pnpm
114-
export PATH="/tmp/sfw-bin:$PATH"
115-
fi
116-
117102
set +e
118103
pnpm build 2>&1 | tee build-output.log
119104
BUILD_EXIT=${PIPESTATUS[0]}
@@ -148,13 +133,6 @@ jobs:
148133
BUILD_LOG: ${{ steps.tests.outputs.BUILD_LOG }}
149134
TEST_LOG: ${{ steps.tests.outputs.TEST_LOG }}
150135
run: |
151-
if [ -n "$SFW_BIN" ]; then
152-
mkdir -p /tmp/sfw-bin
153-
printf '#!/bin/bash\nexec "%s" pnpm "$@"\n' "$SFW_BIN" > /tmp/sfw-bin/pnpm
154-
chmod +x /tmp/sfw-bin/pnpm
155-
export PATH="/tmp/sfw-bin:$PATH"
156-
fi
157-
158136
set +e
159137
claude --print \
160138
--allowedTools "Bash(pnpm:*)" "Bash(git add:*)" "Bash(git commit:*)" "Bash(git status:*)" "Bash(git diff:*)" "Bash(git log:*)" "Bash(git rev-parse:*)" "Read" "Write" "Edit" "Glob" "Grep" \

0 commit comments

Comments
 (0)