From b3ca674febc91551b08656e02985685701b38305 Mon Sep 17 00:00:00 2001 From: Luke Cartey Date: Mon, 7 Oct 2024 10:19:42 +0100 Subject: [PATCH] Switch to workflow dispatch for cross repo testing The PR testing jobs were still using repository dispatch, but the target workflows had changed to use workflow dispatch. --- .github/workflows/dispatch-matrix-check.yml | 50 ------------------- .../dispatch-matrix-test-on-comment.yml | 19 ++++--- .../dispatch-release-performance-check.yml | 19 ++++--- 3 files changed, 24 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/dispatch-matrix-check.yml diff --git a/.github/workflows/dispatch-matrix-check.yml b/.github/workflows/dispatch-matrix-check.yml deleted file mode 100644 index 845a8fc4ae..0000000000 --- a/.github/workflows/dispatch-matrix-check.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: 🤖 Run Matrix Check - -on: - pull_request_target: - types: [synchronize, opened] - branches: - - "matrix/**" - workflow_dispatch: - -jobs: - dispatch-matrix-check: - runs-on: ubuntu-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Check permission - id: check-write-permission - uses: ./.github/actions/check-permissions - with: - minimum-permission: "write" - - - name: Generate token - id: generate-token - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ vars.AUTOMATION_APP_ID }} - private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: "codeql-coding-standards-release-engineering" - - - name: Dispatch Matrix Testing Job - if: steps.check-write-permission.outputs.has-permission - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ steps.generate-token.outputs.token }} - repository: github/codeql-coding-standards-release-engineering - event-type: matrix-test - client-payload: '{"pr": "${{ github.event.number }}"}' - - - uses: actions/github-script@v6 - if: steps.check-write-permission.outputs.has-permission - with: - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '🤖 Beep Boop! Matrix Testing for this PR has been initiated. Please check back later for results.

:bulb: If you do not hear back from me please check my status! **I will report even if this PR does not contain files eligible for matrix testing.**' - }) diff --git a/.github/workflows/dispatch-matrix-test-on-comment.yml b/.github/workflows/dispatch-matrix-test-on-comment.yml index 4f9f9a5b1e..297b6fbc7e 100644 --- a/.github/workflows/dispatch-matrix-test-on-comment.yml +++ b/.github/workflows/dispatch-matrix-test-on-comment.yml @@ -26,14 +26,19 @@ jobs: owner: ${{ github.repository_owner }} repositories: "codeql-coding-standards-release-engineering" - - name: Dispatch Matrix Testing Job + - name: Invoke matrix testing job if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-matrix') && steps.check-write-permission.outputs.has-permission }} - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ steps.generate-token.outputs.token }} - repository: github/codeql-coding-standards-release-engineering - event-type: matrix-test - client-payload: '{"pr": "${{ github.event.issue.number }}"}' + env: + ISSUE_NR: ${{ github.event.issue.number }} + GH_TOKEN: ${{ steps.generate-token.outputs.token }} + run: | + jq -n \ + --arg issue_nr "$ISSUE_NR" \ + '{"issue-nr": $issue_nr}' \ + | \ + gh workflow run pr-compiler-validation.yml \ + --json \ + -R github/codeql-coding-standards-release-engineering - uses: actions/github-script@v6 if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-matrix') && steps.check-write-permission.outputs.has-permission }} diff --git a/.github/workflows/dispatch-release-performance-check.yml b/.github/workflows/dispatch-release-performance-check.yml index 7e28a9c4f9..260846185a 100644 --- a/.github/workflows/dispatch-release-performance-check.yml +++ b/.github/workflows/dispatch-release-performance-check.yml @@ -26,14 +26,19 @@ jobs: owner: ${{ github.repository_owner }} repositories: "codeql-coding-standards-release-engineering" - - name: Dispatch Performance Testing Job + - name: Invoke performance test if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') && steps.check-write-permission.outputs.has-permission }} - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ steps.generate-token.outputs.token }} - repository: github/codeql-coding-standards-release-engineering - event-type: performance-test - client-payload: '{"pr": "${{ github.event.issue.number }}"}' + env: + ISSUE_NR: ${{ github.event.issue.number }} + GH_TOKEN: ${{ steps.generate-token.outputs.token }} + run: | + jq -n \ + --arg issue_nr "$ISSUE_NR" \ + '{"issue-nr": $issue_nr}' \ + | \ + gh workflow run pr-performance-testing.yml \ + --json \ + -R github/codeql-coding-standards-release-engineering - uses: actions/github-script@v6 if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') && steps.check-write-permission.outputs.has-permission }}