From 25ce53737385b66c8809c03b7e3ddf73f71891d7 Mon Sep 17 00:00:00 2001 From: Eshed Schacham Date: Mon, 14 Apr 2025 11:33:59 +0200 Subject: [PATCH] ci: fix workflow triggering extended tests from pr comments. For creating a workflow with workflow_dispatch, you can't specify a branch name in another repo as the ref. Instead you need to use the local ref to the PR. --- .github/workflows/extended.yml | 10 +++++++--- .github/workflows/pr_comment_commands.yml | 10 +++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/extended.yml b/.github/workflows/extended.yml index a5d68ff079b5..d80fdb75d932 100644 --- a/.github/workflows/extended.yml +++ b/.github/workflows/extended.yml @@ -47,7 +47,7 @@ on: permissions: contents: read checks: write - + jobs: # Check crate compiles and base cargo check passes @@ -58,6 +58,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + ref: ${{ github.event.inputs.pr_head_sha }} # will be empty if triggered by push submodules: true fetch-depth: 1 - name: Install Rust @@ -81,6 +82,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + ref: ${{ github.event.inputs.pr_head_sha }} # will be empty if triggered by push submodules: true fetch-depth: 1 - name: Free Disk Space (Ubuntu) @@ -114,6 +116,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + ref: ${{ github.event.inputs.pr_head_sha }} # will be empty if triggered by push submodules: true fetch-depth: 1 - name: Setup Rust toolchain @@ -134,6 +137,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + ref: ${{ github.event.inputs.pr_head_sha }} # will be empty if triggered by push submodules: true fetch-depth: 1 - name: Setup Rust toolchain @@ -161,14 +165,14 @@ jobs: echo "workflow_status=completed" >> $GITHUB_OUTPUT echo "conclusion=success" >> $GITHUB_OUTPUT fi - + - name: Update check run uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; - + await github.rest.checks.update({ owner: context.repo.owner, repo: context.repo.repo, diff --git a/.github/workflows/pr_comment_commands.yml b/.github/workflows/pr_comment_commands.yml index a20a5b15965d..6aa6caaf34d0 100644 --- a/.github/workflows/pr_comment_commands.yml +++ b/.github/workflows/pr_comment_commands.yml @@ -44,12 +44,12 @@ jobs: repo: context.repo.repo, pull_number: context.payload.issue.number }); - + // Extract the branch name const branchName = pullRequest.head.ref; const headSha = pullRequest.head.sha; const workflowRunsUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions?query=workflow%3A%22Datafusion+extended+tests%22+branch%3A${branchName}`; - + // Create a check run that links to the Actions tab so the run will be visible in GitHub UI const check = await github.rest.checks.create({ owner: context.repo.owner, @@ -69,7 +69,7 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, workflow_id: 'extended.yml', - ref: branchName, + ref: 'main', inputs: { pr_number: context.payload.issue.number.toString(), check_run_id: check.data.id.toString(), @@ -77,7 +77,7 @@ jobs: } }); - - name: Add reaction to comment + - name: Add reaction to comment uses: actions/github-script@v7 with: script: | @@ -86,4 +86,4 @@ jobs: repo: context.repo.repo, comment_id: context.payload.comment.id, content: 'rocket' - }); \ No newline at end of file + });