Browse Source

install pnpm only first time or on version mismatch

pull/6431/head
starbirdtech383 1 year ago committed by starbirdtech383
parent
commit
74ecc45864
  1. 28
      .github/workflows/playwright-test-workflow.yml
  2. 28
      .github/workflows/pre-build-for-playwright.yml
  3. 35
      scripts/self-hosted-gh-runner/node-pnpm-check.sh
  4. 35
      tests/playwright/scripts/self-hosted-gh-runner/node-pnpm-check.sh

28
.github/workflows/playwright-test-workflow.yml

@ -18,31 +18,29 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Check node,pnpm Installation and set Path
shell: bash
working-directory: scripts/self-hosted-gh-runner
timeout-minutes: 1
run: |
./node-pnpm-check.sh
echo "make sure below mentioned versions are expected versions"
echo "If you are expecting the node and pnpm versions to be updated. Please update the node-pnpm-check.sh script"
env
- name: Setup Node - name: Setup Node
if: ${{ env.SETUP_NODE != 'false' }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18.14.0 node-version: ${{ env.NC_REQ_NODE_V }}
- name: Setup pnpm - name: Setup pnpm
if: ${{ env.SETUP_PNPM != 'false' }}
uses: pnpm/action-setup@v2 uses: pnpm/action-setup@v2
with: with:
version: 8 version: ${{ env.NC_REQ_PNPM_V }}
- name: Get pnpm store directory - name: Get pnpm store directory
shell: bash shell: bash
run: | run: |
echo "STORE_PATH=/root/setup-pnpm/node_modules/.bin/store/v3" >> $GITHUB_ENV echo "STORE_PATH=/root/setup-pnpm/node_modules/.bin/store/v3" >> $GITHUB_ENV
- name: check if npm cache is needed
shell: bash
run: |
IS_NPM_CACHE_DOWNLOAD_REQUIRED="/cache-marker-v1.txt"
# update the above file name to force the cache ex: /cache-marker-v2.txt.
if [[ ! -f ${PRE_REQ_CHECK_FILE_PATH} ]];
then
echo "IS_NPM_CACHE_DOWNLOAD_REQUIRED is true"
IS_NPM_CACHE_DOWNLOAD_REQUIRED="true"
else
IS_NPM_CACHE_DOWNLOAD_REQUIRED="false"
fi
echo "IS_NPM_CACHE_DOWNLOAD_REQUIRED=${IS_NPM_CACHE_DOWNLOAD_REQUIRED}" >> $GITHUB_ENV
- uses: actions/cache@v3 - uses: actions/cache@v3
if: env.IS_NPM_CACHE_DOWNLOAD_REQUIRED == 'true' if: env.IS_NPM_CACHE_DOWNLOAD_REQUIRED == 'true'
name: Setup pnpm cache name: Setup pnpm cache

28
.github/workflows/pre-build-for-playwright.yml

@ -16,27 +16,25 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Check node,pnpm Installation and set Path
shell: bash
working-directory: scripts/self-hosted-gh-runner
timeout-minutes: 1
run: |
./node-pnpm-check.sh
echo "make sure below mentioned versions are expected versions"
echo "If you are expecting the node and pnpm versions to be updated. Please update the node-pnpm-check.sh script"
env
- name: Setup Node - name: Setup Node
if: ${{ env.SETUP_NODE != 'false' }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18.14.0 node-version: ${{ env.NC_REQ_NODE_V }}
- name: Setup pnpm - name: Setup pnpm
if: ${{ env.SETUP_PNPM != 'false' }}
uses: pnpm/action-setup@v2 uses: pnpm/action-setup@v2
with: with:
version: 8 version: ${{ env.NC_REQ_PNPM_V }}
- name: check if npm cache is needed
shell: bash
run: |
PRE_REQ_CHECK_FILE_PATH="/cache-marker-v1.txt"
# update the above file name to force the cache ex: /cache-marker-v2.txt.
if [[ ! -f ${PRE_REQ_CHECK_FILE_PATH} ]];
then
echo "IS_NPM_CACHE_DOWNLOAD_REQUIRED is true"
IS_NPM_CACHE_DOWNLOAD_REQUIRED="true"
else
IS_NPM_CACHE_DOWNLOAD_REQUIRED="false"
fi
echo "IS_NPM_CACHE_DOWNLOAD_REQUIRED=${IS_NPM_CACHE_DOWNLOAD_REQUIRED}" >> $GITHUB_ENV
- name: Get pnpm store directory - name: Get pnpm store directory
shell: bash shell: bash
run: | run: |

35
scripts/self-hosted-gh-runner/node-pnpm-check.sh

@ -0,0 +1,35 @@
#!/bin/bash
# this script is intended to run in ci/cd job
# it checks if node and pnpm is installed
# and sets github env variable to skip installation
# this is suitable for self-hosted runners with
# docker image created from /Users/rajanishgj/Documents/GitHub/nocohub/tests/docker/Dockerfile
#
NC_REQ_NODE_V="18.17.1"
NC_REQ_PNPM_V="8.8.0"
NODE_PATH="/home/docker/actions-runner/_work/_tool/node/${NC_REQ_NODE_V}/x64/bin/node"
PNPM_PATH="/root/setup-pnpm/node_modules/.bin/pnpm"
NC_NODE_V=$($NODE_PATH -v || echo "error")
NC_PNPM_V=$($PNPM_PATH -v || echo "error")
if [[ $NC_NODE_V == *$NC_REQ_NODE_V* ]]; then
PATH=$PATH:$(dirname $NODE_PATH)
SETUP_NODE=false
fi
if [[ $NC_PNPM_V == $NC_REQ_PNPM_V ]]; then
PATH=$PATH:$(dirname $PNPM_PATH)
SETUP_PNPM=false
fi
echo "SETUP_NODE=${SETUP_NODE:-true}" >> $GITHUB_ENV
echo "SETUP_PNPM=${SETUP_PNPM:-true}" >> $GITHUB_ENV
echo "NC_REQ_NODE_V=${NC_REQ_NODE_V}" >> $GITHUB_ENV
echo "NC_REQ_PNPM_V=${NC_REQ_PNPM_V}" >> $GITHUB_ENV
echo "NC_NODE_V=${NC_NODE_V}" >> $GITHUB_ENV
echo "NC_PNPM_V=${NC_PNPM_V}" >> $GITHUB_ENV
echo "PATH=${PATH}" >> $GITHUB_ENV
echo "completed check node and pnpm installation"

35
tests/playwright/scripts/self-hosted-gh-runner/node-pnpm-check.sh

@ -0,0 +1,35 @@
#!/bin/bash
# this script is intended to run in ci/cd job
# it checks if node and pnpm is installed
# and sets github env variable to skip installation
# this is suitable for self-hosted runners with
# docker image created from /Users/rajanishgj/Documents/GitHub/nocohub/tests/docker/Dockerfile
#
NC_REQ_NODE_V="18.17.1"
NC_REQ_PNPM_V="8.8.0"
NODE_PATH="/home/docker/actions-runner/_work/_tool/node/${NC_REQ_NODE_V}/x64/bin/node"
PNPM_PATH="/root/setup-pnpm/node_modules/.bin/pnpm"
NC_NODE_V=$($NODE_PATH -v || echo "error")
NC_PNPM_V=$($PNPM_PATH -v || echo "error")
if [[ $NC_NODE_V == *$NC_REQ_NODE_V* ]]; then
PATH=$PATH:$(dirname $NODE_PATH)
SETUP_NODE=false
fi
if [[ $NC_PNPM_V == $NC_REQ_PNPM_V ]]; then
PATH=$PATH:$(dirname $PNPM_PATH)
SETUP_PNPM=false
fi
echo "SETUP_NODE=${SETUP_NODE:-true}" >> $GITHUB_ENV
echo "SETUP_PNPM=${SETUP_PNPM:-true}" >> $GITHUB_ENV
echo "NC_REQ_NODE_V=${NC_REQ_NODE_V}" >> $GITHUB_ENV
echo "NC_REQ_PNPM_V=${NC_REQ_PNPM_V}" >> $GITHUB_ENV
echo "NC_NODE_V=${NC_NODE_V}" >> $GITHUB_ENV
echo "NC_PNPM_V=${NC_PNPM_V}" >> $GITHUB_ENV
echo "PATH=${PATH}" >> $GITHUB_ENV
echo "completed check node and pnpm installation"
Loading…
Cancel
Save