Skip to content
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

Merged
merged 53 commits into from
Feb 27, 2025

Conversation

karlhorky
Copy link
Member

@karlhorky karlhorky commented Feb 27, 2025

Fix path problems with pnpm not workking well with corepack enable, manual setting of PNPM_HOME and Windows PowerShell, which I found in this series of commits:

Opened a related pnpm issue over here:

Copy link

codesandbox-ci bot commented Feb 27, 2025

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.

@karlhorky karlhorky changed the title Add debugging Fix Corepack integration with GitHub Actions workflow and test Feb 27, 2025
Comment on lines -18 to +23
await execa`pnpm add --global --allow-build=esbuild ${process.cwd()}/${pnpmPackTarballPath}`;
await execa`pnpm add --global --allow-build=esbuild $(pwd)/${pnpmPackTarballPath}`;
Copy link
Member Author

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',
Copy link
Member Author

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

Comment on lines +5 to +9
const execa = execaBind({
// Use Bash also on Windows, to avoid path issues
shell: 'bash',
});

Copy link
Member Author

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

Comment on lines -75 to +96
- 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add paths for Windows

@karlhorky karlhorky merged commit 8f4ca5e into main Feb 27, 2025
6 checks passed
@karlhorky karlhorky deleted the add-debugging branch February 27, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant