-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Corepack integration with GitHub Actions workflow and test #631
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
await execa`pnpm add --global --allow-build=esbuild ${process.cwd()}/${pnpmPackTarballPath}`; | ||
await execa`pnpm add --global --allow-build=esbuild $(pwd)/${pnpmPackTarballPath}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid path errors with process.cwd()
on non-Bash Windows:
vitest run
RUN v3.0.6 D:/a/preflight/preflight
❯ __tests__/e2e.test.ts (2 tests | 2 skipped) 2680ms
⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL __tests__/e2e.test.ts [ __tests__/e2e.test.ts ]
ExecaError: Command failed with exit code 127: pnpm add --global "--allow-build=esbuild" "D:\a\preflight\preflight/upleveled-preflight-8.0.4.tgz"
\u2009ENOENT\u2009 ENOENT: no such file or directory, open 'D:\a\preflight\preflight\apreflightpreflight\upleveled-preflight-8.0.4.tgz'
This error happened while installing a direct dependency of C:\Program Files\Git\home\runner\.local\share\pnpm\global\5
❯ getFinalError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9
❯ makeError node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16
❯ getAsyncResult node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:167:4
❯ handlePromise node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:150:17
❯ __tests__/e2e.test.ts:22:5
20| }
21|
22| await execa`pnpm add --global --allow-build=esbuild ${process.cwd(…
| ^
23|
24| await pMap(
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
@@ -71,7 +76,6 @@ function sortStdoutAndStripVersionNumber(stdout: string) { | |||
test('Passes in the react-passing test project', async () => { | |||
const { stdout, stderr } = await execa({ | |||
cwd: `${fixturesTempDir}/react-passing`, | |||
shell: 'bash', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bash is used in all execa
commands now
const execa = execaBind({ | ||
// Use Bash also on Windows, to avoid path issues | ||
shell: 'bash', | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
various path issues, such as not being able to find C:\Program Files\Git\home\runner\.local\share\pnpm\global\5\.pnpm\node_modules\tsx\dist\cli.mjs
:
❯ __tests__/e2e.test.ts (2 tests | 2 failed) 202964ms
× Passes in the react-passing test project 1416ms
→ Command failed with exit code 1: preflight
node:internal/modules/cjs/loader:1228\r
throw err;\r
^\r
\r
Error: Cannot find module 'C:\Program Files\Git\home\runner\.local\share\pnpm\global\5\.pnpm\node_modules\tsx\dist\cli.mjs'\r
at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)\r
at Function._load (node:internal/modules/cjs/loader:1055:27)\r
at TracingChannel.traceSync (node:diagnostics_channel:322:14)\r
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)\r
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)\r
at node:internal/main/run_main_module:36:49 {\r
code: 'MODULE_NOT_FOUND',\r
requireStack: []\r
}\r
although the file /c/Program Files/Git/home/runner/.local/share/pnpm/global/5/.pnpm/node_modules/tsx/dist/cli.mjs
does exist
- run: echo 'PNPM_HOME="/home/runner/.local/share/pnpm"' >> $GITHUB_ENV | ||
- run: echo "$PNPM_HOME" >> $GITHUB_PATH | ||
|
||
# Set up PNPM_HOME directory to avoid errors such | ||
# as `ERR_PNPM_NO_GLOBAL_BIN_DIR`: | ||
# | ||
# ``` | ||
# ERR_PNPM_NO_GLOBAL_BIN_DIR Unable to find the global bin directory | ||
# Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH. | ||
# ``` | ||
# | ||
# - https://github.com/pnpm/pnpm/issues/9191#issuecomment-2687756396 | ||
- name: Set up pnpm global bin directory for `pnpm add --global` | ||
run: | | ||
if [ "$RUNNER_OS" == "Windows" ]; then | ||
PNPM_HOME=/c/Program\ Files/Git/home/runner/.local/share/pnpm | ||
elif [ "$RUNNER_OS" == "Linux" ]; then | ||
PNPM_HOME=/home/runner/.local/share/pnpm | ||
fi | ||
echo "PNPM_HOME=$PNPM_HOME" >> "$GITHUB_ENV" | ||
echo "$PNPM_HOME" >> "$GITHUB_PATH" | ||
shell: bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add paths for Windows
Fix path problems with pnpm not workking well with
corepack enable
, manual setting ofPNPM_HOME
and Windows PowerShell, which I found in this series of commits:Opened a related pnpm issue over here:
corepack enable
+pnpm setup
on GitHub Actions pnpm/pnpm#9191