Skip to content

Commit e530aaa

Browse files
committed
CI: install yarn-berry on Windows runners via npm + .cmd wrapper
Previously the Windows matrix deliberately skipped Yarn Berry because the Unix setup uses ln -sf / homebrew prefix dirs that don't translate. The side effect was every test_yarnprovider.py test that uses require_tool('yarn-berry') bailed out with AssertionError: Could not resolve the globally installed yarn-berry alias on PATH on Windows. Add a Windows-specific Berry setup step that uses git-bash + npm: - npm install --prefix %USERPROFILE%/yarn-berry @yarnpkg/cli-dist@4.13.0 - write a tiny yarn-berry.cmd wrapper that forwards to the npm-installed yarn.cmd (no ln needed). - stage the wrapper dir onto GITHUB_PATH so shutil.which finds it. Matches the Unix behavior (yarn classic + Berry both on PATH) so the yarnprovider Windows test suite can actually run.
1 parent df47808 commit e530aaa

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

.github/workflows/tests.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,29 @@ jobs:
165165
yarn-berry --version
166166
yarn --version | grep -q '^1\.' || { echo "ERROR: yarn is not 1.x"; exit 1; }
167167
168-
- name: Setup Yarn classic (Windows)
169-
# Minimal Yarn setup for Windows: classic yarn is enough for most
170-
# tests that ``require_tool("yarn")``; Berry's Unix prefix scheme
171-
# isn't portable to Windows and the Berry-specific tests are
172-
# already gated behind ``require_tool("yarn-berry")``.
168+
- name: Setup Yarn (classic + Berry, Windows)
169+
# Windows equivalent of the Unix setup: classic yarn via ``npm -g``,
170+
# then Berry via ``npm --prefix`` + a ``.cmd`` wrapper at a stable
171+
# ``yarn-berry.cmd`` PATH entry (git-bash has no ``ln -sf``).
173172
if: runner.os == 'Windows'
174-
run: npm install -g yarn@1.22.22
173+
run: |
174+
npm install -g yarn@1.22.22
175+
YARN_BERRY_PREFIX="$USERPROFILE/yarn-berry"
176+
YARN_BERRY_ALIAS_DIR="$USERPROFILE/yarn-berry-bin"
177+
mkdir -p "$YARN_BERRY_ALIAS_DIR"
178+
# GITHUB_PATH is interpreted by runner as \-prefixed lines on Windows.
179+
echo "$YARN_BERRY_ALIAS_DIR" >> "$GITHUB_PATH"
180+
npm install --prefix "$YARN_BERRY_PREFIX" @yarnpkg/cli-dist@4.13.0
181+
# Emit a one-line ``yarn-berry.cmd`` that forwards to npm-installed
182+
# ``yarn.cmd``. Use ``%*`` to pass through all args.
183+
cat > "$YARN_BERRY_ALIAS_DIR/yarn-berry.cmd" <<EOF
184+
@echo off
185+
"$YARN_BERRY_PREFIX\\node_modules\\.bin\\yarn.cmd" %*
186+
EOF
187+
export PATH="$YARN_BERRY_ALIAS_DIR:$PATH"
188+
command -v yarn-berry
189+
yarn-berry --version | grep -q '^4\.'
190+
yarn --version | grep -q '^1\.'
175191

176192
- name: Setup Bun
177193
uses: oven-sh/setup-bun@v2

0 commit comments

Comments
 (0)