Skip to content

Commit

Permalink
#27490: Slack notification for broken build
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralfaro-dotcms committed Apr 9, 2024
1 parent f82bbfd commit 6388657
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
40 changes: 35 additions & 5 deletions .github/workflows/build-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- name: Download Workflow Data
id: data-download
uses: dawidd6/action-download-artifact@v2
Expand Down Expand Up @@ -79,7 +80,6 @@ jobs:
test_elapsed=${{ steps.test-reporter.outputs.time }}
fi
if [[ "$status" == "SUCCESS" ]]; then
echo "status_icon=✅" >> $GITHUB_OUTPUT
else
Expand All @@ -95,7 +95,6 @@ jobs:
else
echo "report_type=$trigger_event_name" >> $GITHUB_OUTPUT
fi
echo "json=$json" >> $GITHUB_OUTPUT
echo "trigger_event_name=$trigger_event_name" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -123,9 +122,31 @@ jobs:
echo "test_failed=$test_failed" >> $GITHUB_OUTPUT
echo "test_skipped=$test_skipped" >> $GITHUB_OUTPUT
echo "test_elapsed=$test_elapsed" >> $GITHUB_OUTPUT
fi
- name: Create message
id: create-message
run: |
run_id_url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ steps.workflow-data.outputs.action_run_url }}
icon_url=https://slackmojis.com/emojis/5432-this-is-fine/download
echo "run_id_url=run_id_url" >> $GITHUB_OUTPUT
echo "icon_url=$icon_url" >> $GITHUB_OUTPUT
if: github.ref_name == 'master' && steps.workflow-data.outputs.status != 'SUCCESS'

- name: Slack Notification
uses: rtCamp/action-slack-notify@v2.3.0
env:
SLACK_WEBHOOK: ${{ secrets.MASTER_BUILD_SLACK_WEBHOOK }}
SLACK_USERNAME: dotBot
SLACK_TITLE: "Broken build!"
SLACK_MSG_AUTHOR: " "
MSG_MINIMAL: true
SLACK_FOOTER: ""
SLACK_ICON: ${{ steps.create-message.outputs.icon_url }}
SLACK_MESSAGE: "Attention <!channel>! Broken build at \`${{ github.ref_name }}\`.\nPlease check the run at: ${{ $steps.create-message.outputs.run_id_url }}"
if: github.ref_name == 'master' && steps.workflow-data.outputs.status != 'SUCCESS'

- name: Prepare Slack Message Payload
id: prepare-slack-message
run: |
Expand Down Expand Up @@ -206,11 +227,20 @@ jobs:
)
echo "payload=$(echo $payload | jq -c .)" >> $GITHUB_OUTPUT
echo "payload=$payload"
- name: Post to Slack
if: steps.workflow-data.outputs.has-json == 'true' && github.repository == 'dotcms/core'
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: ${{ vars.SLACK_REPORT_CHANNEL }}
payload: ${{ steps.prepare-slack-message.outputs.payload }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.MASTER_BUILD_SLACK_WEBHOOK }}

# - name: Post to Slack
# if: steps.workflow-data.outputs.has-json == 'true' && github.repository == 'dotcms/core'
# uses: slackapi/slack-github-action@v1.24.0
# with:
# channel-id: ${{ vars.SLACK_REPORT_CHANNEL }}
# payload: ${{ steps.prepare-slack-message.outputs.payload }}
# env:
# SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
15 changes: 12 additions & 3 deletions .github/workflows/maven-cicd-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
branches:
- master
- release-*
- 27490-*
pull_request:
merge_group:
concurrency:
Expand Down Expand Up @@ -62,7 +63,7 @@ jobs:
backend=${{ steps.filter.outputs.backend }}
build=${{ steps.filter.outputs.build }}
jvm_unit_test=${{ steps.filter.outputs.jvm_unit_test }}
# Check if the commit is to the master branch
is_master=$(echo ${{ github.ref }} | sed -n 's/refs\/heads\/master/&/p')
skip_tests=${CICD_SKIP_TESTS:-false} # Use environment variable, default to 'false'
Expand All @@ -76,6 +77,7 @@ jobs:
backend=true
jvm_unit_test=true
fi
# The below line ensures that if skip_tests is true, all tests are set to false.
if [ "$skip_tests" == "true" ]; then
echo "Skipping tests as per CICD_SKIP_TESTS flag."
Expand Down Expand Up @@ -174,12 +176,20 @@ jobs:
path: ${{ env.DOCKER_BUILD_CONTEXT }}/docker-build.tar
- name: Save Docker image to a tar file
run: docker save ${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} > image.tar

- name: Upload Docker image as artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: image.tar
- name: Core Build Report
uses: actions/upload-artifact@v4
if: always() && !cancelled()
with:
name: "build-reports-Initial JDK 11 Build"
path: |
target/build-reports.json
LICENSE
retention-days: 2

#
# Run all JVM Unit Tests in parallel with other tests
Expand Down Expand Up @@ -695,7 +705,6 @@ jobs:
echo '"pr_author": "'${{ github.event.pull_request.user.login }}'",' >> workflow-data.json
echo '"pr_merge_state": "'${{ github.event.pull_request.mergeable_state }}'",' >> workflow-data.json
echo '"build_reports": [' >> workflow-data.json
total_reports=$(find /tmp/build-step-reports/build-reports-*/target -name build-report.json 2>/dev/null | wc -l)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public BulkEmbeddingsRunner(List<String> inodes, EmbeddingsForm embeddingsForm)
user = Try.of(() -> APILocator.getUserAPI().loadUserById(embeddingsForm.userId)).getOrElse(APILocator.systemUser());
this.embeddingsForm = embeddingsForm;
this.inodes = inodes;
blah();
}

@Override
Expand Down

0 comments on commit 6388657

Please sign in to comment.