From 4708492f3d92ffbc15ea24b290520e820546b10d Mon Sep 17 00:00:00 2001 From: youben11 Date: Thu, 21 Nov 2024 09:29:31 +0100 Subject: [PATCH] fix(ci): notify on MacOS failures the notification action can't run on Mac https://github.com/rtCamp/action-slack-notify/issues/22 --- .../concrete_compiler_test_macos_cpu.yml | 21 ++++++++++++-- .../workflows/concrete_python_release_cpu.yml | 21 ++++++++++++-- .../workflows/concrete_python_test_macos.yml | 28 +++++++++++++++++++ 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/.github/workflows/concrete_compiler_test_macos_cpu.yml b/.github/workflows/concrete_compiler_test_macos_cpu.yml index 4c99842549..f305db672d 100644 --- a/.github/workflows/concrete_compiler_test_macos_cpu.yml +++ b/.github/workflows/concrete_compiler_test_macos_cpu.yml @@ -33,6 +33,9 @@ jobs: runson: ["aws-mac1-metal", "aws-mac2-metal"] python-version: ["3.10"] runs-on: ${{ matrix.runson }} + outputs: + slack_message: ${{ steps.prepare_slack_notif.outputs.slack_message }} + slack_color: ${{ steps.prepare_slack_notif.outputs.slack_color }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -82,10 +85,22 @@ jobs: if: success() || failure() run: | rm -rf "${KEY_CACHE_DIRECTORY}" - - name: Slack Notification + - name: Prepare Slack Notification + id: prepare_slack_notif if: ${{ failure() && github.ref == 'refs/heads/main' }} continue-on-error: true + run: | + echo "slack_message=build-and-test(macos) finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" >> "$GITHUB_OUTPUT" + echo "slack_color=${{ job.status }}" >> "$GITHUB_OUTPUT" + + slack-notif-macos: + needs: ["build-and-test"] + runs-on: "ubuntu-latest" + steps: + - name: Slack Notification + # we want to check that prepare_slack_notif was run + if: ${{ needs.build-and-test.outputs.slack_color != '' }} uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 env: - SLACK_COLOR: ${{ job.status }} - SLACK_MESSAGE: "build-and-test finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" + SLACK_COLOR: ${{ needs.build-and-test.outputs.slack_color }} + SLACK_MESSAGE: ${{ needs.build-and-test.outputs.slack_message }} diff --git a/.github/workflows/concrete_python_release_cpu.yml b/.github/workflows/concrete_python_release_cpu.yml index 0d192b021b..34871f195a 100644 --- a/.github/workflows/concrete_python_release_cpu.yml +++ b/.github/workflows/concrete_python_release_cpu.yml @@ -388,6 +388,9 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: ["aws-mac1-metal", "aws-mac2-metal"] runs-on: ${{ matrix.runs-on }} + outputs: + slack_message: ${{ steps.prepare_slack_notif.outputs.slack_message }} + slack_color: ${{ steps.prepare_slack_notif.outputs.slack_color }} steps: - name: Download wheels uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 @@ -436,10 +439,22 @@ jobs: if: success() || failure() run: | rm -rf "${TEST_TMP_DIR}" - - name: Slack Notification + - name: Prepare Slack Notification + id: prepare_slack_notif if: ${{ failure() }} continue-on-error: true + run: | + echo "slack_message=test-macos (${{matrix.runs-on}}/${{ matrix.python-version }}) finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" >> "$GITHUB_OUTPUT" + echo "slack_color=${{ job.status }}" >> "$GITHUB_OUTPUT" + + slack-notif-macos: + needs: ["test-macos"] + runs-on: "ubuntu-latest" + steps: + - name: Slack Notification + # we want to check that prepare_slack_notif was run + if: ${{ needs.test-macos.outputs.slack_color != '' }} uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 env: - SLACK_COLOR: ${{ job.status }} - SLACK_MESSAGE: "test-macos (${{matrix.runs-on}}/${{ matrix.python-version }}) finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" + SLACK_COLOR: ${{ needs.test-macos.outputs.slack_color }} + SLACK_MESSAGE: ${{ needs.test-macos.outputs.slack_message }} diff --git a/.github/workflows/concrete_python_test_macos.yml b/.github/workflows/concrete_python_test_macos.yml index 4be70ed3de..805a32fa66 100644 --- a/.github/workflows/concrete_python_test_macos.yml +++ b/.github/workflows/concrete_python_test_macos.yml @@ -13,6 +13,12 @@ concurrency: group: concrete_python_tests_macos_${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} +env: + ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_USERNAME: ${{ secrets.BOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + jobs: concrete-python-test-pytest: strategy: @@ -21,6 +27,9 @@ jobs: python-version: ["3.10"] machine: ["aws-mac1-metal", "aws-mac2-metal"] runs-on: ${{ matrix.machine }} + outputs: + slack_message: ${{ steps.prepare_slack_notif.outputs.slack_message }} + slack_color: ${{ steps.prepare_slack_notif.outputs.slack_color }} env: python: python${{matrix.python-version}} concrete-python-dir: ${{ github.workspace }}/frontends/concrete-python @@ -102,3 +111,22 @@ jobs: if: success() || failure() run: | rm -rf "${TEST_TMP_DIR}" + - name: Prepare Slack Notification + id: prepare_slack_notif + if: ${{ failure() }} + continue-on-error: true + run: | + echo "slack_message=concrete-python-test-pytest (${{matrix.machine}}/${{ matrix.python-version }}) finished with status: ${{ job.status }}. (${{ env.ACTION_RUN_URL }})" >> "$GITHUB_OUTPUT" + echo "slack_color=${{ job.status }}" >> "$GITHUB_OUTPUT" + + slack-notif-macos: + needs: ["concrete-python-test-pytest"] + runs-on: "ubuntu-latest" + steps: + - name: Slack Notification + # we want to check that prepare_slack_notif was run + if: ${{ needs.concrete-python-test-pytest.outputs.slack_color != '' }} + uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 + env: + SLACK_COLOR: ${{ needs.concrete-python-test-pytest.outputs.slack_color }} + SLACK_MESSAGE: ${{ needs.concrete-python-test-pytest.outputs.slack_message }}