diff --git a/.github/actions/slack-message/action.yml b/.github/actions/slack-message/action.yml new file mode 100644 index 000000000..1b72d9bee --- /dev/null +++ b/.github/actions/slack-message/action.yml @@ -0,0 +1,57 @@ +name: Send a message to slack + +inputs: + msg: + description: The slack message text + slack_url: + description: passthrough for secrets.SLACK_WEBHOOK_URL + +runs: + using: composite + steps: + - uses: actions/checkout@v3 + + - name: set github ref + shell: bash + run: | + echo "github_reference=${{ github.ref }}" >> $GITHUB_ENV + + - name: trim github ref + shell: bash + run: | + echo "trimmed_ref=${github_reference#refs/}" >> $GITHUB_ENV + + - name: build urls + shell: bash + run: | + echo "logurl=$(printf '' ${{ github.run_id }})" >> $GITHUB_ENV + echo "commiturl=$(printf '' ${{ github.sha }})" >> $GITHUB_ENV + echo "refurl=$(printf '' ${{ env.trimmed_ref }})" >> $GITHUB_ENV + + - name: use url or blank val + shell: bash + run: | + echo "JOB=${{ github.job || '' }}" >> $GITHUB_ENV + echo "LOGS=${{ github.run_id && env.logurl || '-' }}" >> $GITHUB_ENV + echo "COMMIT=${{ github.sha && env.commiturl || '-' }}" >> $GITHUB_ENV + echo "REF=${{ env.trimmed_ref && env.refurl || '-' }}" >> $GITHUB_ENV + + - id: slack-message + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_WEBHOOK_URL: ${{ inputs.slack_url }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + with: + payload: | + { + "text": "${{ inputs.msg }} :: ${{ env.LOGS }} ${{ env.COMMIT }} ${{ env.REF }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "${{ inputs.msg }} :: ${{ env.JOB }}\n${{ env.LOGS }} ${{ env.COMMIT }} ${{ env.REF }}" + } + } + ] + } diff --git a/.github/workflows/ci_test_cleanup.yml b/.github/workflows/ci_test_cleanup.yml index 11ba94097..3687c0e0c 100644 --- a/.github/workflows/ci_test_cleanup.yml +++ b/.github/workflows/ci_test_cleanup.yml @@ -18,9 +18,7 @@ jobs: - uses: actions/checkout@v3 # sets the maximum time to now-30m. - # CI test have a 10 minute timeout. - # At 20 minutes ago, we should be safe from conflicts. - # The additional 10 minutes is just to be good citizens. + # CI test have a 20 minute timeout. - name: Set purge boundary run: echo "HALF_HOUR_AGO=$(date -d '30 minutes ago' -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV @@ -36,6 +34,13 @@ jobs: m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }} m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }} + - name: Notify failure in slack + if: failure() + uses: ./.github/actions/slack-message + with: + msg: "[FAILED] ${{ vars[matrix.user] }} CI Cleanup" + slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} + Test-Site-Data-Cleanup: environment: Testing runs-on: ubuntu-latest @@ -48,9 +53,7 @@ jobs: - uses: actions/checkout@v3 # sets the maximum time to now-30m. - # CI test have a 10 minute timeout. - # At 20 minutes ago, we should be safe from conflicts. - # The additional 10 minutes is just to be good citizens. + # CI test have a 20 minute timeout. - name: Set purge boundary run: echo "HALF_HOUR_AGO=$(date -d '30 minutes ago' -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV @@ -67,3 +70,10 @@ jobs: azure-tenant-id: ${{ secrets.TENANT_ID }} m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }} m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }} + + - name: Notify failure in slack + if: failure() + uses: ./.github/actions/slack-message + with: + msg: "[FAILED] ${{ vars[matrix.site] }} CI Cleanup" + slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/longevity_test.yml b/.github/workflows/longevity_test.yml index 02b956be1..8d294107a 100644 --- a/.github/workflows/longevity_test.yml +++ b/.github/workflows/longevity_test.yml @@ -277,33 +277,9 @@ jobs: if-no-files-found: error retention-days: 14 - - name: SHA info - id: sha-info + - name: Notify failure in slack if: failure() - run: | - echo ${GITHUB_REF#refs/heads/}-${GITHUB_SHA} - echo SHA=${GITHUB_REF#refs/heads/}-${GITHUB_SHA} >> $GITHUB_OUTPUT - echo RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_OUTPUT - echo COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${GITHUB_SHA} >> $GITHUB_OUTPUT - - - name: Send Github Action failure to Slack - id: slack-notification - if: failure() - uses: slackapi/slack-github-action@v1.24.0 + uses: ./.github/actions/slack-message with: - payload: | - { - "text": "Longevity test failure - build: ${{ job.status }} - SHA: ${{ steps.sha-info.outputs.SHA }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "[FAILED] Longevity Checks :: <${{ steps.sha-info.outputs.RUN_URL }}|[Logs]> <${{ steps.sha-info.outputs.COMMIT_URL }}|[Base]>\nCommit: <${{ steps.sha-info.outputs.COMMIT_URL }}|${{ steps.sha-info.outputs.SHA }}>" - } - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + msg: "[FAILED] Longevity Test" + slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/nightly_test.yml b/.github/workflows/nightly_test.yml index cc18732c5..29b69ad20 100644 --- a/.github/workflows/nightly_test.yml +++ b/.github/workflows/nightly_test.yml @@ -120,33 +120,9 @@ jobs: if-no-files-found: error retention-days: 14 - - name: SHA info - id: sha-info + - name: Notify failure in slack if: failure() - run: | - echo ${GITHUB_REF#refs/heads/}-${GITHUB_SHA} - echo SHA=${GITHUB_REF#refs/heads/}-${GITHUB_SHA} >> $GITHUB_OUTPUT - echo RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_OUTPUT - echo COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${GITHUB_SHA} >> $GITHUB_OUTPUT - - - name: Send Github Action failure to Slack - id: slack-notification - if: failure() - uses: slackapi/slack-github-action@v1.24.0 + uses: ./.github/actions/slack-message with: - payload: | - { - "text": "Nightly test failure - build: ${{ job.status }} - SHA: ${{ steps.sha-info.outputs.SHA }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "[FAILED] Nightly Checks :: <${{ steps.sha-info.outputs.RUN_URL }}|[Logs]> <${{ steps.sha-info.outputs.COMMIT_URL }}|[Base]>\nCommit: <${{ steps.sha-info.outputs.COMMIT_URL }}|${{ steps.sha-info.outputs.SHA }}>" - } - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + msg: "[FAILED] Nightly Checks" + slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/sanity-test.yaml b/.github/workflows/sanity-test.yaml index 9e210778d..292c358dd 100644 --- a/.github/workflows/sanity-test.yaml +++ b/.github/workflows/sanity-test.yaml @@ -333,33 +333,9 @@ jobs: if-no-files-found: error retention-days: 14 - - name: SHA info - id: sha-info + - name: Notify failure in slack if: failure() - run: | - echo ${GITHUB_REF#refs/heads/}-${GITHUB_SHA} - echo SHA=${GITHUB_REF#refs/heads/}-${GITHUB_SHA} >> $GITHUB_OUTPUT - echo RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} >> $GITHUB_OUTPUT - echo COMMIT_URL=${{ github.server_url }}/${{ github.repository }}/commit/${GITHUB_SHA} >> $GITHUB_OUTPUT - - - name: Send Github Action failure to Slack - id: slack-notification - if: failure() - uses: slackapi/slack-github-action@v1.24.0 + uses: ./.github/actions/slack-message with: - payload: | - { - "text": "Sanity test failure - build: ${{ job.status }} - SHA: ${{ steps.sha-info.outputs.SHA }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "[FAILED] Sanity Checks :: <${{ steps.sha-info.outputs.RUN_URL }}|[Logs]> <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|[Base]>\nCommit: <${{ steps.sha-info.outputs.COMMIT_URL }}|${{ steps.sha-info.outputs.SHA }}>" - } - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file + msg: "[FAILED] Sanity Tests" + slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file diff --git a/website/docs/developers/linters.md b/website/docs/developers/linters.md index 9cf192ff1..e7416b235 100644 --- a/website/docs/developers/linters.md +++ b/website/docs/developers/linters.md @@ -21,6 +21,16 @@ You can run the linter manually or with the `Makefile` in the repository. Runnin the `Makefile` will also ensure you have the proper version of golangci-lint installed. +### Running the actions linter + +Installation: + +```sh +go install github.com/rhysd/actionlint/cmd/actionlint@latest +``` + +[Instructions for running locally.](https://github.com/rhysd/actionlint/blob/main/docs/usage.md) + ### Running with the `Makefile` There’s a `Makefile` in the corso/src that will automatically check if the proper