From 657285c94fec9e3d5c334c78ebaf6f4e6f82a6d3 Mon Sep 17 00:00:00 2001 From: Saturnino Abril <5334504+saturninoabril@users.noreply.github.com> Date: Wed, 15 Apr 2026 12:50:18 +0800 Subject: [PATCH] feat(workflow): pr test analysis --- .../workflows/pr-test-analysis-override.yml | 34 +++++++++++++ .github/workflows/pr-test-analysis.yml | 48 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/pr-test-analysis-override.yml create mode 100644 .github/workflows/pr-test-analysis.yml diff --git a/.github/workflows/pr-test-analysis-override.yml b/.github/workflows/pr-test-analysis-override.yml new file mode 100644 index 0000000000..b3e0222cd7 --- /dev/null +++ b/.github/workflows/pr-test-analysis-override.yml @@ -0,0 +1,34 @@ +--- +name: PR Test Analysis Override + +on: + issue_comment: + types: [created] + +concurrency: + group: test-analyzer-${{ github.event.issue.number }} + cancel-in-progress: false + +jobs: + override: + permissions: + statuses: write + pull-requests: read + contents: read + issues: write + if: >- + github.repository == 'mattermost/mattermost-mobile' && + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/test-analysis-override') && + contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) + # Pin to a commit SHA once the reusable workflow is stable. Using @main during initial rollout. + uses: mattermost/mattermost-test-automation-toolkit/.github/workflows/pr-test-analysis-override.yml@main + with: + pr_number: ${{ github.event.issue.number }} + target_repo: mattermost/mattermost-mobile + comment_body: ${{ github.event.comment.body }} + comment_id: ${{ github.event.comment.id }} + sender: ${{ github.event.comment.user.login }} + secrets: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + WEBHOOK_URL: ${{ secrets.WEBHOOK_URL_TEST_PR_ANALYSIS_HUB }} diff --git a/.github/workflows/pr-test-analysis.yml b/.github/workflows/pr-test-analysis.yml new file mode 100644 index 0000000000..6fe32e8b2e --- /dev/null +++ b/.github/workflows/pr-test-analysis.yml @@ -0,0 +1,48 @@ +--- +name: PR Test Analysis + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: + - main + - 'release-*' + workflow_dispatch: + inputs: + pr_number: + description: 'PR number to analyze' + required: true + type: number + claude_model: + description: 'Claude model to use (default: claude-sonnet-4-6)' + required: false + type: string + +concurrency: + group: test-analyzer-${{ github.event.pull_request.number || inputs.pr_number }} + cancel-in-progress: true + +jobs: + analyze: + permissions: + contents: read + pull-requests: write + statuses: write + id-token: write + # pull_request: skip drafts and forks (drafts are not ready for analysis; + # fork runs do not receive this repo's Actions secrets). + # workflow_dispatch: always allowed — runs in this repo with secrets, so you can pass a fork PR number manually. + if: >- + github.event_name == 'workflow_dispatch' || + (github.event.pull_request.draft == false && + github.event.pull_request.head.repo.full_name == 'mattermost/mattermost-mobile') + # Pin to a commit SHA once the reusable workflow is stable. Using @main during initial rollout. + uses: mattermost/mattermost-test-automation-toolkit/.github/workflows/pr-test-analysis.yml@main + with: + pr_number: ${{ github.event.pull_request.number || inputs.pr_number }} + target_repo: mattermost/mattermost-mobile + claude_model: ${{ inputs.claude_model || vars.CLAUDE_MODEL || 'claude-sonnet-4-6' }} + secrets: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + WEBHOOK_URL: ${{ secrets.WEBHOOK_URL_TEST_PR_ANALYSIS_HUB }}