Testkube -49 #228
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Harbor Test Workflow | |
on: | |
pull_request: | |
types: [opened,reopened,synchronize,closed] | |
permissions: | |
contents: read | |
pull-requests: write | |
id-token: write | |
jobs: | |
# # Job to build-push harbor-core image | |
# build-harbor-core: | |
# name: Build and Push `harbor-core` Image | |
# runs-on: ubuntu-latest | |
# if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
# outputs: | |
# tags: ${{ steps.meta.outputs.tags }} | |
# steps: | |
# - name: Checkout git repo | |
# uses: actions/checkout@v3 | |
# with: | |
# repository: goharbor/harbor | |
# - name: Make versions dir | |
# run: | | |
# make compile | |
# - name: Make harbor_core | |
# run: | | |
# make compile_core | |
# - name: Generate UUID image name | |
# id: uuid | |
# run: echo "UUID_VOTE=$(uuidgen)" >> $GITHUB_ENV | |
# - name: Docker metadata | |
# id: meta | |
# uses: docker/metadata-action@v4 | |
# with: | |
# # An anonymous, emphemeral registry built on ttl.sh | |
# images: registry.uffizzi.com/${{ env.UUID_VOTE }} | |
# tags: type=raw,value=24h | |
# - name: Build and Push Image to Uffizzi Ephemeral Registry | |
# uses: docker/build-push-action@v3 | |
# with: | |
# no-cache: true | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# file: ./make/photon/core/Dockerfile | |
# context: . | |
# build-args: | | |
# harbor_base_image_version=dev | |
# harbor_base_namespace=goharbor | |
# npm_registry=https://registry.npmjs.org | |
# # Job to build-push harbor-portal image | |
# build-harbor-portal: | |
# name: Build and Push `harbor-portal` Image | |
# runs-on: ubuntu-latest | |
# if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
# outputs: | |
# tags: ${{ steps.meta.outputs.tags }} | |
# steps: | |
# - name: Checkout git repo | |
# uses: actions/checkout@v3 | |
# with: | |
# repository: goharbor/harbor | |
# - name: Generate UUID image name | |
# id: uuid | |
# run: echo "UUID_VOTE=$(uuidgen)" >> $GITHUB_ENV | |
# - name: Docker metadata | |
# id: meta | |
# uses: docker/metadata-action@v4 | |
# with: | |
# # An anonymous, emphemeral registry built on ttl.sh | |
# images: registry.uffizzi.com/${{ env.UUID_VOTE }} | |
# tags: type=raw,value=24h | |
# - name: Build and Push Image to Uffizzi Ephemeral Registry | |
# uses: docker/build-push-action@v3 | |
# with: | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# file: ./make/photon/portal/Dockerfile | |
# context: . | |
# build-args: | | |
# harbor_base_image_version=dev | |
# harbor_base_namespace=goharbor | |
# npm_registry=https://registry.npmjs.org | |
# - name: Echo image | |
# run: echo ${{ steps.meta.outputs.images }} | |
# # Job to build-push harbor-jobservice image | |
# build-harbor-jobservice: | |
# name: Build and Push `harbor-jobservice` Image | |
# runs-on: ubuntu-latest | |
# if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
# outputs: | |
# tags: ${{ steps.meta.outputs.tags }} | |
# steps: | |
# - name: Checkout git repo | |
# uses: actions/checkout@v3 | |
# with: | |
# repository: goharbor/harbor | |
# - name: Make harbor_jobservice file | |
# run: | | |
# make compile | |
# - name: Generate UUID image name | |
# id: uuid | |
# run: echo "UUID_VOTE=$(uuidgen)" >> $GITHUB_ENV | |
# - name: Docker metadata | |
# id: meta | |
# uses: docker/metadata-action@v4 | |
# with: | |
# # An anonymous, emphemeral registry built on ttl.sh | |
# images: registry.uffizzi.com/${{ env.UUID_VOTE }} | |
# tags: type=raw,value=24h | |
# - name: Build and Push Image to Uffizzi Ephemeral Registry | |
# uses: docker/build-push-action@v3 | |
# with: | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# file: ./make/photon/jobservice/Dockerfile | |
# context: . | |
# build-args: | | |
# harbor_base_image_version=dev | |
# harbor_base_namespace=goharbor | |
# npm_registry=https://registry.npmjs.org | |
# # Job to build-push harbor-registry image | |
# build-harbor-registry: | |
# name: Build and Push `harbor-registry` Image | |
# runs-on: ubuntu-latest | |
# if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
# outputs: | |
# tags: ${{ steps.meta.outputs.tags }} | |
# steps: | |
# - name: Checkout git repo | |
# uses: actions/checkout@v3 | |
# with: | |
# repository: goharbor/harbor | |
# - name: Make registry file | |
# run: | | |
# make build -e BUILDTARGET="_build_registry" | |
# - name: Generate UUID image name | |
# id: uuid | |
# run: echo "UUID_VOTE=$(uuidgen)" >> $GITHUB_ENV | |
# - name: Docker metadata | |
# id: meta | |
# uses: docker/metadata-action@v4 | |
# with: | |
# # An anonymous, emphemeral registry built on ttl.sh | |
# images: registry.uffizzi.com/${{ env.UUID_VOTE }} | |
# tags: type=raw,value=24h | |
# - name: Build and Push Image to Uffizzi Ephemeral Registry | |
# uses: docker/build-push-action@v3 | |
# with: | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# file: ./make/photon/registry/Dockerfile | |
# context: . | |
# build-args: | | |
# harbor_base_image_version=dev | |
# harbor_base_namespace=goharbor | |
# npm_registry=https://registry.npmjs.org | |
# # Job to build-push harbor-registryctl image | |
# build-harbor-registryctl: | |
# name: Build and Push `harbor-registryctl` Image | |
# runs-on: ubuntu-latest | |
# if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
# outputs: | |
# tags: ${{ steps.meta.outputs.tags }} | |
# steps: | |
# - name: Checkout git repo | |
# uses: actions/checkout@v3 | |
# with: | |
# repository: goharbor/harbor | |
# - name: Make registry file | |
# run: | | |
# make build -e BUILDTARGET="_build_registry" | |
# - name: Compile registryctl file | |
# run: | | |
# make compile_registryctl | |
# - name: Generate UUID image name | |
# id: uuid | |
# run: echo "UUID_VOTE=$(uuidgen)" >> $GITHUB_ENV | |
# - name: Docker metadata | |
# id: meta | |
# uses: docker/metadata-action@v4 | |
# with: | |
# # An anonymous, emphemeral registry built on ttl.sh | |
# images: registry.uffizzi.com/${{ env.UUID_VOTE }} | |
# tags: type=raw,value=24h | |
# - name: Build and Push Image to Uffizzi Ephemeral Registry | |
# uses: docker/build-push-action@v3 | |
# with: | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
# file: ./make/photon/registryctl/Dockerfile | |
# context: . | |
# build-args: | | |
# harbor_base_image_version=dev | |
# harbor_base_namespace=goharbor | |
# npm_registry=https://registry.npmjs.org | |
# uffizzi-cluster: | |
# name: Deploy to Uffizzi uCluster | |
# outputs: | |
# HARBOR_HOST: ${{ steps.ingress.outputs.HARBOR_HOST }} | |
# needs: | |
# - build-harbor-core | |
# - build-harbor-portal | |
# - build-harbor-jobservice | |
# - build-harbor-registry | |
# - build-harbor-registryctl | |
# if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v3 | |
# # Identify comment to be updated | |
# - name: Find comment for Ephemeral Environment | |
# uses: peter-evans/find-comment@v2 | |
# id: find-comment | |
# with: | |
# issue-number: ${{ github.event.pull_request.number }} | |
# comment-author: "github-actions[bot]" | |
# body-includes: pr-${{ github.event.pull_request.number }} | |
# direction: last | |
# # Create/Update comment with action deployment status | |
# - name: Create or Update Comment with Deployment Notification | |
# uses: peter-evans/create-or-update-comment@v2 | |
# id: notification | |
# with: | |
# comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
# issue-number: ${{ github.event.pull_request.number }} | |
# body: | | |
# ## Uffizzi Ephemeral Environment - Virtual Cluster | |
# :cloud: deploying ... | |
# :gear: Updating now by workflow run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). | |
# Download the Uffizzi CLI to interact with the upcoming virtual cluster | |
# https://docs.uffizzi.com/install | |
# edit-mode: replace | |
# # Create/Connect to Uffizzi Virtual Cluster | |
# - name: Connect to Virtual Cluster | |
# uses: UffizziCloud/cluster-action@main | |
# with: | |
# cluster-name: pr-${{ github.event.pull_request.number }} | |
# # server: https://app.qa-gke.uffizzi.com/ | |
# # Create/Update comment with action deployment status | |
# - name: Create or Update Comment with Deployment URL | |
# uses: peter-evans/create-or-update-comment@v2 | |
# with: | |
# comment-id: ${{ steps.notification.outputs.comment-id }} | |
# issue-number: ${{ github.event.pull_request.number }} | |
# body: | | |
# ## Uffizzi Ephemeral Environment - Virtual Cluster | |
# Your cluster `pr-${{ github.event.pull_request.number }}` was successfully created. Learn more about [Uffizzi virtual clusters](https://docs.uffizzi.com/virtual-clusters) | |
# To connect to this cluster, follow these steps: | |
# 1. Download and install the Uffizzi CLI from https://docs.uffizzi.com/install | |
# 2. Login to Uffizzi: `uffizzi login` | |
# 3. Update your kubeconfig: `uffizzi cluster update-kubeconfig pr-${{ github.event.pull_request.number }}`. This command will update your local `~/.kube/config`. | |
# If you want to provide an alternate location follow the optional step (the next step) instead. | |
# Optional: Update your kubeconfig: `uffizzi cluster update-kubeconfig pr-${{ github.event.pull_request.number }} --kubeconfig=[KUBECONFIG]`, replacing `[KUBECONFIG]` with the path to your kubeconfig file. | |
# After updating your kubeconfig, you can manage your cluster with `kubectl`, `kustomize`, `helm`, and other tools that use kubeconfig files: `kubectl get namespace --kubeconfig [KUBECONFIG]` | |
# edit-mode: replace | |
# # Apply Harbor Helm Chart | |
# - name: Apply Helm Chart | |
# id: helm | |
# run: | | |
# export REPO_core=$(echo ${{ needs.build-harbor-core.outputs.tags }} | cut -f1 -d":") | |
# export REPO_portal=$(echo ${{ needs.build-harbor-portal.outputs.tags }} | cut -f1 -d":") | |
# export REPO_jobservice=$(echo ${{ needs.build-harbor-jobservice.outputs.tags }} | cut -f1 -d":") | |
# export REPO_registry=$(echo ${{ needs.build-harbor-registry.outputs.tags }} | cut -f1 -d":") | |
# export REPO_registryctl=$(echo ${{ needs.build-harbor-registryctl.outputs.tags }} | cut -f1 -d":") | |
# export KUBECONFIG="`pwd`/kubeconfig" | |
# helm repo add harbor https://helm.goharbor.io | |
# if $(helm ls | grep -q my-release); then | |
# helm upgrade --install my-release \ | |
# --set portal.image.repository=${REPO_portal} \ | |
# --set portal.image.tag=24h \ | |
# --set core.image.repository=${REPO_core} \ | |
# --set core.image.tag=24h \ | |
# --set jobservice.image.repository=${REPO_jobservice} \ | |
# --set jobservice.image.tag=24h \ | |
# --set registry.registry.image.repository=${REPO_registry} \ | |
# --set registry.registry.image.tag=24h \ | |
# --set registry.controller.image.repository=${REPO_registryctl} \ | |
# --set registry.controller.image.tag=24h \ | |
# harbor/harbor --values=values.yaml | |
# else | |
# helm install my-release \ | |
# --set portal.image.repository=${REPO_portal} \ | |
# --set portal.image.tag=24h \ | |
# --set core.image.repository=${REPO_core} \ | |
# --set core.image.tag=24h \ | |
# --set jobservice.image.repository=${REPO_jobservice} \ | |
# --set jobservice.image.tag=24h \ | |
# --set registry.registry.image.repository=${REPO_registry} \ | |
# --set registry.registry.image.tag=24h \ | |
# --set registry.controller.image.repository=${REPO_registryctl} \ | |
# --set registry.controller.image.tag=24h \ | |
# harbor/harbor --values=values.yaml | |
# fi | |
# # Create ingress | |
# - name: Create ingress | |
# id: ingress | |
# run: | | |
# sleep 20 | |
# echo "HARBOR_HOST=$(kubectl get ingress my-release-harbor-ingress --kubeconfig kubeconfig -o json | jq '.spec.rules[0].host' | tr -d '"')" >> "$GITHUB_OUTPUT" | |
# - name: Update Comment with Harbor URL | |
# id: harbor_notify | |
# uses: peter-evans/create-or-update-comment@v2 | |
# with: | |
# comment-id: ${{ steps.notification.outputs.comment-id }} | |
# issue-number: ${{ github.event.pull_request.number }} | |
# body: | | |
# --- | |
# Please wait for several minutes for Harbor deployment to complete. | |
# Then you should be able to visit the Harbor portal at https://${{ steps.ingress.outputs.HARBOR_HOST }} | |
# For more details, please visit https://github.com/goharbor/harbor | |
# edit-mode: append | |
# - name: Upload kubeconfig file | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: kubeconfig | |
# path: kubeconfig | |
# - name: Update Harbor URL for Cypress | |
# env: | |
# HARBOR_HOST: ${{ steps.ingress.outputs.HARBOR_HOST }} | |
# run: | | |
# sed -i "s#harbor_url#https://${{ steps.ingress.outputs.HARBOR_HOST }}#g" cypress/cypress.config.js | |
# testkube: | |
# name: Run test on Harbor | |
# needs: | |
# - uffizzi-cluster | |
# if: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }} | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v2 | |
# - name: Download kubeconfig | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: kubeconfig | |
# - name: Install Testkube helm chart | |
# run: | | |
# export KUBECONFIG="`pwd`/kubeconfig" | |
# helm repo add kubeshop https://kubeshop.github.io/helm-charts | |
# if $(helm ls | grep -q my-testkube); then | |
# helm upgrade --install my-testkube kubeshop/testkube | |
# else | |
# helm install my-testkube kubeshop/testkube | |
# fi | |
# sleep 10 | |
# - name: Create Ingress for Testkube | |
# id: test | |
# run: | | |
# if $(kubectl get ingress my-testkube-ingress --kubeconfig="`pwd`/kubeconfig" | grep -q "my-testkube-ingress"); then | |
# kubectl delete ingress my-testkube-ingress --kubeconfig="`pwd`/kubeconfig" | |
# fi | |
# kubectl create ingress my-testkube-ingress --kubeconfig="`pwd`/kubeconfig" \ | |
# --rule="testkube.uclusters.app.uffizzi.com/*=testkube-dashboard:8080,tls" | |
# if $(kubectl get ingress my-testkube-api-server --kubeconfig="`pwd`/kubeconfig" | grep -q "my-testkube-api-server"); then | |
# kubectl delete ingress my-testkube-api-server --kubeconfig="`pwd`/kubeconfig" | |
# fi | |
# kubectl create ingress my-testkube-api-server --kubeconfig="`pwd`/kubeconfig" \ | |
# --rule="testkube-api-server.uclusters.app.uffizzi.com/*=testkube-api-server:8088,tls" | |
# sleep 20 | |
# echo "API_SERVER=$(kubectl get ingress my-testkube-api-server --kubeconfig="`pwd`/kubeconfig" -o json | jq '.spec.rules[0].host' | tr -d '"')" >> "$GITHUB_OUTPUT" | |
# echo "TK_DASHBOARD=$(kubectl get ingress my-testkube-ingress --kubeconfig="`pwd`/kubeconfig" -o json | jq '.spec.rules[0].host' | tr -d '"')" >> "$GITHUB_OUTPUT" | |
# - shell: bash | |
# env: | |
# API_SERVER: ${{ steps.test.outputs.API_SERVER }} | |
# run: | | |
# export KUBECONFIG=`pwd`/kubeconfig | |
# helm upgrade my-testkube kubeshop/testkube --set testkube-dashboard.apiServerEndpoint=${{ steps.test.outputs.API_SERVER }} | |
# - name: Get test with Testkube | |
# id: get_test | |
# uses: kubeshop/testkube-docker-action@v1 | |
# with: | |
# command: get | |
# resource: test | |
# api-uri: https://${{ steps.test.outputs.API_SERVER }} | |
# parameters: "cypress-test" | |
# - name: Create test with Testkube | |
# id: create_test | |
# if: always() && (steps.get_test.outcome == 'failure') | |
# uses: kubeshop/testkube-docker-action@v1 | |
# env: | |
# KUBECONFIG: kubeconfig | |
# KUBERNETES_MASTER: kubeconfig | |
# API_SERVER: ${{ steps.test.outputs.API_SERVER }} | |
# with: | |
# command: create | |
# resource: test | |
# api-uri: https://${{ steps.test.outputs.API_SERVER }} | |
# parameters: "--name cypress-test --type cypress/project --test-content-type git-dir --git-uri https://github.com/UffizziCloud/harbor-test/ --git-branch testkube --git-path cypress/ --variable CYPRESS_BASE_URL=https://${{ needs.uffizzi-cluster.outputs.HARBOR_HOST }} --job-template job.yaml" | |
# - name: Run test with Testkube | |
# id: run_test | |
# if: always() | |
# uses: kubeshop/testkube-docker-action@v1 | |
# with: | |
# command: run | |
# resource: test | |
# api-uri: https://${{ steps.test.outputs.API_SERVER }} | |
# parameters: "cypress-test" | |
# - name: Update comment with Testkube | |
# if: always() | |
# uses: peter-evans/create-or-update-comment@v2 | |
# with: | |
# comment-id: ${{ needs.uffizzi-cluster.harbor_notify.outputs.comment-id }} | |
# issue-number: ${{ github.event.pull_request.number }} | |
# body: | | |
# --- | |
# Check out Testkube at -- https://${{ steps.test.outputs.TK_DASHBOARD }} | |
# edit-mode: append | |
cypress-run: | |
# needs: | |
# - uffizzi-cluster | |
name: Cypress run | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
path: 'cypress/' | |
- name: Cypress run | |
id: cypress | |
uses: mihaisee/github-action@feat/add-test-reults-output | |
with: | |
working-directory: cypress/cypress | |
config-file: cypress.config.js | |
build: npx cypress info | |
# config: baseUrl=https://${{ needs.uffizzi-cluster.outputs.HARBOR_HOST }} | |
config: baseUrl=https://my-release-harbor-ingress-default-pr-3-c432.uclusters.app.uffizzi.com | |
- name: Cypress output | |
uses: actions/[email protected] | |
with: | |
script: | | |
if (${{ steps.cypress.outputs.testResultsObject }} == "") { | |
console.log('No test results found') | |
return | |
} | |
const testResults = JSON.parse('${{ steps.cypress.outputs.testResultsObject }}') | |
console.log("Success: " + testResults.success) | |
console.log("TotalPassed: " + testResults.totalPassed) | |
console.log("TotalFailed: " + testResults.totalFailed) | |
console.log("TotalPending: " + testResults.totalPending) | |
console.log("TotalSkipped: " + testResults.totalSkipped) | |
console.log("TotalDuration: " + testResults.totalDuration) | |
const headers = [ | |
{ data: 'Result', header: true }, | |
{ data: 'Passed :white_check_mark:', header: true }, | |
{ data: 'Failed :x:', header: true }, | |
{ data: 'Pending :hand:', header: true }, | |
{ data: 'Skipped :leftwards_arrow_with_hook:', header: true }, | |
{ data: 'Duration :clock8:', header: true } | |
] | |
const status = | |
testResults.totalFailed === 0 | |
? 'Passing :white_check_mark:' | |
: 'Failing :red_circle:' | |
const summaryRows = [ | |
status, | |
`${testResults.totalPassed}`, | |
`${testResults.totalFailed}`, | |
`${testResults.totalPending}`, | |
`${testResults.totalSkipped}`, | |
`${testResults.totalDuration / 1000}s` || '' | |
] | |
const tableRows = [headers.map(h => h.data), summaryRows].map(row => '|' + row.join('|') + '|').join('\\n'); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body:` | |
Here are the test results: | |
\`\`\` | |
| Result | Passed ✅ | Failed ❌ | Pending ✋ | Skipped ↩️ | Duration 🕗 | | |
| -------------- | --------- | --------- | --------- | ---------- | ------------------ | | |
| ${status} | ${testResults.totalPassed} | ${testResults.totalFailed} | ${testResults.totalPending} | ${testResults.totalSkipped} | ${testResults.totalDuration / 1000}s | | |
\`\`\` | |
`,, | |
}) | |
uffizzi-cluster-delete: | |
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete Virtual Cluster | |
uses: UffizziCloud/cluster-action@main | |
with: | |
action: delete | |
cluster-name: pr-${{ github.event.pull_request.number }} | |
server: https://app.uffizzi.com/ |