From c6c60ba5cc3f1f536fee6ceed647396bea1da7cc Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Tue, 9 Apr 2024 16:34:25 +0300 Subject: [PATCH] ci: Delete QNS PR comment on successful run (#1807) * ci: Always add or update the QNS PR comment Because we only add one when there is a failure, and when things then later get fixed we don't update it again (because we skip the update on success). So the outdated, failed state keeps being shown. * Delete comment on success * Update .github/actions/pr-comment/action.yml Co-authored-by: Max Inden Signed-off-by: Lars Eggert * Address code review --------- Signed-off-by: Lars Eggert Co-authored-by: Max Inden --- .github/actions/pr-comment/action.yml | 4 ++++ .github/actions/quic-interop-runner/action.yml | 7 ++----- .github/workflows/qns-comment.yml | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/actions/pr-comment/action.yml b/.github/actions/pr-comment/action.yml index b7f9bb12da..1e84aa5bb4 100644 --- a/.github/actions/pr-comment/action.yml +++ b/.github/actions/pr-comment/action.yml @@ -5,6 +5,9 @@ inputs: name: description: 'Artifact name to import comment data from.' required: true + mode: + description: 'Mode of operation (upsert/recreate/delete).' + default: 'upsert' token: description: 'A Github PAT' required: true @@ -29,5 +32,6 @@ runs: - uses: thollander/actions-comment-pull-request@v2 with: filePath: contents + mode: ${{ inputs.mode }} pr_number: ${{ steps.pr-number.outputs.number }} comment_tag: ${{ inputs.name }}-comment diff --git a/.github/actions/quic-interop-runner/action.yml b/.github/actions/quic-interop-runner/action.yml index 7fd055f184..cdc617d275 100644 --- a/.github/actions/quic-interop-runner/action.yml +++ b/.github/actions/quic-interop-runner/action.yml @@ -91,12 +91,9 @@ runs: - name: Format GitHub comment if: always() run: | - if [ -s quic-interop-runner/summary ]; then - exit 0 - fi echo '[**QUIC Interop Runner**](https://github.com/quic-interop/quic-interop-runner)' >> comment echo '' >> comment - # Ignore all, but table, which starts with "|". + # Ignore all, but table, which starts with "|". Also reformat it to GitHub Markdown. grep -E '^\|' quic-interop-runner/summary |\ awk '(!/^\| *:-/ || (d++ && d < 3))' |\ sed -E -e 's/✓/:white_check_mark:/gi' -e 's/✕/:x:/gi' -e 's/\?/:grey_question:/gi' \ @@ -106,7 +103,7 @@ runs: shell: bash - name: Export PR comment data - if: env.EXPORT_COMMENT == '1' + if: always() uses: ./.github/actions/pr-comment-data-export with: name: qns diff --git a/.github/workflows/qns-comment.yml b/.github/workflows/qns-comment.yml index 71cbcc805b..db9f74f7bf 100644 --- a/.github/workflows/qns-comment.yml +++ b/.github/workflows/qns-comment.yml @@ -18,11 +18,11 @@ jobs: pull-requests: write runs-on: ubuntu-latest if: | - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'failure' + github.event.workflow_run.event == 'pull_request' steps: - uses: actions/checkout@v4 - uses: ./.github/actions/pr-comment with: name: qns + mode: ${{ github.event.workflow_run.conclusion == 'success' && 'delete' || 'upsert' }} token: ${{ secrets.GITHUB_TOKEN }}