From 75d2a54d0e338c6f3bba9b690815f18b99693ee5 Mon Sep 17 00:00:00 2001 From: ypoplavs <45286051+ypoplavs@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:59:53 +0300 Subject: [PATCH] ci: sandbox add outputs (#5730) * add outputs for sandbox --- .github/sandbox-comment-template.md | 9 +++++ .github/workflows/sandbox.yaml | 58 +++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .github/sandbox-comment-template.md diff --git a/.github/sandbox-comment-template.md b/.github/sandbox-comment-template.md new file mode 100644 index 00000000000..ef6fc7b2b18 --- /dev/null +++ b/.github/sandbox-comment-template.md @@ -0,0 +1,9 @@ +Sandbox environment for `{{ .branch_ref }}` has been created. + +## URLs + +- **Dashboard**: https://dashboard.{{ .branch_ref }}.testkube.dev +- **API**: https://api.{{ .branch_ref }}.testkube.dev +- **Agent**: https://agent.{{ .branch_ref }}.testkube.dev +- **Storage**: https://storage.{{ .branch_ref }}.testkube.dev +- **Websockets**: https://websockets.{{ .branch_ref }}.testkube.dev diff --git a/.github/workflows/sandbox.yaml b/.github/workflows/sandbox.yaml index 05c6943b96d..222a58b0928 100644 --- a/.github/workflows/sandbox.yaml +++ b/.github/workflows/sandbox.yaml @@ -5,12 +5,16 @@ on: - sandbox/** paths-ignore: - 'docs/**' + pull_request: + types: + - opened env: ALPINE_IMAGE: alpine:3.20.0 BUSYBOX_IMAGE: busybox:1.36.1-musl jobs: api: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: - name: Checkout @@ -79,6 +83,7 @@ jobs: docker push kubeshop/testkube-sandbox:api-server-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} testworkflow: + if: startsWith(github.ref, 'refs/heads/sandbox/') strategy: matrix: service: [testworkflow-init, testworkflow-toolkit] @@ -157,6 +162,7 @@ jobs: docker push kubeshop/testkube-sandbox:${{ matrix.service }}-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} single_executor: + if: startsWith(github.ref, 'refs/heads/sandbox/') strategy: matrix: executor: [artillery, curl, example, ginkgo, k6, kubepug, postman, soapui, init, scraper, template, tracetest, zap ] @@ -226,6 +232,7 @@ jobs: docker push kubeshop/testkube-sandbox:${{ matrix.executor }}-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} executor_jmeter: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: @@ -289,6 +296,7 @@ jobs: docker push kubeshop/testkube-sandbox:jmeter-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} executor_jmeterd: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: @@ -352,6 +360,7 @@ jobs: docker push kubeshop/testkube-sandbox:jmeterd-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} jmeterd_slave: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: - name: Checkout @@ -396,6 +405,7 @@ jobs: platforms: linux/amd64,linux/arm64 executor_maven: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: - name: Checkout @@ -458,6 +468,7 @@ jobs: docker push kubeshop/testkube-sandbox:maven-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} executor_gradle: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: @@ -521,6 +532,7 @@ jobs: docker push kubeshop/testkube-sandbox:gradle-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} executor_cypress: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: - name: Checkout @@ -583,6 +595,7 @@ jobs: docker push kubeshop/testkube-sandbox:cypress-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} executor_playwright: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: - name: Checkout @@ -645,6 +658,7 @@ jobs: docker push kubeshop/testkube-sandbox:playwright-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} executor_postman_node21: + if: startsWith(github.ref, 'refs/heads/sandbox/') runs-on: ubuntu-latest steps: - name: Checkout @@ -707,6 +721,7 @@ jobs: docker push kubeshop/testkube-sandbox:postman-node21-executor-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} log_server_sidecar: + if: startsWith(github.ref, 'refs/heads/sandbox/') strategy: matrix: service: [ logs-server, logs-sidecar ] @@ -778,6 +793,7 @@ jobs: docker push kubeshop/testkube-sandbox:${{ matrix.service }}-${{ env.branch_identifier }}-${{ steps.commit.outputs.short }} dispatch: + if: startsWith(github.ref, 'refs/heads/sandbox/') needs: [ api, @@ -806,3 +822,45 @@ jobs: repository: kubeshop/testkube-deployment event-type: sandbox_image_update client-payload: '{"ref_name": "${{ github.ref_name }}"}' + + - name: Output summary + run: | + echo -e "### Sandbox Environment" >> $GITHUB_STEP_SUMMARY + echo -e '```' >> $GITHUB_STEP_SUMMARY + echo -e "## URLs" >> $GITHUB_STEP_SUMMARY + echo "- Dashboard: https://dashboard.${{ github.ref_name }}.testkube.dev" >> $GITHUB_STEP_SUMMARY + echo "- API: https://api.${{ github.ref_name }}.testkube.dev" >> $GITHUB_STEP_SUMMARY + echo "- Agent: https://agent.${{ github.ref_name }}.testkube.dev" >> $GITHUB_STEP_SUMMARY + echo "- Storage: https://storage.${{ github.ref_name }}.testkube.dev" >> $GITHUB_STEP_SUMMARY + echo "- Websockets: https://websockets.${{ github.ref_name }}.testkube.dev" >> $GITHUB_STEP_SUMMARY + echo -e '```' >> $GITHUB_STEP_SUMMARY + + pr_creation: + if: startsWith(github.event.pull_request.head.ref, 'sandbox/') + runs-on: ubuntu-latest + steps: + - name: Get a branch name if PR is created + run: | + # get a branch name + branch_ref="${{ github.event.pull_request.head.ref }}" + + #remove slash + branch_ref="${branch_ref#*/}" + + #create env var + echo "branch_ref=$branch_ref" >> $GITHUB_ENV + + - name: Render template + id: template + uses: chuhlomin/render-template@v1.4 + with: + template: .github/comment-template.md + vars: | + branch_ref: ${{ env.branch_ref }} + + - name: Create comment on a PR with the endpoints + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.CI_BOT_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: ${{ steps.template.outputs.result }}