From b4a8c15ec1bdbde5d590668a302eb130b3d6399b Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Tue, 5 Sep 2023 15:35:24 -0700 Subject: [PATCH 01/31] Use abs path of npm --- src/playwright-runner.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 6bed3891..f408432a 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -276,8 +276,9 @@ async function runPlaywright(nodeBin: string, runCfg: RunnerConfig): Promise Date: Tue, 5 Sep 2023 19:43:03 -0700 Subject: [PATCH 02/31] Bundle npm&npx --- scripts/bundle.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/bundle.sh b/scripts/bundle.sh index cf41bb08..214d6449 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -15,7 +15,8 @@ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json cp "$(which node)" bundle/ - +cp "$(which npm)" bundle/ +cp "$(which npx)" bundle/ pushd bundle/ From c30c29cb0cb5c93afa8785a55f07f7d877772b40 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 10:00:27 -0700 Subject: [PATCH 03/31] add bundle to path? --- src/playwright-runner.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index f408432a..c0659f59 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -2,6 +2,7 @@ import {spawn} from 'node:child_process'; import * as path from 'node:path'; import * as fs from 'node:fs'; +import * as os from 'node:os'; import _ from 'lodash'; import {getArgs, prepareNpmEnv, loadRunConfig, escapeXML, preExec} from 'sauce-testrunner-utils'; @@ -168,6 +169,14 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { console.log(`Sauce Playwright Runner ${packageInfo.version}`); console.log(`Running Playwright ${packageInfo.dependencies?.playwright || ''}`); + const currentPATH = process.env.PATH || ''; + const platform = os.platform(); + if (platform === 'darwin') { + process.env.PATH = `${currentPATH}:${path.resolve(path.dirname(nodeBin))}` + } else if (platform === 'win32') { + process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}` + } + let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { result = await runCucumber(nodeBin, runCfg); From 4ede102e2293c46f74710cafed7e93432924e761 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 10:26:42 -0700 Subject: [PATCH 04/31] copy dereference files --- scripts/bundle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bundle.sh b/scripts/bundle.sh index 214d6449..58d466e3 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -15,8 +15,8 @@ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json cp "$(which node)" bundle/ -cp "$(which npm)" bundle/ -cp "$(which npx)" bundle/ +cp -L "$(which npm)" bundle/ +cp -L "$(which npx)" bundle/ pushd bundle/ From e580d06aeb1f306ed85bf399db754ec2867a273f Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 11:25:24 -0700 Subject: [PATCH 05/31] print PATH --- src/playwright-runner.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index c0659f59..883057d9 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -176,6 +176,7 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { } else if (platform === 'win32') { process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}` } + console.log('env var: ', process.env.PATH) let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { From 91c89f5f7787464ee6e53e39b1698568df42d19c Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 11:50:10 -0700 Subject: [PATCH 06/31] bundle npm&npx through download link --- scripts/bundle.sh | 6 +++--- src/playwright-runner.ts | 15 ++++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/scripts/bundle.sh b/scripts/bundle.sh index 58d466e3..619b720d 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -14,9 +14,9 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json -cp "$(which node)" bundle/ -cp -L "$(which npm)" bundle/ -cp -L "$(which npx)" bundle/ +wget "https://nodejs.org/dist/v18.17.1/node-v18.17.1-darwin-arm64.tar.gz" +tar xf node-v18.17.1-darwin-arm64.tar.gz +mv node-v18.17.1-darwin-arm64 node pushd bundle/ diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 883057d9..cd1851f5 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -169,14 +169,8 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { console.log(`Sauce Playwright Runner ${packageInfo.version}`); console.log(`Running Playwright ${packageInfo.dependencies?.playwright || ''}`); - const currentPATH = process.env.PATH || ''; - const platform = os.platform(); - if (platform === 'darwin') { - process.env.PATH = `${currentPATH}:${path.resolve(path.dirname(nodeBin))}` - } else if (platform === 'win32') { - process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}` - } - console.log('env var: ', process.env.PATH) + nodeBin = `${nodeBin}/node/bin/`; + console.log('nodeBin: ', nodeBin) let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { @@ -286,9 +280,8 @@ async function runPlaywright(nodeBin: string, runCfg: RunnerConfig): Promise Date: Wed, 6 Sep 2023 12:46:13 -0700 Subject: [PATCH 07/31] oops --- scripts/bundle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bundle.sh b/scripts/bundle.sh index 619b720d..da947c44 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -16,7 +16,7 @@ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json wget "https://nodejs.org/dist/v18.17.1/node-v18.17.1-darwin-arm64.tar.gz" tar xf node-v18.17.1-darwin-arm64.tar.gz -mv node-v18.17.1-darwin-arm64 node +mv node-v18.17.1-darwin-arm64 bundle/node pushd bundle/ From b6254f26c7efb188729a2bbefa7430a81fcc6f06 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 12:54:10 -0700 Subject: [PATCH 08/31] update nodeBin --- src/playwright-runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index cd1851f5..3c8bc60c 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -169,7 +169,7 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { console.log(`Sauce Playwright Runner ${packageInfo.version}`); console.log(`Running Playwright ${packageInfo.dependencies?.playwright || ''}`); - nodeBin = `${nodeBin}/node/bin/`; + nodeBin = `${path.dirname(nodeBin)}/node/bin/${path.basename(nodeBin)}`; console.log('nodeBin: ', nodeBin) let result: RunResult; From 19e43b2f098f299df10388ca18e8e2353afbcccd Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 13:29:41 -0700 Subject: [PATCH 09/31] what about this one? --- scripts/bundle.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/bundle.sh b/scripts/bundle.sh index da947c44..5741b74a 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -14,6 +14,7 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json +cp $(which node) bundle/ wget "https://nodejs.org/dist/v18.17.1/node-v18.17.1-darwin-arm64.tar.gz" tar xf node-v18.17.1-darwin-arm64.tar.gz mv node-v18.17.1-darwin-arm64 bundle/node From f95b1760d48f7bb12058e6d4950be1c25bf6cd08 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 13:41:02 -0700 Subject: [PATCH 10/31] use amd64 --- scripts/bundle.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/bundle.sh b/scripts/bundle.sh index 5741b74a..43893a8c 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle.sh @@ -14,10 +14,9 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json -cp $(which node) bundle/ -wget "https://nodejs.org/dist/v18.17.1/node-v18.17.1-darwin-arm64.tar.gz" -tar xf node-v18.17.1-darwin-arm64.tar.gz -mv node-v18.17.1-darwin-arm64 bundle/node +wget "https://nodejs.org/dist/v18.17.1/node-v18.17.1-darwin-x64.tar.gz" +tar xf node-v18.17.1-darwin-x64.tar.gz +mv node-v18.17.1-darwin-x64 bundle/node pushd bundle/ From 79e636b49d0a9b972ac59db3fe6b58ed4a352ea5 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 14:51:16 -0700 Subject: [PATCH 11/31] update downloading script --- .github/workflows/release.yml | 4 ++-- scripts/bundle-mac.sh | 35 ++++++++++++++++++++++++++++ scripts/{bundle.sh => bundle-win.sh} | 10 +++++--- src/playwright-runner.ts | 2 +- 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 scripts/bundle-mac.sh rename scripts/{bundle.sh => bundle-win.sh} (77%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index db9f7821..82cdd5bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -140,7 +140,7 @@ jobs: - name: Bundle Directory if: ${{ steps.prep.outputs.asset_id == '' }} - run: bash ./scripts/bundle.sh + run: bash ./scripts/bundle-win.sh - name: List Bundle Contents if: ${{ steps.prep.outputs.asset_id == '' }} @@ -211,7 +211,7 @@ jobs: - name: Bundle Directory if: ${{ steps.prep.outputs.asset_id == '' }} - run: bash ./scripts/bundle.sh + run: bash ./scripts/bundle-mac.sh - name: List Bundle Contents if: ${{ steps.prep.outputs.asset_id == '' }} diff --git a/scripts/bundle-mac.sh b/scripts/bundle-mac.sh new file mode 100644 index 00000000..f59e4315 --- /dev/null +++ b/scripts/bundle-mac.sh @@ -0,0 +1,35 @@ +set -e +echo "Using: $(which node)" +export PLAYWRIGHT_BROWSERS_PATH=$PWD/bundle/Cache/ +echo $PLAYWRIGHT_BROWSERS_PATH +NODE_VERSION=$(node --version) +NODE_URL="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-darwin-x64.tar.gz" +NODE_TAR_FILE="node-$NODE_VERSION-darwin-x64.tar.gz" +NODE_DIR="node-$NODE_VERSION-darwin-x64" + +rm -rf ./bundle/ +mkdir ./bundle/ + +# Build src +npm ci +npm run build +cp -r ./lib/ ./bundle/lib/ + +cp -r bin/ bundle/bin/ +cp package.json bundle/package.json +cp package-lock.json bundle/package-lock.json +wget $NODE_URL +tar xf $NODE_TAR_FILE +mv $NODE_DIR bundle/node + +pushd bundle/ + +npm cache clean --force +npm ci --omit=dev + + +npx playwright install +npx playwright install-deps +npx playwright --version + +popd diff --git a/scripts/bundle.sh b/scripts/bundle-win.sh similarity index 77% rename from scripts/bundle.sh rename to scripts/bundle-win.sh index 43893a8c..0673a783 100644 --- a/scripts/bundle.sh +++ b/scripts/bundle-win.sh @@ -2,6 +2,10 @@ set -e echo "Using: $(which node)" export PLAYWRIGHT_BROWSERS_PATH=$PWD/bundle/Cache/ echo $PLAYWRIGHT_BROWSERS_PATH +NODE_VERSION=$(node --version) +NODE_URL="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-win-x64.zip" +NODE_TAR_FILE="node-$NODE_VERSION-darwin-x64.tar.gz" +NODE_DIR="node-$NODE_VERSION-darwin-x64" rm -rf ./bundle/ mkdir ./bundle/ @@ -14,9 +18,9 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json -wget "https://nodejs.org/dist/v18.17.1/node-v18.17.1-darwin-x64.tar.gz" -tar xf node-v18.17.1-darwin-x64.tar.gz -mv node-v18.17.1-darwin-x64 bundle/node +wget $NODE_URL +tar xf $NODE_TAR_FILE +mv $NODE_DIR bundle/node pushd bundle/ diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 3c8bc60c..498ffe98 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -169,7 +169,6 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { console.log(`Sauce Playwright Runner ${packageInfo.version}`); console.log(`Running Playwright ${packageInfo.dependencies?.playwright || ''}`); - nodeBin = `${path.dirname(nodeBin)}/node/bin/${path.basename(nodeBin)}`; console.log('nodeBin: ', nodeBin) let result: RunResult; @@ -281,6 +280,7 @@ async function runPlaywright(nodeBin: string, runCfg: RunnerConfig): Promise Date: Wed, 6 Sep 2023 14:58:18 -0700 Subject: [PATCH 12/31] fix test --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 366f3c5e..fd378dce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -123,7 +123,7 @@ jobs: run: npm version --no-git-tag-version 1.0.0 - name: Bundle Directory - run: bash ./scripts/bundle.sh + run: bash ./scripts/bundle-win.sh - name: Archive Bundle uses: azure/powershell@v1 @@ -171,7 +171,7 @@ jobs: run: npm version --no-git-tag-version 1.0.0 - name: Bundle Directory - run: bash ./scripts/bundle.sh + run: bash ./scripts/bundle-mac.sh - name: Archive Bundle run: zip --symlinks -r playwright-macos-amd64.zip bundle/ From cb51af1d171fdc2a41988559ccca0ec51600f919 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 15:02:49 -0700 Subject: [PATCH 13/31] update win bundle --- scripts/bundle-win.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index 0673a783..21759fbd 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -19,7 +19,7 @@ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json wget $NODE_URL -tar xf $NODE_TAR_FILE +unzip $NODE_TAR_FILE mv $NODE_DIR bundle/node pushd bundle/ From 172d12b5aed93c14ffed66ec81bb08dc116ab761 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 15:37:53 -0700 Subject: [PATCH 14/31] use curl --- scripts/bundle-mac.sh | 2 +- scripts/bundle-win.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bundle-mac.sh b/scripts/bundle-mac.sh index f59e4315..a52bb9b3 100644 --- a/scripts/bundle-mac.sh +++ b/scripts/bundle-mac.sh @@ -18,7 +18,7 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json -wget $NODE_URL +curl -o $NODE_TAR_FILE $NODE_URL tar xf $NODE_TAR_FILE mv $NODE_DIR bundle/node diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index 21759fbd..638b01f2 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -18,7 +18,7 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json -wget $NODE_URL +curl -o $NODE_TAR_FILE $NODE_URL unzip $NODE_TAR_FILE mv $NODE_DIR bundle/node From 6313ec00c363686d3fade110a190df78e6df37ec Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 15:46:07 -0700 Subject: [PATCH 15/31] am I blind? --- scripts/bundle-win.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index 638b01f2..a43100cb 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -4,8 +4,8 @@ export PLAYWRIGHT_BROWSERS_PATH=$PWD/bundle/Cache/ echo $PLAYWRIGHT_BROWSERS_PATH NODE_VERSION=$(node --version) NODE_URL="https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-win-x64.zip" -NODE_TAR_FILE="node-$NODE_VERSION-darwin-x64.tar.gz" -NODE_DIR="node-$NODE_VERSION-darwin-x64" +NODE_TAR_FILE="node-$NODE_VERSION-win-x64.zip" +NODE_DIR="node-$NODE_VERSION-win-x64" rm -rf ./bundle/ mkdir ./bundle/ From 21d915cc9e2b943046dbe39aac4032a848a7b953 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 16:53:54 -0700 Subject: [PATCH 16/31] log platform name --- src/playwright-runner.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 498ffe98..761d2d2c 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -169,7 +169,15 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { console.log(`Sauce Playwright Runner ${packageInfo.version}`); console.log(`Running Playwright ${packageInfo.dependencies?.playwright || ''}`); + const platform = os.platform(); + const currentPATH = process.env.PATH || ''; + if (platform === 'win32') { + process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}`; + } else { + process.env.PATH = `${currentPATH}:${path.resolve(path.dirname(nodeBin))}`; + } console.log('nodeBin: ', nodeBin) + console.log('path: ', process.env.PATH) let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { From 638ab97c39d765db158c7183c3dd26ff85383434 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 17:07:23 -0700 Subject: [PATCH 17/31] maybe windows needs cmd? --- src/playwright-runner.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 761d2d2c..494f2b1e 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -287,7 +287,10 @@ async function runPlaywright(nodeBin: string, runCfg: RunnerConfig): Promise Date: Wed, 6 Sep 2023 17:35:45 -0700 Subject: [PATCH 18/31] npmBin needs js --- src/playwright-runner.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 494f2b1e..edb65489 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -287,11 +287,7 @@ async function runPlaywright(nodeBin: string, runCfg: RunnerConfig): Promise Date: Wed, 6 Sep 2023 18:11:40 -0700 Subject: [PATCH 19/31] do I need to set the PATH? --- src/playwright-runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index edb65489..a21fae1d 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -172,7 +172,7 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { const platform = os.platform(); const currentPATH = process.env.PATH || ''; if (platform === 'win32') { - process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}`; + //process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}`; } else { process.env.PATH = `${currentPATH}:${path.resolve(path.dirname(nodeBin))}`; } From ece9b29e554a13bb98848f8dd4c5e8018d08647a Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 18:25:37 -0700 Subject: [PATCH 20/31] Revert "do I need to set the PATH?" This reverts commit 520188d00374d30e7bb9c54328f86bf6d0846081. --- src/playwright-runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index a21fae1d..edb65489 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -172,7 +172,7 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { const platform = os.platform(); const currentPATH = process.env.PATH || ''; if (platform === 'win32') { - //process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}`; + process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}`; } else { process.env.PATH = `${currentPATH}:${path.resolve(path.dirname(nodeBin))}`; } From 4c119f89aafca68f70f0143a99d2da392093082f Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Wed, 6 Sep 2023 20:00:17 -0700 Subject: [PATCH 21/31] remove debug code --- src/playwright-runner.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index edb65489..a0ea856a 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -176,8 +176,6 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { } else { process.env.PATH = `${currentPATH}:${path.resolve(path.dirname(nodeBin))}`; } - console.log('nodeBin: ', nodeBin) - console.log('path: ', process.env.PATH) let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { From 2c1e657c6445d1e6c0939e3943c45902b672ef2e Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 09:01:13 -0700 Subject: [PATCH 22/31] use path.delimiter --- src/playwright-runner.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index a0ea856a..6dee6176 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -2,7 +2,6 @@ import {spawn} from 'node:child_process'; import * as path from 'node:path'; import * as fs from 'node:fs'; -import * as os from 'node:os'; import _ from 'lodash'; import {getArgs, prepareNpmEnv, loadRunConfig, escapeXML, preExec} from 'sauce-testrunner-utils'; @@ -169,13 +168,8 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { console.log(`Sauce Playwright Runner ${packageInfo.version}`); console.log(`Running Playwright ${packageInfo.dependencies?.playwright || ''}`); - const platform = os.platform(); const currentPATH = process.env.PATH || ''; - if (platform === 'win32') { - process.env.PATH = `${currentPATH};${path.resolve(path.dirname(nodeBin))}`; - } else { - process.env.PATH = `${currentPATH}:${path.resolve(path.dirname(nodeBin))}`; - } + process.env.PATH = `${currentPATH}${path.delimiter}${path.resolve(path.dirname(nodeBin))}` let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { From 4cd9b3cac1ed39d92a40d952e51f781e8c4aecad Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 09:49:39 -0700 Subject: [PATCH 23/31] modify nodeBin location --- scripts/bundle-mac.sh | 2 +- scripts/bundle-win.sh | 2 +- src/playwright-runner.ts | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/bundle-mac.sh b/scripts/bundle-mac.sh index a52bb9b3..d29fb5a9 100644 --- a/scripts/bundle-mac.sh +++ b/scripts/bundle-mac.sh @@ -14,10 +14,10 @@ mkdir ./bundle/ npm ci npm run build cp -r ./lib/ ./bundle/lib/ - cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json +cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL tar xf $NODE_TAR_FILE mv $NODE_DIR bundle/node diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index a43100cb..229c8a08 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -14,10 +14,10 @@ mkdir ./bundle/ npm ci npm run build cp -r ./lib/ ./bundle/lib/ - cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json +cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL unzip $NODE_TAR_FILE mv $NODE_DIR bundle/node diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 6dee6176..73a92a42 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -2,6 +2,7 @@ import {spawn} from 'node:child_process'; import * as path from 'node:path'; import * as fs from 'node:fs'; +import * as os from 'node:os'; import _ from 'lodash'; import {getArgs, prepareNpmEnv, loadRunConfig, escapeXML, preExec} from 'sauce-testrunner-utils'; @@ -168,6 +169,13 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { console.log(`Sauce Playwright Runner ${packageInfo.version}`); console.log(`Running Playwright ${packageInfo.dependencies?.playwright || ''}`); + // Modify nodeBin location to downloaded node binaries. + const nodeDir = path.resolve(path.dirname(nodeBin)); + if (os.platform() === 'win32') { + nodeBin = path.join(nodeDir, 'node', 'node.exe'); + } else { + nodeBin = path.join(nodeDir, 'node', 'bin', 'node'); + } const currentPATH = process.env.PATH || ''; process.env.PATH = `${currentPATH}${path.delimiter}${path.resolve(path.dirname(nodeBin))}` From fb20f3beff1645b0519bfdcacbaaa6a6a2634b26 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 09:57:47 -0700 Subject: [PATCH 24/31] file and folder cannot use the same name --- scripts/bundle-mac.sh | 2 +- scripts/bundle-win.sh | 2 +- src/playwright-runner.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/bundle-mac.sh b/scripts/bundle-mac.sh index d29fb5a9..b5e9e354 100644 --- a/scripts/bundle-mac.sh +++ b/scripts/bundle-mac.sh @@ -20,7 +20,7 @@ cp package-lock.json bundle/package-lock.json cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL tar xf $NODE_TAR_FILE -mv $NODE_DIR bundle/node +mv $NODE_DIR bundle/node_dir pushd bundle/ diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index 229c8a08..eeb59532 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -20,7 +20,7 @@ cp package-lock.json bundle/package-lock.json cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL unzip $NODE_TAR_FILE -mv $NODE_DIR bundle/node +mv $NODE_DIR bundle/nodeBin pushd bundle/ diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 73a92a42..c707c5ee 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -172,9 +172,9 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { // Modify nodeBin location to downloaded node binaries. const nodeDir = path.resolve(path.dirname(nodeBin)); if (os.platform() === 'win32') { - nodeBin = path.join(nodeDir, 'node', 'node.exe'); + nodeBin = path.join(nodeDir, 'node_dir', 'node.exe'); } else { - nodeBin = path.join(nodeDir, 'node', 'bin', 'node'); + nodeBin = path.join(nodeDir, 'node_dir', 'bin', 'node'); } const currentPATH = process.env.PATH || ''; process.env.PATH = `${currentPATH}${path.delimiter}${path.resolve(path.dirname(nodeBin))}` From 6a5e8e7b37d83e31ecf459d52c989326e6f24b95 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 10:20:19 -0700 Subject: [PATCH 25/31] update npmBin location --- scripts/bundle-win.sh | 2 +- src/playwright-runner.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index eeb59532..442b9a1b 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -20,7 +20,7 @@ cp package-lock.json bundle/package-lock.json cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL unzip $NODE_TAR_FILE -mv $NODE_DIR bundle/nodeBin +mv $NODE_DIR bundle/node_dir pushd bundle/ diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index c707c5ee..9edff329 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -287,7 +287,7 @@ async function runPlaywright(nodeBin: string, runCfg: RunnerConfig): Promise Date: Thu, 7 Sep 2023 10:31:46 -0700 Subject: [PATCH 26/31] print nodeBin --- src/playwright-runner.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 9edff329..1a003575 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -176,8 +176,10 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { } else { nodeBin = path.join(nodeDir, 'node_dir', 'bin', 'node'); } + console.log('nodeBin: ', nodeBin) const currentPATH = process.env.PATH || ''; process.env.PATH = `${currentPATH}${path.delimiter}${path.resolve(path.dirname(nodeBin))}` + console.log('PATH: ', process.env.PATH) let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { From d92dc078cc2d356253243e4912774740c6abc58e Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 10:34:30 -0700 Subject: [PATCH 27/31] set the only node --- scripts/bundle-mac.sh | 1 - scripts/bundle-win.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/scripts/bundle-mac.sh b/scripts/bundle-mac.sh index b5e9e354..e7c73800 100644 --- a/scripts/bundle-mac.sh +++ b/scripts/bundle-mac.sh @@ -17,7 +17,6 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json -cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL tar xf $NODE_TAR_FILE mv $NODE_DIR bundle/node_dir diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index 442b9a1b..612fe22c 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -17,7 +17,6 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json -cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL unzip $NODE_TAR_FILE mv $NODE_DIR bundle/node_dir From ceaf28c9f0725da0a5e7264144434915c3db2409 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 10:48:20 -0700 Subject: [PATCH 28/31] Revert "set the only node" This reverts commit d92dc078cc2d356253243e4912774740c6abc58e. --- scripts/bundle-mac.sh | 1 + scripts/bundle-win.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/bundle-mac.sh b/scripts/bundle-mac.sh index e7c73800..b5e9e354 100644 --- a/scripts/bundle-mac.sh +++ b/scripts/bundle-mac.sh @@ -17,6 +17,7 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json +cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL tar xf $NODE_TAR_FILE mv $NODE_DIR bundle/node_dir diff --git a/scripts/bundle-win.sh b/scripts/bundle-win.sh index 612fe22c..442b9a1b 100644 --- a/scripts/bundle-win.sh +++ b/scripts/bundle-win.sh @@ -17,6 +17,7 @@ cp -r ./lib/ ./bundle/lib/ cp -r bin/ bundle/bin/ cp package.json bundle/package.json cp package-lock.json bundle/package-lock.json +cp $(which node) bundle/ curl -o $NODE_TAR_FILE $NODE_URL unzip $NODE_TAR_FILE mv $NODE_DIR bundle/node_dir From a1b6034272b824a9c3a36a69c77534bedde0e7d6 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 10:51:42 -0700 Subject: [PATCH 29/31] fix relative path of npm for mac platform --- src/playwright-runner.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 1a003575..b2f172fb 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -174,6 +174,10 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { if (os.platform() === 'win32') { nodeBin = path.join(nodeDir, 'node_dir', 'node.exe'); } else { + fs.unlink(nodeBin, (err) => { + if (err) throw err; + console.log('previous nodeBin was deleted'); + }); nodeBin = path.join(nodeDir, 'node_dir', 'bin', 'node'); } console.log('nodeBin: ', nodeBin) From 7b45f2a4d493d5e40538f47ef9e04f8d64a3a67b Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 11:19:33 -0700 Subject: [PATCH 30/31] cleanup code --- src/playwright-runner.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index b2f172fb..0f1fdde5 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -174,16 +174,16 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { if (os.platform() === 'win32') { nodeBin = path.join(nodeDir, 'node_dir', 'node.exe'); } else { + // The previous bundled nodeBin(/Users/chef/payload/bundle/bundle/node) should be resolved on Mac platform. + // Otherwise, `npx` would point to `/Users/chef/payload/bundle/lib/`. fs.unlink(nodeBin, (err) => { if (err) throw err; - console.log('previous nodeBin was deleted'); + console.log('previous bundled nodeBin was deleted'); }); nodeBin = path.join(nodeDir, 'node_dir', 'bin', 'node'); } - console.log('nodeBin: ', nodeBin) const currentPATH = process.env.PATH || ''; process.env.PATH = `${currentPATH}${path.delimiter}${path.resolve(path.dirname(nodeBin))}` - console.log('PATH: ', process.env.PATH) let result: RunResult; if (runCfg.Kind === 'playwright-cucumberjs') { From 9ecb7b190850b9306b10b209a8dc0fba93621ad9 Mon Sep 17 00:00:00 2001 From: Tian Feng Date: Thu, 7 Sep 2023 11:27:40 -0700 Subject: [PATCH 31/31] update comment --- src/playwright-runner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/playwright-runner.ts b/src/playwright-runner.ts index 0f1fdde5..68c10368 100644 --- a/src/playwright-runner.ts +++ b/src/playwright-runner.ts @@ -174,8 +174,8 @@ async function run(nodeBin: string, runCfgPath: string, suiteName: string) { if (os.platform() === 'win32') { nodeBin = path.join(nodeDir, 'node_dir', 'node.exe'); } else { - // The previous bundled nodeBin(/Users/chef/payload/bundle/bundle/node) should be resolved on Mac platform. - // Otherwise, `npx` would point to `/Users/chef/payload/bundle/lib/`. + // The previous bundled nodeBin(/Users/chef/payload/bundle/bundle/node) should be removed on Mac platform. + // Otherwise, `npx` would be point to `/Users/chef/payload/bundle/lib/` according to the `node` path, which is wrong. fs.unlink(nodeBin, (err) => { if (err) throw err; console.log('previous bundled nodeBin was deleted');