Skip to content

Commit

Permalink
Test builds of extensions with latest published shell version in all …
Browse files Browse the repository at this point in the history
…relevant branches (#12814)

* update

* delete file that shouldnt be there

* create nightly test to cover skeleton app generation and update paths + update master workflow + improve slack message output
  • Loading branch information
aalves08 authored Dec 5, 2024
1 parent 6c170fc commit 04a8857
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 16 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/scripts/test-extensions-creators-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/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

cat package.json

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

# debug changes done via migration script
cat package.json

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"
43 changes: 27 additions & 16 deletions .github/workflows/test-extension-workflows-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ defaults:
working-directory: ./

jobs:
test-extensions-creators-and-update-paths:
runs-on: ubuntu-latest
outputs:
test-extensions-creators-and-update-paths-job-status: ${{ job.status }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Retrieve Shell and Creators versions
run: .github/workflows/scripts/test-extensions-creators-build.sh
id: test-extensions-and-creators
shell: bash
retrieve-tags-master:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -77,37 +89,36 @@ jobs:
slack-message:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [retrieve-tags-master, test-build-extension-charts-master, test-build-extension-catalog-master, test-release-shell-pkg-master, test-release-creators-pkg-master]
needs: [test-extensions-creators-and-update-paths, retrieve-tags-master, test-build-extension-charts-master, test-build-extension-catalog-master, test-release-shell-pkg-master, test-release-creators-pkg-master]
steps:
- name: Slack message for workflow
if: always()
shell: bash
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL_EXT_WFS }}
run: |
OUTPUT_ARRAY=("${{ needs.retrieve-tags-master.outputs.tags-job-status }}" "${{ needs.test-build-extension-charts-master.outputs.build-job-status }}" "${{ needs.test-build-extension-catalog-master.outputs.build-extension-catalog-job-status }}" "${{ needs.test-release-shell-pkg-master.outputs.build-release-shell-creators-status }}" "${{ needs.test-release-creators-pkg-master.outputs.build-release-shell-creators-status }}")
OUTPUT_ARRAY=("${{ needs.test-extensions-creators-and-update-paths-job-status.outputs.test-legacy-v1-job-status }}" "${{ needs.retrieve-tags-master.outputs.tags-job-status }}" "${{ needs.test-build-extension-charts-master.outputs.build-job-status }}" "${{ needs.test-build-extension-catalog-master.outputs.build-extension-catalog-job-status }}" "${{ needs.test-release-shell-pkg-master.outputs.build-release-shell-creators-status }}" "${{ needs.test-release-creators-pkg-master.outputs.build-release-shell-creators-status }}")
JOB_NAME_ARRAY=("test-extensions-creators-and-update-paths-job-status" "retrieve-tags-master" "test-build-extension-charts-master" "test-build-extension-catalog-master" "test-release-shell-pkg-master" "test-release-creators-pkg-master")
if [[ ${OUTPUT_ARRAY[@]} =~ "failure" ]]; then
MSG_PREFIX="Workflows testing for extensions failed! 🆘"
MSG_PREFIX="\nWorkflows testing for extensions failed! 🆘"
else
MSG_PREFIX="Workflows testing for extensions succedded! ✅"
MSG_PREFIX="\nWorkflows testing for extensions succedded! ✅"
fi
echo "message prefix ::: $MSG_PREFIX"
TAGS_OUTPUT_STRING="status for retrieve-tags-master - build => ${{ needs.retrieve-tags-master.outputs.tags-job-status }}"
EXT_CHART_BUILD_OUTPUT_STRING="status for test-build-extension-charts-master - build => ${{ needs.test-build-extension-charts-master.outputs.build-job-status }}"
EXT_CATALOG_BUILD_OUTPUT_STRING="status for test-build-extension-catalog-master - build => ${{ needs.test-build-extension-catalog-master.outputs.build-extension-catalog-job-status }}"
RELEASE_SHELL_PKG_OUTPUT_STRING="status for test-release-shell-pkg-master - release => ${{ needs.test-release-shell-pkg-master.outputs.build-release-shell-creators-status }}"
RELEASE_CREATORS_PKG_OUTPUT_STRING="status for test-release-creators-pkg-master - release => ${{ needs.test-release-creators-pkg-master.outputs.build-release-shell-creators-status }}"
MSG="$MSG_PREFIX"
echo $TAGS_OUTPUT_STRING
echo $EXT_CHART_BUILD_OUTPUT_STRING
echo $EXT_CATALOG_BUILD_OUTPUT_STRING
echo $RELEASE_SHELL_PKG_OUTPUT_STRING
echo $RELEASE_CREATORS_PKG_OUTPUT_STRING
MSG="$MSG_PREFIX ::: $TAGS_OUTPUT_STRING ::: $EXT_CHART_BUILD_OUTPUT_STRING ::: $EXT_CATALOG_BUILD_OUTPUT_STRING ::: $RELEASE_SHELL_PKG_OUTPUT_STRING ::: $RELEASE_CREATORS_PKG_OUTPUT_STRING"
for index in "${!OUTPUT_ARRAY[@]}"
do
if [[ ${OUTPUT_ARRAY[$index]} == "failure" ]]; then
EMOJI="🆘"
else
EMOJI="✅"
fi
MSG="$MSG \n::: Status for ${JOB_NAME_ARRAY[$index]} job => ${OUTPUT_ARRAY[$index]} $EMOJI"
done
echo "message sent: $MSG"
Expand Down

0 comments on commit 04a8857

Please sign in to comment.