Skip to content

Commit 15f8113

Browse files
danila-bNirnay Roy
authored and
Nirnay Roy
committed
Triggering extended tests through PR comment: Run extended tests (apache#15101)
* Add custom trigger for extended tests * Add workflow dispatch * Try different templating for ref path * Add checkout * Use branch name directly * Add js action to fetch branch name * Post check on PR * Fix owner and repo name * Remove unused vars * Add permissions for check write * Add check updates * Add lighweight test * Uncomment needs * Add comments for new actions
1 parent 3e2fd15 commit 15f8113

File tree

2 files changed

+148
-1
lines changed

2 files changed

+148
-1
lines changed

.github/workflows/extended.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,26 @@ concurrency:
3030
# in the (very rare) event of a hash failure or sqlite library query failure.
3131
on:
3232
push:
33+
branches:
34+
- main
35+
workflow_dispatch:
36+
inputs:
37+
pr_number:
38+
description: 'Pull request number'
39+
type: string
40+
check_run_id:
41+
description: 'Check run ID for status updates'
42+
type: string
43+
pr_head_sha:
44+
description: 'PR head SHA'
45+
type: string
3346

47+
permissions:
48+
contents: read
49+
checks: write
50+
3451
jobs:
52+
3553
# Check crate compiles and base cargo check passes
3654
linux-build-lib:
3755
name: linux build test
@@ -57,7 +75,7 @@ jobs:
5775
# Run extended tests (with feature 'extended_tests')
5876
linux-test-extended:
5977
name: cargo test 'extended_tests' (amd64)
60-
needs: linux-build-lib
78+
needs: [linux-build-lib]
6179
runs-on: ubuntu-latest
6280
# note: do not use amd/rust container to preserve disk space
6381
steps:
@@ -127,4 +145,44 @@ jobs:
127145
cargo test --features backtrace --profile release-nonlto --test sqllogictests -- --include-sqlite
128146
cargo clean
129147
148+
# If the workflow was triggered by the PR comment (through pr_comment_commands.yml action) we need to manually update check status to display in UI
149+
update-check-status:
150+
needs: [linux-build-lib, linux-test-extended, hash-collisions, sqllogictest-sqlite]
151+
runs-on: ubuntu-latest
152+
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
153+
steps:
154+
- name: Determine workflow status
155+
id: status
156+
run: |
157+
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
158+
echo "workflow_status=failure" >> $GITHUB_OUTPUT
159+
echo "conclusion=failure" >> $GITHUB_OUTPUT
160+
else
161+
echo "workflow_status=completed" >> $GITHUB_OUTPUT
162+
echo "conclusion=success" >> $GITHUB_OUTPUT
163+
fi
164+
165+
- name: Update check run
166+
uses: actions/github-script@v7
167+
with:
168+
github-token: ${{ secrets.GITHUB_TOKEN }}
169+
script: |
170+
const workflowRunUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
171+
172+
await github.rest.checks.update({
173+
owner: context.repo.owner,
174+
repo: context.repo.repo,
175+
check_run_id: ${{ github.event.inputs.check_run_id }},
176+
status: 'completed',
177+
conclusion: '${{ steps.status.outputs.conclusion }}',
178+
output: {
179+
title: '${{ steps.status.outputs.conclusion == 'success' && 'Extended Tests Passed' || 'Extended Tests Failed' }}',
180+
summary: `Extended tests have completed with status: ${{ steps.status.outputs.conclusion }}.\n\n[View workflow run](${workflowRunUrl})`
181+
},
182+
details_url: workflowRunUrl
183+
});
184+
185+
186+
187+
130188
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: PR commands
19+
20+
on:
21+
issue_comment:
22+
types: [created]
23+
24+
permissions:
25+
contents: read
26+
pull-requests: write
27+
actions: write
28+
checks: write
29+
30+
jobs:
31+
# Starts the extended_tests on a PR branch when someone leaves a `Run extended tests` comment
32+
run_extended_tests:
33+
runs-on: ubuntu-latest
34+
if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, 'Run extended tests') }}
35+
steps:
36+
- name: Dispatch extended tests for a PR branch with comment
37+
uses: actions/github-script@v7
38+
with:
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
script: |
41+
// Get PR details to fetch the branch name
42+
const { data: pullRequest } = await github.rest.pulls.get({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
pull_number: context.payload.issue.number
46+
});
47+
48+
// Extract the branch name
49+
const branchName = pullRequest.head.ref;
50+
const headSha = pullRequest.head.sha;
51+
const workflowRunsUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions?query=workflow%3A%22Datafusion+extended+tests%22+branch%3A${branchName}`;
52+
53+
// Create a check run that links to the Actions tab so the run will be visible in GitHub UI
54+
const check = await github.rest.checks.create({
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
name: 'Extended Tests',
58+
head_sha: headSha,
59+
status: 'in_progress',
60+
output: {
61+
title: 'Extended Tests Running',
62+
summary: `Extended tests have been triggered for this PR.\n\n[View workflow runs](${workflowRunsUrl})`
63+
},
64+
details_url: workflowRunsUrl
65+
});
66+
67+
// Dispatch the workflow with the PR branch name
68+
await github.rest.actions.createWorkflowDispatch({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
workflow_id: 'extended.yml',
72+
ref: branchName,
73+
inputs: {
74+
pr_number: context.payload.issue.number.toString(),
75+
check_run_id: check.data.id.toString(),
76+
pr_head_sha: headSha
77+
}
78+
});
79+
80+
- name: Add reaction to comment
81+
uses: actions/github-script@v7
82+
with:
83+
script: |
84+
await github.rest.reactions.createForIssueComment({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
comment_id: context.payload.comment.id,
88+
content: 'rocket'
89+
});

0 commit comments

Comments
 (0)