From 14742dce4703f8978269effaa37fc9ef8dc62496 Mon Sep 17 00:00:00 2001 From: Karolina Rakoczy Date: Thu, 10 Oct 2024 10:50:27 +0200 Subject: [PATCH] Fix false positive slack message on release (#5203) * Fix false positive slack message on release, when there is an error in prepare instance job * Add run on push to tests changes * Add run on push to tests changes * Add run on push to tests changes * Fix slack message payload * Fix slack message payload * Fix slack message payload * Fix slack message payload * Fix slack message payload * Fix slack message payload * Fix slack message payload * Fix slack message payload * remove data for testing --- .changeset/slimy-dodos-think.md | 5 ++++ ...utomation-tests-on-repository-dispatch.yml | 4 +-- .../getEnvironmentVariables.js | 4 +++ .github/workflows/run-tests-on-release.yml | 30 ++++++++++++++++++- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .changeset/slimy-dodos-think.md diff --git a/.changeset/slimy-dodos-think.md b/.changeset/slimy-dodos-think.md new file mode 100644 index 00000000000..3a5aab4c05b --- /dev/null +++ b/.changeset/slimy-dodos-think.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": minor +--- + +Now we have slack message if there is failure when preparing instance before release tests diff --git a/.github/workflows/automation-tests-on-repository-dispatch.yml b/.github/workflows/automation-tests-on-repository-dispatch.yml index 6a8382a37c1..abda3bfa925 100644 --- a/.github/workflows/automation-tests-on-repository-dispatch.yml +++ b/.github/workflows/automation-tests-on-repository-dispatch.yml @@ -1,5 +1,5 @@ name: Execute automation tests -run-name: Run tests on ${{github.event.client_payload.custom_version }} ${{github.event.client_payload.project}} +run-name: Run tests on ${{github.event.client_payload.custom_version }} ${{github.event.client_payload.project}} on: repository_dispatch: @@ -40,7 +40,7 @@ jobs: uses: ./.github/workflows/run-tests-on-release.yml with: VERSION: ${{needs.get-environment-variables.outputs.VERSION}} - CUSTOM_VERSION: ${{github.event.client_payload.custom_version }} + CUSTOM_VERSION: ${{github.event.client_payload.custom_version }} ADDITIONAL_TITLE: "Core automation test" secrets: inherit diff --git a/.github/workflows/cypressTestsHelpers/getEnvironmentVariables.js b/.github/workflows/cypressTestsHelpers/getEnvironmentVariables.js index 967a02fc981..d663fe019bd 100644 --- a/.github/workflows/cypressTestsHelpers/getEnvironmentVariables.js +++ b/.github/workflows/cypressTestsHelpers/getEnvironmentVariables.js @@ -13,6 +13,10 @@ program .option("--repo_token ", "github token") .option("--project ", "release project") .action(async options => { + + if (options.version.match(/^\d+\.\d+\./)) { + throw new Error(`Incorrect version provided - ${customVersion}`); + } const isOldVersion = await checkIfOldVersion(options.version, options.repo_token); core.setOutput("IS_OLD_VERSION", isOldVersion); diff --git a/.github/workflows/run-tests-on-release.yml b/.github/workflows/run-tests-on-release.yml index d1b0a07f811..bc91488432b 100644 --- a/.github/workflows/run-tests-on-release.yml +++ b/.github/workflows/run-tests-on-release.yml @@ -15,6 +15,7 @@ on: required: false default: "Dashboard Automation test run " + secrets: STAGING_TOKEN: required: true @@ -130,6 +131,32 @@ jobs: --repo_token "$REPO_TOKEN" \ --project "$PROJECT" + - name: send slack message if failure + if: failure() + env: + LINK: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + MESSAGE: "Could not prepare instance for release tests on version ${{ env.CUSTOM_VERSION }}" + run: | + payload=$(\ + jq --null-input \ + --arg link "$LINK" \ + --arg message "$MESSAGE" \ + '{ + "attachments": [ + { + "pretext": "FAILURE", + "color": "#FE6E76", + "title": "Automation tests failure", + "title_link": $link, + "text": $message + } + ] + }' + ) + curl -H "Content-type: application/json" \ + --data "$payload" \ + -X POST ${{ secrets.SLACK_QA_STATUSES_WEBHOOK_URL }} + run-cy-tests: if: needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"cypress"' needs: add-check-and-prepare-instance @@ -230,7 +257,7 @@ jobs: tests-complete: if: | - !cancelled() && always() + !cancelled() && always() && needs.add-check-and-prepare-instance.result == 'success' needs: ["add-check-and-prepare-instance", "run-cy-tests", "run-pw-tests"] runs-on: ubuntu-22.04 timeout-minutes: 30 @@ -303,6 +330,7 @@ jobs: always() && (needs.tests-complete != 'success' && cancelled()) && needs.add-check-and-prepare-instance.outputs.FRAMEWORK == '"playwright"' + && needs.add-check-and-prepare-instance.result == 'success' steps: - uses: actions/checkout@v4