Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: deploy integration TK for develop cluster #567

Merged
merged 12 commits into from
Jul 13, 2023
72 changes: 36 additions & 36 deletions .github/workflows/helm-deploy-testkube-charts-stage-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Releasing Testkube Helm charts to Stage k8s Cluster.

concurrency: staging_cluster
concurrency: develop_cluster

on:
push:
Expand All @@ -11,9 +11,9 @@ on:

env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER_NAME_STAGE: ${{ secrets.GKE_CLUSTER_NAME_STAGE }} # Add your cluster name here.
GKE_ZONE_STAGE: ${{ secrets.GKE_ZONE_STAGE }} # Add your cluster zone here.
DEPLOYMENT_NAME: testkube # Add your deployment name here.
GKE_CLUSTER_NAME: ${{ secrets.GKE_CLUSTER_NAME_DEVELOP }} # Add your cluster name here.
GKE_ZONE: ${{ secrets.GKE_ZONE_DEVELOP }} # Add your cluster zone here.
DEPLOYMENT_NAME: testkube-integration # Add your deployment name here.
ENV: stage


Expand All @@ -40,8 +40,8 @@ jobs:

- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ env.GKE_CLUSTER_NAME_STAGE }}
location: ${{ env.GKE_ZONE_STAGE }}
cluster_name: ${{ env.GKE_CLUSTER_NAME }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}

- name: Install Helm
Expand All @@ -57,25 +57,25 @@ jobs:
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
echo ::set-output name=operator_image_tag::$(kubectl get deployment testkube-operator-controller-manager -o=jsonpath='{$.spec.template.spec.containers[1].image}' -n testkube | awk -F':' '{print $2}') || exit 1
echo ::set-output name=dashboard_image_tag::$(kubectl get deployment testkube-dashboard -o=jsonpath='{$.spec.template.spec.containers[:1].image}' -n ${{ env.DEPLOYMENT_NAME }} | awk -F':' '{print $2}') || exit 1

- name: Deploy helm chart to Integration Cluster
- name: Deploy helm chart to Develop Cluster
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=${{ steps.vars.outputs.operator_image_tag }} --set testkube-dashboard.image.tag=${{ steps.vars.outputs.dashboard_image_tag }} --set testkube-api.image.tag=${{ steps.vars.outputs.api_image_tag }}
helm upgrade --debug --install --atomic --timeout 180s testkube ./charts/testkube --namespace ${{ env.DEPLOYMENT_NAME }} --create-namespace --values ./charts/testkube/values-${{ env.ENV }}.yaml --set testkube-operator.image.tag=${{ steps.vars.outputs.operator_image_tag }} --set testkube-dashboard.image.tag=${{ steps.vars.outputs.dashboard_image_tag }} --set testkube-api.image.tag=${{ steps.vars.outputs.api_image_tag }} --set testkube-api.multinamespace.enabled=true --set testkube-operator.enabled=false

notify_slack_if_deploy_stage_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.
- name: Slack Notification if the helm release deployment to ${{ env.GKE_CLUSTER_NAME }} GKE into ${{ env.DEPLOYMENT_NAME }} namespace 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_STAGE }} GKE :party_blob:!
SLACK_TITLE: Helm chart release successfully deployed to ${{ env.GKE_CLUSTER_NAME }} GKE into ${{ env.DEPLOYMENT_NAME }} namespace :party_blob:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Expand All @@ -86,19 +86,19 @@ jobs:
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.
- name: Slack Notification if the helm release deployment to ${{ env.GKE_CLUSTER_NAME }} GKE into ${{ env.DEPLOYMENT_NAME }} namespace 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_STAGE }} GKE! :boom:!
SLACK_TITLE: Helm chart release failed to deploy to ${{ env.GKE_CLUSTER_NAME }} GKE into ${{ env.DEPLOYMENT_NAME }} namespace :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> TestKube"

test_suite_run_stage:
test_suite_run:
name: test suite for GKE cluster
runs-on: ubuntu-latest
needs: release_charts_if_image_updated
Expand All @@ -117,12 +117,12 @@ jobs:
# 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_STAGE }}
location: ${{ env.GKE_ZONE_STAGE }}
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
run: bash <(curl -sSLf https://get.testkube.io) beta && kubectl testkube disable telemetry --namespace ${{ env.DEPLOYMENT_NAME }}

- name: Checkout tests from main Testkube repo
uses: actions/checkout@v3
Expand All @@ -132,67 +132,67 @@ jobs:

- 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
run: chmod +x ./test/scripts/executor-tests/run.sh && ./test/scripts/executor-tests/run.sh -d -c -s -n ${{ env.DEPLOYMENT_NAME }} # (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
kubectl delete test sanity --ignore-not-found=true --namespace ${{ env.DEPLOYMENT_NAME }}
kubectl delete secret sanity-secrets --ignore-not-found=true --namespace ${{ env.DEPLOYMENT_NAME }}
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 --namespace ${{ env.DEPLOYMENT_NAME }}

- name: Run Postman sanity tests
run: kubectl testkube run test sanity -f --git-branch develop
run: kubectl testkube run test sanity -f --git-branch develop --namespace ${{ env.DEPLOYMENT_NAME }}

- 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
kubectl delete test dashboard-e2e-tests --ignore-not-found=true --namespace ${{ env.DEPLOYMENT_NAME }}
kubectl apply -f ./test/dashboard-e2e/crd/crd.yaml --namespace ${{ env.DEPLOYMENT_NAME }}

- 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
kubectl delete testsuite staging-testsuite --ignore-not-found=true --namespace ${{ env.DEPLOYMENT_NAME }}
kubectl testkube create testsuite -f ./test/suites/staging-testsuite.json --name staging-testsuite --namespace ${{ env.DEPLOYMENT_NAME }}

- name: Run staging testsuite
run: kubectl testkube run testsuite staging-testsuite -f --git-branch develop
run: kubectl testkube run testsuite staging-testsuite -f --git-branch develop --namespace ${{ env.DEPLOYMENT_NAME }}

notify_slack_if_test_suite_stage_succeeds:
runs-on: ubuntu-latest
needs: test_suite_run_stage
needs: test_suite_run
steps:
- name: Slack Notification if the test suite run on STAGE GKS succeeded.
- name: Slack Notification if the test suite run on ${{ env.GKE_CLUSTER_NAME }} GKE in ${{ env.DEPLOYMENT_NAME }} namespace succeeded.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run_stage.result }} # or a specific color like 'good' or '#ff00ff'
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_STAGE }} GKE :party_blob:!
SLACK_TITLE: Test suite successfully run on ${{ env.GKE_CLUSTER_NAME }} GKE in ${{ env.DEPLOYMENT_NAME }} namespace :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_stage
if: always() && (needs.test_suite_run_stage.result == 'failure')
needs: test_suite_run
if: always() && (needs.test_suite_run.result == 'failure')
steps:
- name: Slack Notification if the test suite run on ${{ env.ENV }} GKS failed.
- name: Slack Notification if the test suite run on ${{ env.GKE_CLUSTER_NAME }} GKE in ${{ env.DEPLOYMENT_NAME }} namespace failed.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: testkube-logs
SLACK_COLOR: ${{ needs.test_suite_run_stage.result }} # or a specific color like 'good' or '#ff00ff'
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_STAGE }} GKE! :boom:!
SLACK_TITLE: Test suite FAILED to run on ${{ env.GKE_CLUSTER_NAME }} GKE in ${{ env.DEPLOYMENT_NAME }} namespace! :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Expand Down
Loading