Skip to content

Commit

Permalink
create nightly tests for extension workflows in branch 'master' + adj…
Browse files Browse the repository at this point in the history
…ustments needed for the workflows in test to be testable
  • Loading branch information
aalves08 committed Nov 13, 2024
1 parent 267a31e commit 7b82d00
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 13 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/build-extension-catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,43 @@ on:
tagged_release:
required: false
type: string
is_test:
required: false
type: string
test_ext_repo:
required: false
type: string
test_ext_branch:
required: false
type: string
secrets:
registry_token:
required: true
outputs:
build-extension-catalog-job-status:
value: ${{ jobs.build-extension-catalog.outputs.build-status }}

jobs:
build-extension-catalog:
name: Build container image
if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') || inputs.is_test == 'true'
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
packages: write

outputs:
build-status: ${{ job.status }}
steps:
- name: Checkout repository
- if: inputs.is_test == 'true'
name: Checkout repository (test flow)
uses: actions/checkout@v4
with:
repository: rancher/${{ inputs.test_ext_repo }}
ref: ${{ inputs.test_ext_branch }}

- if: inputs.is_test != 'true'
name: Checkout repository (normal flow)
uses: actions/checkout@v4

- name: Enable Corepack
Expand Down Expand Up @@ -60,7 +81,7 @@ jobs:
run: yarn

- name: Parse Extension Name
if: github.ref_type == 'tag'
if: github.ref_type == 'tag' || inputs.is_test == 'true'
id: parsed-name
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -69,7 +90,13 @@ jobs:
- name: Build and push UI image
run: |
publish="yarn publish-pkgs -cp -r ${{ inputs.registry_target }} -o ${{ github.repository_owner }}"
publish="yarn publish-pkgs -c"
if [[ "${{ inputs.is_test }}" != "true" ]]; then
publish="$publish -p"
fi
publish="$publish -r ${{ inputs.registry_target }} -o ${{ github.repository_owner }}"
if [[ -n "${{ inputs.tagged_release }}" ]]; then
publish="$publish -t ${{ inputs.tagged_release }}"
Expand Down
41 changes: 36 additions & 5 deletions .github/workflows/build-extension-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ on:
tagged_release:
required: true
type: string
is_test:
required: false
type: string
test_ext_repo:
required: false
type: string
test_ext_branch:
required: false
type: string
outputs:
build-job-status:
value: ${{ jobs.build-extension-artifact.outputs.build-status }}
release-job-status:
value: ${{ jobs.release.outputs.release-status }}

env:
ACTIONS_RUNNER_DEBUG: false
Expand All @@ -26,8 +40,19 @@ jobs:
permissions:
actions: write
contents: read
outputs:
build-status: ${{ job.status }}
steps:
- name: Checkout
- if: inputs.is_test == 'true'
name: Checkout (test flow)
uses: actions/checkout@v4
with:
repository: rancher/${{ inputs.test_ext_repo }}
ref: ${{ inputs.test_ext_branch }}
fetch-depth: 0

- if: inputs.is_test != 'true'
name: Checkout (normal flow)
uses: actions/checkout@v4
with:
fetch-depth: 0
Expand Down Expand Up @@ -55,7 +80,7 @@ jobs:
run: yarn

- name: Parse Extension Name
if: github.ref_type == 'tag'
if: github.ref_type == 'tag' || inputs.is_test == 'true'
id: parsed-name
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -72,25 +97,31 @@ jobs:
publish="$publish -t ${{ inputs.tagged_release }}"
fi
if [[ "${{ inputs.is_test }}" == "true" ]]; then
publish="$publish -f"
fi
$publish
- name: Upload charts artifact
if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') || inputs.is_test == 'true'
uses: actions/upload-artifact@v3
with:
name: charts
path: tmp

release:
name: Release Build
if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
if: github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') || inputs.is_test != 'true'
needs: build-extension-artifact
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
deployments: write
pages: write
outputs:
release-status: ${{ job.status }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -119,4 +150,4 @@ jobs:
charts_dir: ./charts/*
env:
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
CR_SKIP_EXISTING: true
CR_SKIP_EXISTING: true
35 changes: 32 additions & 3 deletions .github/workflows/release-shell-pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,43 @@ on:
tags:
- 'shell-pkg-v*'
- 'creators-pkg-v*'
workflow_call:
inputs:
tag:
required: false
type: string
is_test:
required: false
type: string
test_branch:
required: false
type: string
outputs:
build-release-shell-creators-status:
value: ${{ jobs.build.outputs.build-status }}

jobs:

build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: github.repository == 'rancher/dashboard' && (github.event_name == 'workflow_call' || (github.event_name == 'push' && github.event.ref == 'refs/tags/${{ github.ref_name }}'))
outputs:
build-status: ${{ job.status }}
steps:
- uses: actions/checkout@v3
- if: inputs.is_test == 'true' && inputs.test_branch != ''
name: Checkout (test flow)
uses: actions/checkout@v3
with:
persist-credentials: false
ref: ${{ inputs.test_branch }}
fetch-depth: 0

- if: inputs.is_test != 'true'
name: Checkout (normal flow)
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
Expand All @@ -29,7 +57,7 @@ jobs:

- name: Check Tags Version Matching
env:
TAG: ${{github.ref_name}}
TAG: ${{ inputs.tag || github.ref_name }}
run: ./.github/workflows/scripts/check-package-tag-version.sh
shell: bash

Expand Down Expand Up @@ -59,5 +87,6 @@ jobs:
- name: Publish Shell Package to npm
run: ./shell/scripts/publish-shell.sh --npm
env:
TAG: ${{github.ref_name}}
TAG: ${{ inputs.tag || github.ref_name }}
DRY_RUN: ${{ inputs.is_test }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
117 changes: 117 additions & 0 deletions .github/workflows/test-extension-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Test Extension workflows

on:
schedule:
- cron: "0 0 * * *"

defaults:
run:
shell: bash
working-directory: ./

jobs:
retrieve-tags-master:
runs-on: ubuntu-latest
outputs:
SHELL_TAG: ${{ steps.retrieve-data.outputs.SHELL_TAG }}
CREATORS_TAG: ${{ steps.retrieve-data.outputs.CREATORS_TAG }}
ECI_TAG: ${{ steps.retrieve-data.outputs.ECI_TAG }}
EXTENSIONS_TAG: ${{ steps.retrieve-data.outputs.EXTENSIONS_TAG }}
CURR_JOB_ID: ${{ github.job }}
tags-job-status: ${{ job.status }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: master

- name: Retrieve Shell and Creators versions
run: source ./shell/scripts/retrieve-versions.sh
id: retrieve-data
shell: bash
test-build-extension-charts-master:
needs: retrieve-tags-master
uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@master
permissions:
actions: write
contents: write
deployments: write
pages: write
with:
target_branch: 'gh-pages'
tagged_release: ${{ needs.retrieve-tags-master.outputs.EXTENSIONS_TAG }}
is_test: 'true'
test_ext_repo: 'ui-plugin-examples'
test_ext_branch: 'main'
test-build-extension-catalog-master:
needs: retrieve-tags-master
uses: rancher/dashboard/.github/workflows/build-extension-catalog.yml@master
permissions:
actions: write
contents: read
packages: write
with:
registry_target: ghcr.io
registry_user: ${{ github.actor }}
tagged_release: ${{ needs.retrieve-tags-master.outputs.ECI_TAG }}
is_test: 'true'
test_ext_repo: 'ui-plugin-examples'
test_ext_branch: 'main'
secrets:
registry_token: ${{ secrets.GITHUB_TOKEN }}
test-release-shell-pkg-master:
needs: retrieve-tags-master
uses: rancher/dashboard/.github/workflows/release-shell-pkg.yaml@master
with:
is_test: 'true'
test_branch: 'master'
tag: ${{ needs.retrieve-tags-master.outputs.SHELL_TAG }}
test-release-creators-pkg-master:
needs: retrieve-tags-master
uses: rancher/dashboard/.github/workflows/release-shell-pkg.yaml@master
with:
is_test: 'true'
test_branch: 'master'
tag: ${{ needs.retrieve-tags-master.outputs.CREATORS_TAG }}

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]
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-charts-master.outputs.release-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 }}")
if [[ ${OUTPUT_ARRAY[@]} =~ "failure" ]]; then
MSG_PREFIX="Workflows testing for extensions failed! 🆘"
else
MSG_PREFIX="Workflows 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_CHART_RELEASE_OUTPUT_STRING="status for test-build-extension-charts-master - release => ${{ needs.test-build-extension-charts-master.outputs.release-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 }}"
echo $TAGS_OUTPUT_STRING
echo $EXT_CHART_BUILD_OUTPUT_STRING
echo $EXT_CHART_RELEASE_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_CHART_RELEASE_OUTPUT_STRING ::: $EXT_CATALOG_BUILD_OUTPUT_STRING ::: $RELEASE_SHELL_PKG_OUTPUT_STRING ::: $RELEASE_CREATORS_PKG_OUTPUT_STRING"
echo "message sent: $MSG"
curl -X POST -H 'Content-type: application/json; charset=utf-8' \
--data '{ branch: "master", message: $MSG }' $SLACK_WEBHOOK

0 comments on commit 7b82d00

Please sign in to comment.