Add chatterbox Slack notifications for failed PR lint runs#6039
Add chatterbox Slack notifications for failed PR lint runs#6039jencarlucci wants to merge 4 commits intomainfrom
Conversation
d27f2bc to
fe57989
Compare
There was a problem hiding this comment.
Pull request overview
Adds CI alerting so the API team is notified in #api-platform when PR lint runs fail.
Changes:
- Trigger the linter workflow on
pull_requestevents. - Add a
workflow_run-based notifier workflow that posts failures to chatterbox/Slack. - Document required repository secrets and workflow location in
CONTRIBUTING.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
descriptions-next/lint-failure-test.yaml |
Adds a file intended to force lint failure (used to test notifications). |
CONTRIBUTING.md |
Documents CI notification behavior and required secrets. |
.github/workflows/linter.yml |
Enables lint workflow on PRs in addition to pushes. |
.github/workflows/linter-failure-notifier.yml |
New workflow to post chatterbox notifications on failed PR lint runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1 @@ | |||
| trigger: [this is intentionally broken | |||
There was a problem hiding this comment.
This file is syntactically invalid YAML and will cause lint/CI to fail continuously once merged (not just during testing). If the goal is to test notifications, consider removing this file before merge, or move it into a test/fixture location that is excluded from the linter inputs (or gate it behind a dedicated test-only workflow).
| trigger: [this is intentionally broken | |
| trigger: ["this is intentionally broken"] |
| message=":warning: Linter workflow failed for a pull request in ${REPO}.\n• Workflow: ${RUN_NAME}\n• PR: ${PR_URL}\n• Branch: ${BRANCH}\n• Commit: ${short_sha}\n• Run: ${RUN_URL}" | ||
|
|
||
| curl --fail --silent --show-error \ | ||
| -X POST \ | ||
| -u "${CHATTERBOX_TOKEN}:" \ | ||
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | ||
| --data "$message" |
There was a problem hiding this comment.
In bash, \"\\n\" inside double quotes is not converted to a newline; it becomes a literal backslash+n. This will post \\n sequences rather than multi-line text. Build message using actual newlines (e.g., a heredoc or printf) and consider --data-binary to preserve newline formatting in the request body.
| message=":warning: Linter workflow failed for a pull request in ${REPO}.\n• Workflow: ${RUN_NAME}\n• PR: ${PR_URL}\n• Branch: ${BRANCH}\n• Commit: ${short_sha}\n• Run: ${RUN_URL}" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data "$message" | |
| printf -v message ':warning: Linter workflow failed for a pull request in %s.\n• Workflow: %s\n• PR: %s\n• Branch: %s\n• Commit: %s\n• Run: %s' "$REPO" "$RUN_NAME" "$PR_URL" "$BRANCH" "$short_sha" "$RUN_URL" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data-binary "$message" |
| message=":warning: Linter workflow failed for a pull request in ${REPO}.\n• Workflow: ${RUN_NAME}\n• PR: ${PR_URL}\n• Branch: ${BRANCH}\n• Commit: ${short_sha}\n• Run: ${RUN_URL}" | ||
|
|
||
| curl --fail --silent --show-error \ | ||
| -X POST \ | ||
| -u "${CHATTERBOX_TOKEN}:" \ | ||
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | ||
| --data "$message" |
There was a problem hiding this comment.
In bash, \"\\n\" inside double quotes is not converted to a newline; it becomes a literal backslash+n. This will post \\n sequences rather than multi-line text. Build message using actual newlines (e.g., a heredoc or printf) and consider --data-binary to preserve newline formatting in the request body.
| message=":warning: Linter workflow failed for a pull request in ${REPO}.\n• Workflow: ${RUN_NAME}\n• PR: ${PR_URL}\n• Branch: ${BRANCH}\n• Commit: ${short_sha}\n• Run: ${RUN_URL}" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data "$message" | |
| message="$(cat <<EOF | |
| :warning: Linter workflow failed for a pull request in ${REPO}. | |
| • Workflow: ${RUN_NAME} | |
| • PR: ${PR_URL} | |
| • Branch: ${BRANCH} | |
| • Commit: ${short_sha} | |
| • Run: ${RUN_URL} | |
| EOF | |
| )" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data-binary "$message" |
| RUN_NAME: ${{ github.event.workflow_run.name }} | ||
| BRANCH: ${{ github.event.workflow_run.head_branch }} | ||
| COMMIT: ${{ github.event.workflow_run.head_sha }} | ||
| PR_URL: ${{ github.event.workflow_run.pull_requests[0].html_url }} |
There was a problem hiding this comment.
The workflow_run payload’s pull_requests array can be empty in some cases, which would leave PR_URL blank and degrade the alert. Add a fallback (e.g., link to RUN_URL, or query the PR via the GitHub API using head_sha when pull_requests[0] is missing).
This PR adds CI alerting so the API team gets notified in #api-platform when lint fails on pull requests.
I'll need to test this workflow once it's merged since we don't currently have a way to manually trigger the entire process.