From f096557897d00e59e619dc73581eeb2e0fe9f99a Mon Sep 17 00:00:00 2001 From: Caue Santos Date: Fri, 6 Nov 2026 12:29:56 -0600 Subject: [PATCH] test(e2e-command): reply to each command with its runs --- .../caller-comment-triggered-check.yaml | 70 +++++++++++-------- .github/workflows/caller-e2e-oss-run.yaml | 4 +- .github/workflows/caller-e2e-pro-run.yaml | 4 +- .../workflows/caller-platform-command.yaml | 50 ++++++++----- .github/workflows/caller-platform-run.yaml | 4 +- 5 files changed, 79 insertions(+), 53 deletions(-) diff --git a/.github/workflows/caller-comment-triggered-check.yaml b/.github/workflows/caller-comment-triggered-check.yaml index 1b1294b..3d1c7fc 100644 --- a/.github/workflows/caller-comment-triggered-check.yaml +++ b/.github/workflows/caller-comment-triggered-check.yaml @@ -66,13 +66,16 @@ jobs: # DEFINITION from the pull request and run it with this token. - name: Parse the command and open the pro check id: pro - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: start command: /test-e2e check-name-prefix: e2e-pro parse-focus: true target-name: pro + reply: "true" + comment-id: ${{ github.event.comment.id }} + run-label: Pro comment-body: ${{ github.event.comment.body }} comment-author: ${{ github.event.comment.user.login }} author-association: ${{ github.event.comment.author_association }} @@ -84,13 +87,16 @@ jobs: - name: Open the oss check id: oss if: ${{ steps.pro.outputs.target == 'oss' || (steps.pro.outputs.target == '' && steps.pro.outputs.should-run == 'true') }} - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: start command: /test-e2e check-name-prefix: e2e-oss parse-focus: true target-name: oss + reply: "true" + comment-id: ${{ github.event.comment.id }} + run-label: OSS comment-body: ${{ github.event.comment.body }} comment-author: ${{ github.event.comment.user.login }} author-association: ${{ github.event.comment.author_association }} @@ -135,7 +141,7 @@ jobs: - name: Close the pro check if the branch has no contract if: ${{ always() && steps.pro.outputs.should-run == 'true' && steps.contract.outcome != 'success' }} - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ steps.pro.outputs.check-run-id }} @@ -145,7 +151,7 @@ jobs: - name: Close the oss check if the branch has no contract if: ${{ always() && steps.oss.outputs.should-run == 'true' && steps.contract.outcome != 'success' }} - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ steps.oss.outputs.check-run-id }} @@ -155,7 +161,7 @@ jobs: - name: Close whatever was opened if preparing failed if: failure() - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ steps.pro.outputs.check-run-id }} @@ -262,14 +268,26 @@ jobs: env: CHECK_RUN_ID: ${{ needs.prepare.outputs.pro-check-run-id }} run: | - gh workflow run caller-e2e-pro-run.yaml \ + output="$(gh workflow run caller-e2e-pro-run.yaml \ --ref "$WORKFLOW_REF" \ -f "ginkgo-label=$FILTER" \ -f "ginkgo-focus=$FOCUS" \ -f "head-sha=$HEAD_SHA" \ -f "compose-with-pr=false" \ -f "concurrency-key=$KEY" \ - -f "check-run-id=$CHECK_RUN_ID" + -f "check-run-id=$CHECK_RUN_ID" 2>&1)" || { echo "$output"; exit 1; } + echo "$output" + # gh prints the URL of the run it started. + url="$(grep -Eo 'https://[^[:space:]]+/actions/runs/[0-9]+' <<< "$output" | head -n1 || true)" + echo "url=${url}" >> "$GITHUB_OUTPUT" + + - name: Link the pro run in the reply + if: ${{ steps.dispatch-pro.outputs.url != '' }} + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply + with: + mode: link + check-run-id: ${{ needs.prepare.outputs.pro-check-run-id }} + run-url: ${{ steps.dispatch-pro.outputs.url }} - name: Run the oss suite id: dispatch-oss @@ -278,40 +296,30 @@ jobs: env: CHECK_RUN_ID: ${{ needs.prepare.outputs.oss-check-run-id }} run: | - gh workflow run caller-e2e-oss-run.yaml \ + output="$(gh workflow run caller-e2e-oss-run.yaml \ --ref "$WORKFLOW_REF" \ -f "ginkgo-label=$FILTER" \ -f "ginkgo-focus=$FOCUS" \ -f "head-sha=$HEAD_SHA" \ -f "compose-with-pr=false" \ -f "concurrency-key=$KEY" \ - -f "check-run-id=$CHECK_RUN_ID" + -f "check-run-id=$CHECK_RUN_ID" 2>&1)" || { echo "$output"; exit 1; } + echo "$output" + # gh prints the URL of the run it started. + url="$(grep -Eo 'https://[^[:space:]]+/actions/runs/[0-9]+' <<< "$output" | head -n1 || true)" + echo "url=${url}" >> "$GITHUB_OUTPUT" - - name: Say what it picked - if: always() - uses: loft-sh/github-actions/.github/actions/sticky-pr-comment@ee112eee4fb449b7b1e78f63fdec314563be534d # sticky-pr-comment/v1 + - name: Link the oss run in the reply + if: ${{ steps.dispatch-oss.outputs.url != '' }} + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: - # Required here. The input defaults to github.event.pull_request.number, - # which is empty on issue_comment, and the action then refuses. - pr-number: ${{ github.event.issue.number }} - marker: '' - body: | - ### `/test-e2e` started - - Target: `${{ needs.prepare.outputs.target != '' && needs.prepare.outputs.target || 'pro + oss' }}` - - - **Pro:** ${{ needs.prepare.outputs.target == 'oss' && 'Not requested' || steps.dispatch-pro.outcome == 'success' && 'Started' || 'Failed to start' }} - - **OSS:** ${{ needs.prepare.outputs.target == 'pro' && 'Not requested' || steps.dispatch-oss.outcome == 'success' && 'Started' || 'Failed to start' }} - - Filter: `${{ needs.prepare.outputs.filter }}` - ${{ needs.prepare.outputs.focus != '' && format('Focus: `{0}`', needs.prepare.outputs.focus) || '' }} - - If no specs match in a selected tree, its check reports **Nothing to run**. - github-token: ${{ secrets.GITHUB_TOKEN }} + mode: link + check-run-id: ${{ needs.prepare.outputs.oss-check-run-id }} + run-url: ${{ steps.dispatch-oss.outputs.url }} - name: Close the pro check if its dispatch failed if: ${{ steps.dispatch-pro.outcome == 'failure' }} - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ needs.prepare.outputs.pro-check-run-id }} @@ -321,7 +329,7 @@ jobs: - name: Close the oss check if its dispatch failed if: ${{ steps.dispatch-oss.outcome == 'failure' }} - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ needs.prepare.outputs.oss-check-run-id }} diff --git a/.github/workflows/caller-e2e-oss-run.yaml b/.github/workflows/caller-e2e-oss-run.yaml index efb4cda..0e74a76 100644 --- a/.github/workflows/caller-e2e-oss-run.yaml +++ b/.github/workflows/caller-e2e-oss-run.yaml @@ -152,10 +152,12 @@ jobs: runs-on: ubuntu-latest permissions: checks: write + # Redraws the command's reply. + pull-requests: write steps: - name: Complete the check-run - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ inputs.check-run-id }} diff --git a/.github/workflows/caller-e2e-pro-run.yaml b/.github/workflows/caller-e2e-pro-run.yaml index c07d4eb..771c9f1 100644 --- a/.github/workflows/caller-e2e-pro-run.yaml +++ b/.github/workflows/caller-e2e-pro-run.yaml @@ -152,10 +152,12 @@ jobs: runs-on: ubuntu-latest permissions: checks: write + # Redraws the command's reply. + pull-requests: write steps: - name: Complete the check-run - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ inputs.check-run-id }} diff --git a/.github/workflows/caller-platform-command.yaml b/.github/workflows/caller-platform-command.yaml index 17690a0..b06d889 100644 --- a/.github/workflows/caller-platform-command.yaml +++ b/.github/workflows/caller-platform-command.yaml @@ -27,16 +27,21 @@ jobs: head-sha: ${{ steps.command.outputs.head-sha }} key: ${{ steps.command.outputs.concurrency-key }} check-run-id: ${{ steps.command.outputs.check-run-id }} + runs: ${{ steps.command.outputs.runs }} steps: - name: Parse command and open check id: command - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: start command: /test-platform-e2e check-name-prefix: e2e-platform parse-focus: true + parse-runs: true + reply: "true" + comment-id: ${{ github.event.comment.id }} + run-label: Platform comment-body: ${{ github.event.comment.body }} comment-author: ${{ github.event.comment.user.login }} author-association: ${{ github.event.comment.author_association }} @@ -58,7 +63,7 @@ jobs: - name: Close the check if the branch has no contract if: ${{ always() && steps.command.outputs.should-run == 'true' && steps.contract.outcome != 'success' }} - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ steps.command.outputs.check-run-id }} @@ -77,10 +82,15 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} dispatch: - name: Dispatch suite + name: Dispatch suite (${{ matrix.run.check-name }}) needs: [prepare] if: ${{ needs.prepare.outputs.should-run == 'true' }} runs-on: ubuntu-latest + # One job per --runs run, like loft-enterprise, so the links race for the reply. + strategy: + fail-fast: false + matrix: + run: ${{ fromJSON(needs.prepare.outputs.runs) }} permissions: actions: write checks: write @@ -94,8 +104,8 @@ jobs: HEAD_SHA: ${{ needs.prepare.outputs.head-sha }} FILTER: ${{ needs.prepare.outputs.filter }} FOCUS: ${{ needs.prepare.outputs.focus }} - KEY: ${{ needs.prepare.outputs.key }} - CHECK_RUN_ID: ${{ needs.prepare.outputs.check-run-id }} + KEY: ${{ matrix.run.concurrency-key }} + CHECK_RUN_ID: ${{ matrix.run.check-run-id }} PR_NUMBER: ${{ github.event.issue.number }} steps: @@ -103,35 +113,37 @@ jobs: id: dispatch continue-on-error: true run: | - gh workflow run caller-platform-run.yaml \ + output="$(gh workflow run caller-platform-run.yaml \ --ref "$WORKFLOW_REF" \ -f "ginkgo-label=$FILTER" \ -f "ginkgo-focus=$FOCUS" \ -f "head-sha=$HEAD_SHA" \ -f "concurrency-key=$KEY" \ -f "pr-number=$PR_NUMBER" \ - -f "check-run-id=$CHECK_RUN_ID" + -f "check-run-id=$CHECK_RUN_ID" 2>&1)" || { echo "$output"; exit 1; } + echo "$output" + # gh prints the URL of the run it started. + url="$(grep -Eo 'https://[^[:space:]]+/actions/runs/[0-9]+' <<< "$output" | head -n1 || true)" + echo "url=${url}" >> "$GITHUB_OUTPUT" + + - name: Link the run in the reply + if: ${{ steps.dispatch.outputs.url != '' }} + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply + with: + mode: link + check-run-id: ${{ matrix.run.check-run-id }} + run-url: ${{ steps.dispatch.outputs.url }} - name: Close check if dispatch failed if: ${{ always() && steps.dispatch.outcome == 'failure' }} - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish - check-run-id: ${{ needs.prepare.outputs.check-run-id }} + check-run-id: ${{ matrix.run.check-run-id }} suite-result: failure summary: "Could not start the mock Platform suite." details-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - - name: Report dispatch - if: always() - uses: loft-sh/github-actions/.github/actions/sticky-pr-comment@sticky-pr-comment/v1 - with: - pr-number: ${{ github.event.issue.number }} - marker: '' - body: | - `/test-platform-e2e ${{ needs.prepare.outputs.filter }}${{ needs.prepare.outputs.focus != '' && format(' --focus "{0}"', needs.prepare.outputs.focus) || '' }}`: `${{ steps.dispatch.outcome }}`. - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Fail if dispatch failed if: ${{ always() && steps.dispatch.outcome == 'failure' }} run: exit 1 diff --git a/.github/workflows/caller-platform-run.yaml b/.github/workflows/caller-platform-run.yaml index 56e979b..c28fd96 100644 --- a/.github/workflows/caller-platform-run.yaml +++ b/.github/workflows/caller-platform-run.yaml @@ -106,9 +106,11 @@ jobs: runs-on: ubuntu-latest permissions: checks: write + # Redraws the command's reply. + pull-requests: write steps: - name: Complete check - uses: loft-sh/github-actions/.github/actions/comment-triggered-check@comment-triggered-check/v1 + uses: loft-sh/github-actions/.github/actions/comment-triggered-check@devops-1843/test-e2e-run-reply with: mode: finish check-run-id: ${{ inputs.check-run-id }}