From 72675464ed20d46bc53852292a62cfe9f92c75c4 Mon Sep 17 00:00:00 2001 From: Are Almaas Date: Mon, 14 Oct 2024 10:32:13 +0200 Subject: [PATCH] ci: add status for build and test (#1284) ## Description Add status for build and test workflow in Test-environment ## Related Issue(s) - #{issue number} ## Verification - [ ] **Your** code builds clean without any errors or warnings - [ ] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) ## Summary by CodeRabbit - **New Features** - Enhanced Slack notifications to include the status of the build and test process upon failure. - Added a new input parameter for CI/CD status messages, improving reporting capabilities. - **Bug Fixes** - Updated logic for status emojis to accurately reflect the build and test job status. --- .github/workflows/ci-cd-main.yml | 11 ++++++++++- .../workflow-send-ci-cd-status-slack-message.yml | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd-main.yml b/.github/workflows/ci-cd-main.yml index 581503459..af372cde4 100644 --- a/.github/workflows/ci-cd-main.yml +++ b/.github/workflows/ci-cd-main.yml @@ -152,7 +152,15 @@ jobs: send-slack-message-on-failure: name: Send Slack message on failure - needs: [deploy-infra-test, deploy-apps-test, deploy-slack-notifier-test, run-e2e-tests, publish-schema-npm, publish] + needs: [ + deploy-infra-test, + deploy-apps-test, + deploy-slack-notifier-test, + run-e2e-tests, + publish-schema-npm, + publish, + build-and-test, + ] if: ${{ always() && failure() && !cancelled() }} uses: ./.github/workflows/workflow-send-ci-cd-status-slack-message.yml with: @@ -163,6 +171,7 @@ jobs: e2e_tests_status: ${{ needs.run-e2e-tests.result }} schema_npm_status: ${{ needs.publish-schema-npm.result }} publish_status: ${{ needs.publish.result }} + build_and_test_status: ${{ needs.build-and-test.result }} secrets: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID_FOR_CI_CD_STATUS }} diff --git a/.github/workflows/workflow-send-ci-cd-status-slack-message.yml b/.github/workflows/workflow-send-ci-cd-status-slack-message.yml index 4c2e81c80..60eefda89 100644 --- a/.github/workflows/workflow-send-ci-cd-status-slack-message.yml +++ b/.github/workflows/workflow-send-ci-cd-status-slack-message.yml @@ -30,6 +30,10 @@ on: type: string description: "Status of the docker image publishing job" default: "skipped" + build_and_test_status: + type: string + description: "Status of the build and test job" + default: "skipped" secrets: SLACK_BOT_TOKEN: required: true @@ -64,6 +68,7 @@ jobs: echo "E2E_TESTS_EMOJI=$(determine_emoji "${{ inputs.e2e_tests_status }}")" echo "SCHEMA_NPM_EMOJI=$(determine_emoji "${{ inputs.schema_npm_status }}")" echo "PUBLISH_EMOJI=$(determine_emoji "${{ inputs.publish_status }}")" + echo "BUILD_AND_TEST_EMOJI=$(determine_emoji "${{ inputs.build_and_test_status }}")" } >> "$GITHUB_OUTPUT" - name: Send GitHub slack message @@ -79,6 +84,7 @@ jobs: E2E_TESTS_STATUS: "${{ steps.status-emojis.outputs.E2E_TESTS_EMOJI }}" SCHEMA_NPM_STATUS: "${{ steps.status-emojis.outputs.SCHEMA_NPM_EMOJI }}" PUBLISH_STATUS: "${{ steps.status-emojis.outputs.PUBLISH_EMOJI }}" + BUILD_AND_TEST_STATUS: "${{ steps.status-emojis.outputs.BUILD_AND_TEST_EMOJI }}" uses: slackapi/slack-github-action@v1.27.0 with: channel-id: ${{ secrets.SLACK_CHANNEL_ID }}