From f3c9a6f08a7c54f5c0e026d37c799f9d444162dc Mon Sep 17 00:00:00 2001 From: Mateusz Szostok Date: Mon, 1 Jul 2024 09:47:15 +0200 Subject: [PATCH] Add link to exact run --- .github/actions/cloud-slack-e2e/action.yaml | 29 +++++++---- .github/workflows/branch-build.yml | 2 +- .github/workflows/prod-e2e-test.yml | 2 +- .github/workflows/test-pr.yml | 48 +++++++++++++++++++ .../cloud_slack_dev_e2e_test.go | 1 + 5 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/test-pr.yml diff --git a/.github/actions/cloud-slack-e2e/action.yaml b/.github/actions/cloud-slack-e2e/action.yaml index a3562c0b1..a356f8255 100644 --- a/.github/actions/cloud-slack-e2e/action.yaml +++ b/.github/actions/cloud-slack-e2e/action.yaml @@ -45,6 +45,10 @@ inputs: description: 'Slack Alerts Webhook' required: true + slack_token: + description: 'Slack Alerts Webhook' + required: true + e2e_type: description: "Type of e2e test" required: true @@ -90,13 +94,13 @@ runs: SLACK_BOT_DISPLAY_NAME: ${{ inputs.slack_bot_display_name }} SLACK_TESTER_BOT_NAME: ${{ inputs.slack_tester_bot_name }} SLACK_TESTER_MESSAGE_WAIT_TIMEOUT: 180s - + BOTKUBE_CLOUD_UI_BASE_URL: ${{ inputs.botkube_cloud_ui_base_url }} BOTKUBE_CLOUD_API_BASE_URL: ${{ inputs.botkube_cloud_api_base_url }} BOTKUBE_CLOUD_EMAIL: ${{ inputs.botkube_cloud_email }} BOTKUBE_CLOUD_PASSWORD: ${{ inputs.botkube_cloud_password }} BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID: ${{ inputs.botkube_cloud_team_organization_id }} - SCREENSHOTS_DIR: ${{ runner.temp }}/screenshots + SCREENSHOTS_DIR: ./screenshots DEBUG_MODE: "true" run: | KUBECONFIG=$(k3d kubeconfig write cloud-slack-e2e-cluster) make test-cloud-slack-dev-e2e @@ -105,7 +109,7 @@ runs: if: ${{ always() }} with: name: screenshots_dump_${{github.sha}} - path: ${{ runner.temp }}/screenshots + path: ./screenshots retention-days: 5 - name: Dump cluster state @@ -114,27 +118,32 @@ runs: with: name: cloud-slack-e2e + - name: Select the latest screenshot + if: ${{ failure() }} + shell: bash + run: | + FILE=$(find ./screenshots -type f -exec ls -t1 {} + | head -1) + echo "SCREENSHOT_LOCATION=${FILE}" >> $GITHUB_ENV + - name: Detect failed jobs if: ${{ failure() }} id: footer shell: bash run: | - FOOTER='' - if [[ ${{ steps.k3d.outcome }} == failure ]]; then FOOTER='Failed to setup k3d cluster'; fi - if [[ ${{ steps.modules.outcome }} == failure ]]; then FOOTER='Failed to setup Go modules'; fi - if [[ ${{ steps.tests.outcome }} == failure ]]; then FOOTER='Failed to run e2e tests'; fi - + FOOTER='https://github.com/kubeshop/botkube/actions/runs/${{ github.run_id }}' echo "footer=${FOOTER}" >> $GITHUB_OUTPUT - name: Slack Notification uses: rtCamp/action-slack-notify@v2 if: ${{ failure() }} env: - SLACK_CHANNEL: 'botkube-cloud-ci-alerts' + # SLACK_CHANNEL: 'botkube-cloud-ci-alerts' + SLACK_CHANNEL: 'test-botkube-ci-alerts' SLACK_USERNAME: Botkube Cloud CI SLACK_COLOR: 'red' SLACK_TITLE: 'Message' SLACK_MESSAGE: "Cloud Slack ${{ inputs.e2e_type }} E2E tests failed :scream:" SLACK_ICON_EMOJI: ':this-is-fine-fire:' SLACK_FOOTER: ${{ steps.footer.outputs.footer }} - SLACK_WEBHOOK: ${{ inputs.slack_alerts_webhook }} + SLACK_TOKEN: ${{ inputs.slack_token }} + SLACK_FILE_UPLOAD: ${{ env.SCREENSHOT_LOCATION }} diff --git a/.github/workflows/branch-build.yml b/.github/workflows/branch-build.yml index 7b5797835..d000dc894 100644 --- a/.github/workflows/branch-build.yml +++ b/.github/workflows/branch-build.yml @@ -317,6 +317,6 @@ jobs: botkube_cloud_password: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_PASSWORD }} botkube_cloud_team_organization_id: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID }} - slack_alerts_webhook: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }} + slack_token: ${{ secrets.SLACK_APP_TOKEN_FOR_CI_ALERTS }} e2e_type: "DEV" diff --git a/.github/workflows/prod-e2e-test.yml b/.github/workflows/prod-e2e-test.yml index 120d4844f..da4d6eb80 100644 --- a/.github/workflows/prod-e2e-test.yml +++ b/.github/workflows/prod-e2e-test.yml @@ -44,6 +44,6 @@ jobs: botkube_cloud_password: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_PASSWORD }} botkube_cloud_team_organization_id: ${{ secrets.E2E_PROD_BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID }} - slack_alerts_webhook: ${{ secrets.SLACK_CI_ALERTS_WEBHOOK }} + slack_token: ${{ secrets.SLACK_APP_TOKEN_FOR_CI_ALERTS }} e2e_type: "PROD" diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml new file mode 100644 index 000000000..34cd425f7 --- /dev/null +++ b/.github/workflows/test-pr.yml @@ -0,0 +1,48 @@ +name: Test UI E2E tests on PR + +on: + push: + branches: + - update-ci-slack-msg + +env: + GIT_USER: botkube-dev + HELM_VERSION: v3.9.0 + K3D_VERSION: v5.4.6 + IMAGE_REGISTRY: "ghcr.io" + IMAGE_REPOSITORY: "kubeshop/botkube" + IMAGE_TAG: v9.99.9-dev # TODO: Use commit hash tag to make the predictable builds for each commit on branch + +jobs: + cloud-slack-dev-e2e: + name: Botkube Cloud Slack Dev E2E + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + concurrency: + group: cloud-slack-dev-e2e + cancel-in-progress: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run e2e tests + uses: ./.github/actions/cloud-slack-e2e + with: + access_token: ${{ secrets.E2E_TEST_GH_DEV_ACCOUNT_PAT }} + + slack_workspace_name: ${{ secrets.E2E_DEV_SLACK_WORKSPACE_NAME }} + slack_email: ${{ secrets.E2E_DEV_SLACK_EMAIL }} + slack_password: ${{ secrets.E2E_DEV_SLACK_USER_PASSWORD }} + slack_bot_display_name: "BotkubeDev" + slack_tester_bot_token: ${{ secrets.E2E_DEV_SLACK_TESTER_BOT_TOKEN }} + slack_tester_bot_name: "botkubedev" + + botkube_cloud_api_base_url: "https://api-dev.botkube.io" + botkube_cloud_email: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_EMAIL }} + botkube_cloud_password: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_PASSWORD }} + botkube_cloud_team_organization_id: ${{ secrets.E2E_DEV_BOTKUBE_CLOUD_TEAM_ORGANIZATION_ID }} + + slack_token: ${{ secrets.SLACK_APP_TOKEN_FOR_CI_ALERTS }} + e2e_type: "DEV" \ No newline at end of file diff --git a/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go b/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go index 0ff67e360..8c1a83e2f 100644 --- a/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go +++ b/test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go @@ -156,6 +156,7 @@ func TestCloudSlackE2E(t *testing.T) { gqlCli := createGQLCli(t, cfg, botkubeCloudPage) botkubeCloudPage.Cleanup(t, gqlCli) }) + t.FailNow() botkubeCloudPage.InstallAgentInCluster(t, cfg.BotkubeCliBinaryPath) botkubeCloudPage.OpenSlackAppIntegrationPage(t)