-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Publish CI failures to Slack #4477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1ae6a3f
Publish CI failures to Slack
cte 9f3f4de
Add a failing test
cte 66acbaa
Try to fix action
cte 1c563f5
Fix Slack notification trigger for pull requests
cte 5daa4ee
Fix Slack notification condition for pull requests
cte c21119b
Clean up Slack notification setup
cte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: 'Slack Notification' | ||
| description: 'Send Slack notification for workflow failures' | ||
| inputs: | ||
| webhook-url: | ||
| description: 'Slack webhook URL' | ||
| required: true | ||
| channel: | ||
| description: 'Slack channel to notify' | ||
| required: true | ||
| workflow-name: | ||
| description: 'Name of the workflow' | ||
| required: true | ||
| failed-jobs: | ||
| description: 'JSON object containing job results' | ||
| required: true | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Parse failed jobs | ||
| id: parse-jobs | ||
| shell: bash | ||
| run: | | ||
| echo "Parsing job results..." | ||
| failed_list="" | ||
|
|
||
| # Parse the JSON and extract failed jobs | ||
| echo '${{ inputs.failed-jobs }}' | jq -r 'to_entries[] | select(.value.result == "failure") | .key' | while read job; do | ||
| case $job in | ||
| "check-translations") failed_list="${failed_list}❌ Translation check\n" ;; | ||
| "knip") failed_list="${failed_list}❌ Knip analysis\n" ;; | ||
| "compile") failed_list="${failed_list}❌ Compile & lint\n" ;; | ||
| "platform-unit-test") failed_list="${failed_list}❌ Unit tests\n" ;; | ||
| "integration-test") failed_list="${failed_list}❌ Integration tests\n" ;; | ||
| esac | ||
| done | ||
|
|
||
| # Remove trailing newline and save to output | ||
| echo "failed_jobs<<EOF" >> $GITHUB_OUTPUT | ||
| echo -e "$failed_list" | sed '/^$/d' >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Send Slack notification | ||
| uses: 8398a7/action-slack@v3 | ||
| with: | ||
| status: failure | ||
| channel: ${{ inputs.channel }} | ||
| text: | | ||
| 🚨 ${{ inputs.workflow-name }} workflow failed on main branch! | ||
|
|
||
| Repository: ${{ github.repository }} | ||
| Commit: ${{ github.sha }} | ||
| Author: ${{ github.actor }} | ||
|
|
||
| Failed jobs: | ||
| ${{ steps.parse-jobs.outputs.failed_jobs }} | ||
|
|
||
| View details: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ inputs.webhook-url }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,86 +1,102 @@ | ||
| name: Code QA Roo Code | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| types: [opened, reopened, ready_for_review, synchronize] | ||
| branches: [main] | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| types: [opened, reopened, ready_for_review, synchronize] | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| check-translations: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Verify all translations are complete | ||
| run: node scripts/find-missing-translations.js | ||
| check-translations: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Verify all translations are complete | ||
| run: node scripts/find-missing-translations.js | ||
|
|
||
| knip: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Run knip checks | ||
| run: pnpm knip | ||
| knip: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Run knip checks | ||
| run: pnpm knip | ||
|
|
||
| compile: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Lint | ||
| run: pnpm lint | ||
| - name: Check types | ||
| run: pnpm check-types | ||
| compile: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Lint | ||
| run: pnpm lint | ||
| - name: Check types | ||
| run: pnpm check-types | ||
|
|
||
| platform-unit-test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Run unit tests | ||
| run: pnpm test | ||
| platform-unit-test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Run unit tests | ||
| run: pnpm test | ||
|
|
||
| check-openrouter-api-key: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| exists: ${{ steps.openrouter-api-key-check.outputs.defined }} | ||
| steps: | ||
| - name: Check if OpenRouter API key exists | ||
| id: openrouter-api-key-check | ||
| shell: bash | ||
| run: | | ||
| if [ "${{ secrets.OPENROUTER_API_KEY }}" != '' ]; then | ||
| echo "defined=true" >> $GITHUB_OUTPUT; | ||
| else | ||
| echo "defined=false" >> $GITHUB_OUTPUT; | ||
| fi | ||
| check-openrouter-api-key: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| exists: ${{ steps.openrouter-api-key-check.outputs.defined }} | ||
| steps: | ||
| - name: Check if OpenRouter API key exists | ||
| id: openrouter-api-key-check | ||
| shell: bash | ||
| run: | | ||
| if [ "${{ secrets.OPENROUTER_API_KEY }}" != '' ]; then | ||
| echo "defined=true" >> $GITHUB_OUTPUT; | ||
| else | ||
| echo "defined=false" >> $GITHUB_OUTPUT; | ||
| fi | ||
| integration-test: | ||
| runs-on: ubuntu-latest | ||
| needs: [check-openrouter-api-key] | ||
| if: needs.check-openrouter-api-key.outputs.exists == 'true' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Create .env.local file | ||
| working-directory: apps/vscode-e2e | ||
| run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.local | ||
| - name: Run integration tests | ||
| working-directory: apps/vscode-e2e | ||
| run: xvfb-run -a pnpm test:ci | ||
| integration-test: | ||
| runs-on: ubuntu-latest | ||
| needs: [check-openrouter-api-key] | ||
| if: needs.check-openrouter-api-key.outputs.exists == 'true' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js and pnpm | ||
| uses: ./.github/actions/setup-node-pnpm | ||
| - name: Create .env.local file | ||
| working-directory: apps/vscode-e2e | ||
| run: echo "OPENROUTER_API_KEY=${{ secrets.OPENROUTER_API_KEY }}" > .env.local | ||
| - name: Run integration tests | ||
| working-directory: apps/vscode-e2e | ||
| run: xvfb-run -a pnpm test:ci | ||
|
|
||
| notify-slack-on-failure: | ||
| runs-on: ubuntu-latest | ||
| needs: [check-translations, knip, compile, platform-unit-test, integration-test] | ||
| if: ${{ always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/cte/slack-webhook') && (github.event_name == 'push' || github.event_name == 'pull_request') && contains(needs.*.result, 'failure') }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Send Slack notification on failure | ||
| uses: ./.github/actions/slack-notify | ||
| with: | ||
| webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
| channel: "#ci" | ||
| workflow-name: "Code QA" | ||
| failed-jobs: ${{ toJSON(needs) }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| describe("Slack Webhook Test", () => { | ||
| it("should deliberately fail to test Slack notifications", () => { | ||
| // This test is designed to fail to trigger the Slack webhook. | ||
| expect(true).toBe(false) | ||
| }) | ||
|
|
||
| it("should pass to show mixed results", () => { | ||
| expect(1 + 1).toBe(2) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When triggering on
pull_requestevents,github.refis usually a merge ref (e.g.,refs/pull/123/merge) and won’t equalrefs/heads/mainorrefs/heads/cte/slack-webhook. Consider usinggithub.base_reffor PR events to ensure the branch check works as intended.