From 2b3d7568f29f08eb6ee7581edccf5ac969dfcb8c Mon Sep 17 00:00:00 2001 From: Christian Zunker Date: Fri, 17 Jan 2025 13:36:11 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Trigger=20ALL=20tests=20on=20releas?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian Zunker --- .github/workflows/test-released-all.yaml | 124 +++++++++++++++++++++-- 1 file changed, 118 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-released-all.yaml b/.github/workflows/test-released-all.yaml index 699713e3..f4ad390d 100644 --- a/.github/workflows/test-released-all.yaml +++ b/.github/workflows/test-released-all.yaml @@ -7,29 +7,141 @@ on: description: "Version to test" required: true default: "9.0.0" + release: + types: [published] + +env: + # C07QZDJFF89 == #release-coordination + SLACK_BOT_CHANNEL_ID: "C07QZDJFF89" jobs: + notification-start: + name: Send Slack notification + runs-on: ubuntu-latest + outputs: + update-ts: ${{ steps.slack.outputs.ts }} + steps: + - id: slack + uses: slackapi/slack-github-action@v2.0.0 + with: + method: chat.postMessage + token: ${{ secrets.SLACK_BOT_TOKEN }} + payload: | + channel: "${{ env.SLACK_BOT_CHANNEL_ID }}" + text: "GitHub Actions Run" + attachments: + - color: "#FFFF00" + blocks: + - type: "section" + fields: + - type: "mrkdwn" + text: "<${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}|${{ github.workflow }}>" + - type: "mrkdwn" + text: "*Status:*\n`In Progress`" + + setup: + runs-on: ubuntu-latest + needs: notification-start + name: 'Unify Inputs' + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set Version (Workflow Dispatch) + if: github.event_name == 'workflow_dispatch' + run: | + echo VERSION=${{ inputs.version }} >> $GITHUB_ENV + - name: Set Version (Release Event) + if: github.event_name == 'release' + run: | + echo VERSION=${{ github.event.release.tag_name }} >> $GITHUB_ENV + - name: Unified Version + id: version + run: | + INPUT_NAME=${{ inputs.name }} + if [[ ${INPUT_NAME} == '' ]]; then + echo "Name is empty, using default" + echo "name=mondoo" >> $GITHUB_OUTPUT + else + echo "Name: ${INPUT_NAME}" + echo "name=${INPUT_NAME}" >> $GITHUB_OUTPUT + fi + V=$(echo $VERSION | sed 's/v//') + echo "Version: $V" + echo "version=${V}" >> $GITHUB_OUTPUT + # wait at least for one package to be published, otherwise tests will fail directly + - name: Wait for packages to be published (Release Event) + if: github.event_name == 'release' + id: check_release_file + uses: nick-fields/retry@v3 + with: + retry_wait_seconds: 10 + timeout_seconds: 5 + max_attempts: 60 + retry_on: error + # error on HTTP code different to 200 + command: | + vSEMVER=${{ steps.version.outputs.version }} + SEMVER="${vSEMVER//v}" + curl -o /dev/null -s -w "%{http_code}\n" "https://releases.mondoo.com/mondoo/${SEMVER}/mondoo_${SEMVER}_windows_amd64.msi" | grep 200 + test-arch: + needs: [setup, notification-start] uses: ./.github/workflows/test-released-archlinux.yaml with: - version: ${{ github.event.inputs.version }} + version: ${{ needs.setup.outputs.version }} test-docker: + needs: [setup, notification-start] uses: ./.github/workflows/test-released-docker.yaml with: - version: ${{ github.event.inputs.version }} + version: ${{ needs.setup.outputs.version }} test-install-sh: + needs: [setup, notification-start] uses: ./.github/workflows/test-released-install-sh.yaml with: - version: ${{ github.event.inputs.version }} + version: ${{ needs.setup.outputs.version }} test-install-ps1: + needs: [setup, notification-start] uses: ./.github/workflows/test-released-install-ps1.yaml with: - version: ${{ github.event.inputs.version }} + version: ${{ needs.setup.outputs.version }} test-osx-pkg: + needs: [setup, notification-start] uses: ./.github/workflows/test-released-osx-pkg.yaml with: - version: ${{ github.event.inputs.version }} + version: ${{ needs.setup.outputs.version }} test-brew: + needs: [setup, notification-start] uses: ./.github/workflows/test-released-brew.yaml with: - version: ${{ github.event.inputs.version }} + version: ${{ needs.setup.outputs.version }} + + notification: + runs-on: ubuntu-latest + name: Update Slack notification + needs: [test-arch, test-docker, test-install-sh, test-install-ps1, test-osx-pkg, test-brew, notification-start, setup] + if: ${{ always() }} + steps: + - name: Set status + id: status + run: | + echo "status_success=${{ needs.setup.result == 'success' && needs.test-arch.result == 'success' && needs.test-docker.result == 'success' && needs.test-install-sh.result == 'success' && needs.test-install-ps1.result == 'success' && needs.test-osx-pkg.result == 'success' && needs.test-brew.result == 'success' }}" >> $GITHUB_OUTPUT + - uses: slackapi/slack-github-action@v2.0.0 + if : ${{ always() }} + with: + method: chat.update + token: ${{ secrets.SLACK_BOT_TOKEN }} + payload: | + channel: "${{ env.SLACK_BOT_CHANNEL_ID }}" + ts: "${{ needs.notification-start.outputs.update-ts }}" + text: "GitHub Actions Run" + attachments: + - color: "${{ steps.status.outputs.status_success == 'true' && '#00FF00' || '#FF0000' }}" + blocks: + - type: "section" + fields: + - type: "mrkdwn" + text: "<${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}|${{ github.workflow }}>" + - type: "mrkdwn" + text: "*Status:*\n`${{ steps.status.outputs.status_success == 'true' && 'Success' || 'Failed' }}`"