Skip to content

Commit

Permalink
update downloading script
Browse files Browse the repository at this point in the history
  • Loading branch information
tianfeng92 committed Sep 6, 2023
1 parent f95b176 commit 79e636b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '' }}
Expand Down Expand Up @@ -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 == '' }}
Expand Down
35 changes: 35 additions & 0 deletions scripts/bundle-mac.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 7 additions & 3 deletions scripts/bundle.sh → scripts/bundle-win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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/

Expand Down
2 changes: 1 addition & 1 deletion src/playwright-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -281,6 +280,7 @@ async function runPlaywright(nodeBin: string, runCfg: RunnerConfig): Promise<Run

// Define node/npm path for execution
const npmBin = path.join(path.dirname(nodeBin), 'npm');
console.log('npmBin: ', npmBin)
const nodeCtx = { nodePath: nodeBin, npmPath: npmBin };

// runCfg.path must be set for prepareNpmEnv to find node_modules. :(
Expand Down

0 comments on commit 79e636b

Please sign in to comment.