diff --git a/.github/workflows/scripts/test-extensions-creators-build.sh b/.github/workflows/scripts/test-extensions-creators-build.sh index 8be56aabbe7..5393c8233e9 100755 --- a/.github/workflows/scripts/test-extensions-creators-build.sh +++ b/.github/workflows/scripts/test-extensions-creators-build.sh @@ -1,10 +1,9 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh -set -eo pipefail +set -e SKELETON_APP_NAME="test-pkg" - validate_tagged_extension_creator() { TAG=$1 NODE_VERSION=$2 @@ -15,12 +14,13 @@ validate_tagged_extension_creator() { UPDATE="true" fi - # these two commands will allow for NVM to work in bash, since it's included in ubuntu-latest - export NVM_DIR=~/.nvm - source ~/.nvm/nvm.sh + # These two commands will allow for NVM to work in sh + export NVM_DIR="$HOME/.nvm" + # shellcheck disable=SC1090 + . "$NVM_DIR/nvm.sh" DIR=$(mktemp -d) - cd $DIR + cd "$DIR" || exit 1 echo "*** ***************************************** ***" echo "*** Verifying extension creator for tag ::: ${TAG} ***" @@ -31,24 +31,24 @@ validate_tagged_extension_creator() { echo "=> Current dir 1:" pwd - # setting up correct version of node - nvm install ${NODE_VERSION} - nvm use ${NODE_VERSION} + # Setting up the correct version of Node + nvm install "${NODE_VERSION}" + nvm use "${NODE_VERSION}" - # generate skeleton app - npm init @rancher/extension@${TAG} ${SKELETON_APP_NAME} --app-name test-app | cat - cd ${SKELETON_APP_NAME} + # Generate skeleton app + npm init @rancher/extension@"${TAG}" "${SKELETON_APP_NAME}" --app-name test-app | cat + cd "${SKELETON_APP_NAME}" || exit 1 - # install dependencies + # Install dependencies yarn install - # test build of pkg inside skeleton app - yarn build-pkg ${SKELETON_APP_NAME} | cat + # Test build of pkg inside skeleton app + yarn build-pkg "${SKELETON_APP_NAME}" | cat echo "=> Current dir 2:" pwd - if [ $UPDATE == "true" ]; then + if [ "$UPDATE" = "true" ]; then echo "*** ***************************************** ***" echo "*** Testing FULL UPGRADE path for extensions ***" echo "*** ***************************************** ***" @@ -58,9 +58,9 @@ validate_tagged_extension_creator() { pwd git init - #when doing git init, we are sent to .git folder + # When doing git init, we are sent to the .git folder cd .. - cd ${SKELETON_APP_NAME} + cd "${SKELETON_APP_NAME}" || exit 1 echo "=> Current dir 4:" pwd @@ -68,11 +68,11 @@ validate_tagged_extension_creator() { npm init @rancher/extension@legacy-v2 -- --update rm -rf node_modules - rm -rf yarn.lock + rm -f yarn.lock yarn install - yarn build-pkg ${SKELETON_APP_NAME} | cat + yarn build-pkg "${SKELETON_APP_NAME}" | cat echo "*** ***************************************** ***" echo "*** Testing UPGRADE from legacy-v2 to latest ***" @@ -86,24 +86,135 @@ validate_tagged_extension_creator() { npm init @rancher/extension -- --migrate rm -rf node_modules - rm -rf yarn.lock + rm -f yarn.lock yarn install - yarn build-pkg ${SKELETON_APP_NAME} | cat + yarn build-pkg "${SKELETON_APP_NAME}" | cat fi echo "Cleaning temporary dir" - cd ${DIR} + cd "${DIR}" || exit 1 echo "Removing folder ${DIR}" - rm -rf ${DIR} + rm -rf "${DIR}" } -# test creating an extension with latest shell releases + build +# Test creating an extension with latest shell releases + build # validate_tagged_extension_creator "legacy-v1" "v16" # validate_tagged_extension_creator "legacy-v2" "v16" # validate_tagged_extension_creator "latest" "v20" -# test update paths + build -validate_tagged_extension_creator "legacy-v1" "v16" "true" \ No newline at end of file +# Test update paths + build +validate_tagged_extension_creator "legacy-v1" "v16" "true" + + +# #!/usr/bin/env bash + +# set -eo pipefail + +# SKELETON_APP_NAME="test-pkg" + + +# validate_tagged_extension_creator() { +# TAG=$1 +# NODE_VERSION=$2 +# UPDATE=$3 + +# if [ -n "$UPDATE" ]; then +# echo "*** Will also cover the UPDATE path and MIGRATION on this run! ***" +# UPDATE="true" +# fi + +# # these two commands will allow for NVM to work in bash, since it's included in ubuntu-latest +# export NVM_DIR=~/.nvm +# source ~/.nvm/nvm.sh + +# DIR=$(mktemp -d) +# cd $DIR + +# echo "*** ***************************************** ***" +# echo "*** Verifying extension creator for tag ::: ${TAG} ***" +# echo "*** ***************************************** ***" +# echo "Using temporary directory ${DIR}" + +# echo "=> Setting up node version required for this env: ${NODE_VERSION}" +# echo "=> Current dir 1:" +# pwd + +# # setting up correct version of node +# nvm install ${NODE_VERSION} +# nvm use ${NODE_VERSION} + +# # generate skeleton app +# npm init @rancher/extension@${TAG} ${SKELETON_APP_NAME} --app-name test-app | cat +# cd ${SKELETON_APP_NAME} + +# # install dependencies +# yarn install + +# # test build of pkg inside skeleton app +# yarn build-pkg ${SKELETON_APP_NAME} | cat + +# echo "=> Current dir 2:" +# pwd + +# if [ $UPDATE == "true" ]; then +# echo "*** ***************************************** ***" +# echo "*** Testing FULL UPGRADE path for extensions ***" +# echo "*** ***************************************** ***" +# echo "=> Testing UPGRADE from legacy-v1 to legacy-v2" + +# echo "=> Current dir 3:" +# pwd + +# git init +# #when doing git init, we are sent to .git folder +# cd .. +# cd ${SKELETON_APP_NAME} + +# echo "=> Current dir 4:" +# pwd + +# npm init @rancher/extension@legacy-v2 -- --update + +# rm -rf node_modules +# rm -rf yarn.lock + +# yarn install + +# yarn build-pkg ${SKELETON_APP_NAME} | cat + +# echo "*** ***************************************** ***" +# echo "*** Testing UPGRADE from legacy-v2 to latest ***" +# echo "*** ***************************************** ***" + +# echo "=> Updating node version required for last leg of upgrade path: v20" + +# nvm install v20 +# nvm use v20 + +# npm init @rancher/extension -- --migrate + +# rm -rf node_modules +# rm -rf yarn.lock + +# yarn install + +# yarn build-pkg ${SKELETON_APP_NAME} | cat +# fi + +# echo "Cleaning temporary dir" +# cd ${DIR} + +# echo "Removing folder ${DIR}" +# rm -rf ${DIR} +# } + +# # test creating an extension with latest shell releases + build +# # validate_tagged_extension_creator "legacy-v1" "v16" +# # validate_tagged_extension_creator "legacy-v2" "v16" +# # validate_tagged_extension_creator "latest" "v20" + +# # test update paths + build +# validate_tagged_extension_creator "legacy-v1" "v16" "true" \ No newline at end of file diff --git a/.github/workflows/test-extension-workflows-master.yml b/.github/workflows/test-extension-workflows-master.yml index 1862156e3e1..70a65a57aa7 100644 --- a/.github/workflows/test-extension-workflows-master.yml +++ b/.github/workflows/test-extension-workflows-master.yml @@ -31,7 +31,7 @@ jobs: - name: Retrieve Shell and Creators versions run: .github/workflows/scripts/test-extensions-creators-build.sh id: test-extensions-and-creators - shell: bash + shell: sh # test-extensions-build-legacy-v1: # runs-on: ubuntu-latest # outputs: