Skip to content

trigger-workflow-api-develop #1430

trigger-workflow-api-develop

trigger-workflow-api-develop #1430

name: Releasing Testkube Helm charts to Develop k8s Cluster on Repository Dispatch
concurrency: develop_cluster
on:
repository_dispatch:
types:
[
trigger-workflow-api-develop,
trigger-workflow-operator-develop,
]
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER_NAME: ${{ secrets.GKE_CLUSTER_NAME_DEVELOP }}
GKE_ZONE: ${{ secrets.GKE_ZONE_DEVELOP }}
DEPLOYMENT_NAME: testkube
ENV: develop
jobs:
release_charts_if_image_updated:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.client_payload.ref }}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
- run: |-
gcloud --quiet auth configure-docker
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ env.GKE_CLUSTER_NAME }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Installing repositories
run: |
helm repo add bitnami https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
- name: Get image tag of Testkube APi, Operator
id: vars
run: |
echo ::set-output name=api_image_tag::$(kubectl get deployment testkube-api-server -o=jsonpath='{$.spec.template.spec.containers[:1].image}' -n ${{ env.DEPLOYMENT_NAME }} | awk -F':' '{print $2}') || exit 1
echo ::set-output name=operator_image_tag::$(kubectl get deployment testkube-operator-controller-manager -o=jsonpath='{$.spec.template.spec.containers[1].image}' -n ${{ env.DEPLOYMENT_NAME }} | awk -F':' '{print $2}') || exit 1
- name: Deploy if Testkube API image is updated
if: ${{ github.event.client_payload.image_tag_api }}
run: |
helm dependency update ./charts/testkube
helm upgrade --debug --install --atomic --timeout 180s ${{ env.DEPLOYMENT_NAME }} ./charts/testkube --namespace ${{ env.DEPLOYMENT_NAME }} --create-namespace --values ./charts/testkube/values-${{ env.ENV }}.yaml --set testkube-api.image.tag=${{ github.event.client_payload.image_tag_api }} --set testkube-logs.image.tag=${{ github.event.client_payload.image_tag_api }} --set testkube-operator.image.tag=${{ steps.vars.outputs.operator_image_tag }} --set mongodb.livenessProbe.enabled=false --set mongodb.readinessProbe.enabled=false
- name: Deploy if Testkube Operator image is updated
if: ${{ github.event.client_payload.image_tag_operator }}
run: |
helm dependency update ./charts/testkube
helm upgrade --debug --install --atomic --timeout 180s ${{ env.DEPLOYMENT_NAME }} ./charts/testkube --namespace ${{ env.DEPLOYMENT_NAME }} --create-namespace --values ./charts/testkube/values-${{ env.ENV }}.yaml --set testkube-operator.image.tag=${{ github.event.client_payload.image_tag_operator }} --set testkube-api.image.tag=${{ steps.vars.outputs.api_image_tag }} --set testkube-logs.image.tag=${{ steps.vars.outputs.api_image_tag }} --set mongodb.livenessProbe.enabled=false --set mongodb.readinessProbe.enabled=false
notify_slack_if_deploy_succeeds:
runs-on: ubuntu-latest
needs: release_charts_if_image_updated
steps:
- name: Slack Notification if the helm release deployment to ${{ env.ENV }} GKS succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.release_charts_if_image_updated.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Helm chart release successfully deployed into ${{ env.GKE_CLUSTER_NAME }} GKE :party_blob:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
notify_slack_if_deploy_failed:
runs-on: ubuntu-latest
needs: release_charts_if_image_updated
if: always() && (needs.release_charts_if_image_updated.result == 'failure')
steps:
- name: Slack Notification if the helm release deployment to ${{ env.ENV }} GKS failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.release_charts_if_image_updated.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Helm chart release failed to deploy into ${{ env.GKE_CLUSTER_NAME }} GKE! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
test_suite_run:
name: test suite for GKE cluster
runs-on: ubuntu-latest
needs: release_charts_if_image_updated
steps:
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ env.GKE_CLUSTER_NAME }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Install testkube kubectl plugin and disable telemetry
run: bash <(curl -sSLf https://get.testkube.io) beta && kubectl testkube disable telemetry
- name: Checkout tests from main Testkube repo
uses: actions/checkout@v3
with:
repository: kubeshop/testkube
path: testkube-repo
- name: Executor tests - delete/create/schedule all executor tests
working-directory: ./testkube-repo
run: chmod +x ./test/scripts/executor-tests/run.sh && ./test/scripts/executor-tests/run.sh -d -c -s # (delete, create, schedule) - don't execute
- name: (Re)create Postman Sanity test (with CLI)
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl -n testkube delete test sanity --ignore-not-found=true
kubectl -n testkube delete secret sanity-secrets --ignore-not-found=true
kubectl testkube create test -f ./test/postman/TestKube-Sanity.postman_collection.json --name sanity --type postman/collection -v api_uri=http://testkube-api-server:8088 -v test_api_uri=http://testkube-api-server:8088 -v test_type=postman/collection -v test_name=fill-me -v execution_name=fill-me
- name: Run Postman sanity tests
run: kubectl testkube run test sanity -f --git-branch develop
- name: (Re)create Dashboard E2E tests (from CRD)
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl -n testkube delete test dashboard-e2e-tests --ignore-not-found=true
kubectl apply -f ./test/dashboard-e2e/crd/crd.yaml -ntestkube
- name: (Re)create staging testsuite
working-directory: ./testkube-repo
run: |-
# enabling debug mode
set -x
kubectl -n testkube delete testsuite staging-testsuite --ignore-not-found=true
kubectl testkube create testsuite -f ./test/suites/staging-testsuite.json --name staging-testsuite
- name: Run staging testsuite
run: kubectl testkube run testsuite staging-testsuite -f --git-branch develop
notify_slack_if_test_suite_succeeds:
runs-on: ubuntu-latest
needs: test_suite_run
steps:
- name: Slack Notification if the test suite run on ${{ env.ENV }} GKE succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Test suite successfully run against ${{ env.GKE_CLUSTER_NAME }} GKE :party_blob:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"
notify_slack_if_test_suite_failed:
runs-on: ubuntu-latest
needs: test_suite_run
if: always() && (needs.test_suite_run.result == 'failure')
steps:
- name: Slack Notification if the test suite run on ${{ env.ENV }} GKE failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run.result }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_TITLE: Test suite FAILED to run on ${{ env.GKE_CLUSTER_NAME }} GKE! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"