Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aalves08 committed Dec 4, 2024
1 parent db5cd91 commit 011e558
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 62 deletions.
39 changes: 22 additions & 17 deletions .github/workflows/scripts/test-extensions-creators-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

set -eo pipefail

EXTERNAL_TAG=$1
EXTERNAL_UPDATE=$2

if [ -z "${EXTERNAL_TAG}" ]; then
echo "Missing tag set on running this script! Cannot run without a tag!"
exit 1
fi

validate_tagged_extension_creator() {
TAG=$1
NODE_VERSION=$2
UPDATE=$3

if [ -n "$2" ]; then
echo "will also cover the update path and migration on this run"
if [ -n "$UPDATE" ]; then
echo "*** Will also cover the UPDATE path and MIGRATION on this run! ***"
UPDATE="true"
fi

Expand All @@ -24,6 +19,11 @@ validate_tagged_extension_creator() {
echo "*** Verifying extension creator for tag ::: ${TAG} ***"
echo "Using temporary directory ${DIR}"

echo "=> Setting up node version required for this env: ${NODE_VERSION}"

nvm install ${NODE_VERSION}
nvm use ${NODE_VERSION}

# TODO: change yarn create to use the new tag approach (jordon to tweak code upstream)
npm init @rancher/extension@${TAG} test-pkg --app-name test-app | cat

Expand All @@ -35,10 +35,10 @@ validate_tagged_extension_creator() {


if [ $UPDATE == "true" ]; then
echo "*** Testing full update path for extensions ***"
echo "Testing update from legacy-v1 to legacy-v2"
echo "*** Testing FULL UPGRADE path for extensions ***"
echo "Testing UPGRADE from legacy-v1 to legacy-v2"

npm init @rancher/extension@legacy-v2 -- --update
npm init @rancher/extension@legacy-v2 -- --update -f

rm -rf node_modules
rm -rf yarn.lock
Expand All @@ -47,7 +47,12 @@ validate_tagged_extension_creator() {

yarn build-pkg test-pkg | cat

echo "Testing update from legacy-v2 to latest"
echo "*** Testing UPGRADE from legacy-v2 to latest ***"

echo "=> Updating node version required for last leg of upgrade path: v20"

nvm install v20
nvm use v20

npm init @rancher/extension -- --migrate

Expand All @@ -67,9 +72,9 @@ validate_tagged_extension_creator() {
}

# test creating an extension with latest shell releases + build
validate_tagged_extension_creator ${EXTERNAL_TAG} ${EXTERNAL_UPDATE}
# validate_tagged_extension_creator "legacy-v2"
# validate_tagged_extension_creator "latest"
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" "true"
validate_tagged_extension_creator "legacy-v1" "v16" "true"
151 changes: 106 additions & 45 deletions .github/workflows/test-extension-workflows-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,63 +18,82 @@ defaults:
working-directory: ./

jobs:
test-extensions-build-legacy-v1:
test-extensions-creators-and-update-paths:
runs-on: ubuntu-latest
outputs:
test-legacy-v1-job-status: ${{ job.status }}
test-extensions-creators-and-update-paths-job-status: ${{ job.status }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: 12158-test-latest-published-versions-shell

- name: Setup Nodejs with yarn caching
uses: actions/setup-node@v4
with:
node-version: '16'
# - name: Setup Nodejs with yarn caching
# uses: actions/setup-node@v4
# with:
# node-version: '16'

- name: Retrieve Shell and Creators versions
run: .github/workflows/scripts/test-extensions-creators-build.sh legacy-v1 true
run: .github/workflows/scripts/test-extensions-creators-build.sh
id: test-extensions-and-creators
shell: bash
test-extensions-build-legacy-v2:
runs-on: ubuntu-latest
outputs:
test-legacy-v2-job-status: ${{ job.status }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: 12158-test-latest-published-versions-shell
# test-extensions-build-legacy-v1:
# runs-on: ubuntu-latest
# outputs:
# test-legacy-v1-job-status: ${{ job.status }}
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# ref: 12158-test-latest-published-versions-shell

- name: Setup Nodejs with yarn caching
uses: actions/setup-node@v4
with:
node-version: '16'
# - name: Setup Nodejs with yarn caching
# uses: actions/setup-node@v4
# with:
# node-version: '16'

- name: Retrieve Shell and Creators versions
run: .github/workflows/scripts/test-extensions-creators-build.sh legacy-v2
id: test-extensions-and-creators
shell: bash
test-extensions-build-latest:
runs-on: ubuntu-latest
outputs:
test-latest-job-status: ${{ job.status }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: 12158-test-latest-published-versions-shell
# - name: Retrieve Shell and Creators versions
# run: .github/workflows/scripts/test-extensions-creators-build.sh legacy-v1 true
# id: test-extensions-and-creators
# shell: bash
# test-extensions-build-legacy-v2:
# runs-on: ubuntu-latest
# outputs:
# test-legacy-v2-job-status: ${{ job.status }}
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# ref: 12158-test-latest-published-versions-shell

- name: Setup Nodejs with yarn caching
uses: actions/setup-node@v4
with:
node-version: '16'
# - name: Setup Nodejs with yarn caching
# uses: actions/setup-node@v4
# with:
# node-version: '16'

- name: Retrieve Shell and Creators versions
run: .github/workflows/scripts/test-extensions-creators-build.sh latest
id: test-extensions-and-creators
shell: bash
# - name: Retrieve Shell and Creators versions
# run: .github/workflows/scripts/test-extensions-creators-build.sh legacy-v2
# id: test-extensions-and-creators
# shell: bash
# test-extensions-build-latest:
# runs-on: ubuntu-latest
# outputs:
# test-latest-job-status: ${{ job.status }}
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# ref: 12158-test-latest-published-versions-shell

# - name: Setup Nodejs with yarn caching
# uses: actions/setup-node@v4
# with:
# node-version: '16'

# - name: Retrieve Shell and Creators versions
# run: .github/workflows/scripts/test-extensions-creators-build.sh latest
# id: test-extensions-and-creators
# shell: bash
# retrieve-tags-master:
# runs-on: ubuntu-latest
# outputs:
Expand Down Expand Up @@ -179,19 +198,61 @@ jobs:
# curl -X POST -H 'Content-type: application/json; charset=utf-8' \
# --data "{\"branch\": \"master\", \"message\": \"$MSG\", \"workflow_run\": ${{ github.run_id }} }" $SLACK_WEBHOOK

###################
# THIS ONE WORKS JUST FINE!!!!!
###################
# slack-message:
# if: ${{ always() }}
# runs-on: ubuntu-latest
# needs: [test-extensions-build-legacy-v1, test-extensions-build-legacy-v2, test-extensions-build-latest]
# steps:
# - name: Slack message for workflow
# if: always()
# shell: bash
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL_EXT_WFS }}
# run: |
# OUTPUT_ARRAY=("${{ needs.test-extensions-build-legacy-v1.outputs.test-legacy-v1-job-status }}" "${{ needs.test-extensions-build-legacy-v2.outputs.test-legacy-v2-job-status }}" "${{ needs.test-extensions-build-latest.outputs.test-latest-job-status }}")
# JOB_NAME_ARRAY=("test-extensions-build-legacy-v1 job" "test-extensions-build-legacy-v2 job" "test-extensions-build-latest job")

# if [[ ${OUTPUT_ARRAY[@]} =~ "failure" ]]; then
# MSG_PREFIX="\nWorkflows testing for extensions failed! πŸ†˜"
# else
# MSG_PREFIX="\nWorkflows testing for extensions succedded! βœ…"
# fi

# echo "message prefix ::: $MSG_PREFIX"

# MSG_OUTPUT="$MSG_PREFIX"

# for index in "${!OUTPUT_ARRAY[@]}"
# do
# if [[ ${OUTPUT_ARRAY[$index]} == "failure" ]]; then
# EMOJI="πŸ†˜"
# else
# EMOJI="βœ…"
# fi
# MSG_OUTPUT="$MSG_OUTPUT \n::: Status for ${JOB_NAME_ARRAY[$index]} => ${OUTPUT_ARRAY[$index]} $EMOJI"
# done

# echo "message sent: $MSG_OUTPUT"

# curl -X POST -H 'Content-type: application/json; charset=utf-8' \
# --data "{\"branch\": \"master\", \"message\": \"$MSG\", \"workflow_run\": ${{ github.run_id }} }" $SLACK_WEBHOOK

slack-message:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [test-extensions-build-legacy-v1, test-extensions-build-legacy-v2, test-extensions-build-latest]
needs: [test-extensions-creators-and-update-paths]
steps:
- name: Slack message for workflow
if: always()
shell: bash
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL_EXT_WFS }}
run: |
OUTPUT_ARRAY=("${{ needs.test-extensions-build-legacy-v1.outputs.test-legacy-v1-job-status }}" "${{ needs.test-extensions-build-legacy-v2.outputs.test-legacy-v2-job-status }}" "${{ needs.test-extensions-build-latest.outputs.test-latest-job-status }}")
JOB_NAME_ARRAY=("test-extensions-build-legacy-v1 job" "test-extensions-build-legacy-v2 job" "test-extensions-build-latest job")
OUTPUT_ARRAY=("${{ needs.test-extensions-creators-and-update-paths-job-status.outputs.test-legacy-v1-job-status }}")
JOB_NAME_ARRAY=("test-extensions-creators-and-update-paths-job-status job")
if [[ ${OUTPUT_ARRAY[@]} =~ "failure" ]]; then
MSG_PREFIX="\nWorkflows testing for extensions failed! πŸ†˜"
Expand All @@ -216,4 +277,4 @@ jobs:
echo "message sent: $MSG_OUTPUT"
curl -X POST -H 'Content-type: application/json; charset=utf-8' \
--data "{\"branch\": \"master\", \"message\": \"$MSG\", \"workflow_run\": ${{ github.run_id }} }" $SLACK_WEBHOOK
--data "{\"branch\": \"master\", \"message\": \"$MSG_OUTPUT\", \"workflow_run\": ${{ github.run_id }} }" $SLACK_WEBHOOK

0 comments on commit 011e558

Please sign in to comment.