Skip to content
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

Don't create duplicate issues on workflow failures #8441

Merged
merged 2 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/build-daily-no-build-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ jobs:
# markdown-link-check and misspell-check are not included here because they don't use gradle cache
# anyway and so are already covered by the normal daily build

open-issue-on-failure:
workflow-notification:
needs:
- common
- test-latest-deps
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: needs.common.result == 'success' && needs.test-latest-deps.result == 'success'
13 changes: 10 additions & 3 deletions .github/workflows/build-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ jobs:
misspell-check:
uses: ./.github/workflows/reusable-misspell-check.yml

open-issue-on-failure:
workflow-notification:
needs:
- common
- test-latest-deps
- muzzle
- markdown-link-check
- misspell-check
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: |
needs.common.result == 'success' &&
needs.test-latest-deps.result == 'success' &&
needs.muzzle.result == 'success' &&
needs.markdown-link-check.result == 'success' &&
needs.misspell-check.result == 'success'
9 changes: 5 additions & 4 deletions .github/workflows/codeql-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ jobs:
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v2

open-issue-on-failure:
# open an issue on failure because it can be easy to miss CI failure notifications
workflow-notification:
needs:
- analyze
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: needs.analyze.result == 'success'
8 changes: 5 additions & 3 deletions .github/workflows/overhead-benchmark-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ jobs:
committer_name: opentelemetrybot
committer_email: 107717825+opentelemetrybot@users.noreply.github.com

open-issue-on-failure:
workflow-notification:
needs:
- run-overhead-tests
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: needs.run-overhead-tests.result == 'success'
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ jobs:
with:
arguments: ":smoke-tests:images:fake-backend:dockerPush -PextraTag=${{ env.TAG }}"

open-issue-on-failure:
workflow-notification:
needs:
- publishLinux
- publishWindows
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: needs.publishLinux.result == 'success' && needs.publishWindows.result == 'success'

8 changes: 5 additions & 3 deletions .github/workflows/publish-smoke-test-grpc-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
project: ":smoke-tests:images:grpc"
publish: true

open-issue-on-failure:
workflow-notification:
needs:
- publish
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: ${{ needs.publish.result == 'success' }}
8 changes: 5 additions & 3 deletions .github/workflows/publish-smoke-test-play-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ jobs:
skip-java-17: true
skip-java-19: true

open-issue-on-failure:
workflow-notification:
needs:
- publish
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: ${{ needs.publish.result == 'success' }}
8 changes: 5 additions & 3 deletions .github/workflows/publish-smoke-test-quarkus-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
# Quarkus 2.0+ does not support Java 8
skip-java-8: true

open-issue-on-failure:
workflow-notification:
needs:
- publish
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: ${{ needs.publish.result == 'success' }}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
project: ":smoke-tests:images:security-manager"
publish: true

open-issue-on-failure:
workflow-notification:
needs:
- publish
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: ${{ needs.publish.result == 'success' }}
8 changes: 5 additions & 3 deletions .github/workflows/publish-smoke-test-servlet-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ jobs:
if: matrix.os == 'windows-latest'
run: ./gradlew :smoke-tests:images:servlet:buildWindowsTestImages pushMatrix -PextraTag=${{ needs.prepare.outputs.tag }} -PsmokeTestServer=${{ matrix.smoke-test-server }}

open-issue-on-failure:
workflow-notification:
needs:
- publish
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: ${{ needs.publish.result == 'success' }}
8 changes: 5 additions & 3 deletions .github/workflows/publish-smoke-test-spring-boot-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
project: ":smoke-tests:images:spring-boot"
publish: true

open-issue-on-failure:
workflow-notification:
needs:
- publish
if: failure() && github.run_attempt == 1
uses: ./.github/workflows/reusable-open-issue-on-failure.yml
if: always()
uses: ./.github/workflows/reusable-workflow-notification.yml
with:
success: ${{ needs.publish.result == 'success' }}
18 changes: 0 additions & 18 deletions .github/workflows/reusable-open-issue-on-failure.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/reusable-workflow-notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# this is useful because notifications for scheduled workflows are only sent to the user who
# initially created the given workflow
name: Reusable - Workflow notification

on:
workflow_call:
inputs:
success:
type: boolean
required: true

jobs:
workflow-notification:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Open issue or add comment if issue already open
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
number=$(gh issue list --search "Workflow failed: $GITHUB_WORKFLOW" --limit 1 --json number -q .[].number)

echo $number
echo ${{ inputs.success }}

Comment on lines +24 to +26
Copy link
Member Author

@trask trask May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll come back and remove these echos later once we know it's working well

if [[ $number ]]; then
if [[ "${{ inputs.success }}" == "true" ]]; then
gh issue close $number
else
gh issue comment $number \
--body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."
fi
elif [[ "${{ inputs.success }}" == "false" ]]; then
gh issue create --title "Workflow failed: $GITHUB_WORKFLOW (#$GITHUB_RUN_NUMBER)" \
--body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."
fi