diff --git a/.github/workflows/mantis-telegram-desktop-proof.yml b/.github/workflows/mantis-telegram-desktop-proof.yml index bb592ca004f1..365b50441b41 100644 --- a/.github/workflows/mantis-telegram-desktop-proof.yml +++ b/.github/workflows/mantis-telegram-desktop-proof.yml @@ -181,7 +181,7 @@ jobs: setOutput("request_source", requestSource); - name: Create Mantis status token id: mantis_status_token - if: ${{ steps.resolve.outputs.request_source == 'issue_comment' }} + if: ${{ steps.resolve.outputs.pr_number != '' }} continue-on-error: true uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 with: @@ -201,12 +201,9 @@ jobs: with: github-token: ${{ steps.mantis_status_token.outputs.token }} script: | - const markerRoot = "`; + const marker = ``; const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; - const body = `${marker}\nMantis started this proof. [Follow the active job](${runUrl}).`; + const body = `${marker}\nšŸ‘€ Mantis started this proof. [Follow the active job](${runUrl}).`; const { owner, repo } = context.repo; const issueNumber = Number(process.env.TARGET_PR); await github.rest.issues.createComment({ @@ -248,7 +245,7 @@ jobs: if: >- ${{ always() && - steps.resolve.outputs.request_source == 'issue_comment' && + steps.resolve.outputs.pr_number != '' && ( steps.mantis_status_token.outcome != 'success' || steps.mantis_status_comment.outcome != 'success' @@ -260,7 +257,7 @@ jobs: with: github-token: ${{ github.token }} script: | - const marker = ""; + const marker = ``; const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; const { owner, repo } = context.repo; await github.rest.issues.createComment({ @@ -1238,7 +1235,7 @@ jobs: --request-source "$REQUEST_SOURCE" - name: Report failed Mantis proof - if: ${{ always() && needs.resolve_request.outputs.request_source == 'issue_comment' && steps.publish_evidence.outcome != 'success' }} + if: ${{ always() && needs.resolve_request.outputs.pr_number != '' && steps.publish_evidence.outcome != 'success' }} uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 env: TARGET_PR: ${{ needs.resolve_request.outputs.pr_number }} @@ -1367,7 +1364,8 @@ jobs: --manifest "$root/mantis-evidence.json" \ --target-pr "$TARGET_PR" \ --artifact-root "mantis/telegram-desktop/pr-${TARGET_PR}/published-${PUBLISH_RUN_ID}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \ - --marker "" \ + --marker "" \ + --create-missing false \ --artifact-url "$PUBLISH_ARTIFACT_URL" \ --run-url "https://github.com/${GITHUB_REPOSITORY}/actions/runs/${PUBLISH_RUN_ID}" \ --request-source "$REQUEST_SOURCE" diff --git a/scripts/mantis/publish-pr-evidence.mjs b/scripts/mantis/publish-pr-evidence.mjs index 7fa73f9c1536..abffd0d1e61e 100644 --- a/scripts/mantis/publish-pr-evidence.mjs +++ b/scripts/mantis/publish-pr-evidence.mjs @@ -631,7 +631,7 @@ function upsertPrComment({ body, createMissing, marker, prNumber, repo }) { } catch { if (!createMissing) { console.log( - "Skipped stale Mantis QA evidence comment because its status is no longer active.", + `Could not update existing Mantis QA evidence comment ${commentId}; create-missing is false.`, ); return; } @@ -641,9 +641,7 @@ function upsertPrComment({ body, createMissing, marker, prNumber, repo }) { } } if (!createMissing) { - console.log( - "Skipped stale Mantis QA evidence comment because its status is no longer active.", - ); + console.log("No existing Mantis QA evidence comment found and create-missing is false."); return; } run("gh", ["pr", "comment", prNumber, "--body-file", bodyFile], { stdio: "inherit" }); diff --git a/test/scripts/mantis-telegram-desktop-proof-workflow.test.ts b/test/scripts/mantis-telegram-desktop-proof-workflow.test.ts index a7dde97b654f..709f918ec75c 100644 --- a/test/scripts/mantis-telegram-desktop-proof-workflow.test.ts +++ b/test/scripts/mantis-telegram-desktop-proof-workflow.test.ts @@ -382,10 +382,11 @@ describe("Mantis Telegram Desktop proof workflow", () => { const fallbackComment = resolver?.steps?.find( (step) => step.name === "Report Mantis start failure with workflow token", ); - expect(startedToken?.if).toContain("request_source == 'issue_comment'"); + expect(startedToken?.if).toBe("${{ steps.resolve.outputs.pr_number != '' }}"); + expect(startedToken?.if).not.toContain("request_source"); expect(startedToken?.with?.["permission-pull-requests"]).toBe("write"); expect(startedComment?.["continue-on-error"]).toBe(true); - expect(startedComment?.with?.script).toContain("Mantis started this proof."); + expect(startedComment?.with?.script).toContain("šŸ‘€ Mantis started this proof."); expect(startedComment?.with?.script).toContain("actions/runs/${process.env.GITHUB_RUN_ID}"); expect(startedComment?.with?.script).toContain("mantis-telegram-desktop-proof:"); expect(startedComment?.with?.script).toContain("GITHUB_RUN_ATTEMPT"); @@ -393,6 +394,8 @@ describe("Mantis Telegram Desktop proof workflow", () => { expect(startedComment?.with?.script).toContain("issues.deleteComment"); expect(fallbackComment?.if).toContain("steps.mantis_status_token.outcome != 'success'"); expect(fallbackComment?.if).toContain("steps.mantis_status_comment.outcome != 'success'"); + expect(fallbackComment?.if).toContain("steps.resolve.outputs.pr_number != ''"); + expect(fallbackComment?.if).not.toContain("request_source"); expect(fallbackComment?.with?.["github-token"]).toBe("${{ github.token }}"); expect(fallbackComment?.["continue-on-error"]).toBeUndefined(); expect(fallbackComment?.with?.script).toContain("mantis-telegram-desktop-proof"); @@ -406,7 +409,8 @@ describe("Mantis Telegram Desktop proof workflow", () => { const failureComment = proofSteps.find((step) => step.name === "Report failed Mantis proof"); expect(evidenceComment?.id).toBe("publish_evidence"); expect(failureComment?.if).toContain("always()"); - expect(failureComment?.if).toContain("request_source == 'issue_comment'"); + expect(failureComment?.if).toContain("needs.resolve_request.outputs.pr_number != ''"); + expect(failureComment?.if).not.toContain("request_source"); expect(failureComment?.if).toContain("steps.publish_evidence.outcome != 'success'"); expect(failureComment?.with?.script).toContain("Mantis could not complete this proof."); expect(failureComment?.with?.script).toContain("issues.updateComment"); @@ -454,6 +458,15 @@ describe("Mantis Telegram Desktop proof workflow", () => { expect(workflowText).toContain( "PUBLISH_ARTIFACT_URL=https://github.com/${GITHUB_REPOSITORY}/actions/runs/", ); + const evidenceComment = jobStep( + WORKFLOW, + "publish_existing_telegram_desktop_proof", + "Comment PR with inline QA evidence", + ); + expect(evidenceComment.run).toContain( + "mantis-telegram-desktop-proof:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}", + ); + expect(evidenceComment.run).toContain("--create-missing false"); }); it("limits evidence publishers to comment and PR-read permissions", () => {