Skip to content

Commit

Permalink
Add check updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danila-b committed Mar 8, 2025
1 parent 7eec64e commit 5525ac8
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 12 deletions.
57 changes: 56 additions & 1 deletion .github/workflows/extended.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,23 @@ on:
branches:
- main
workflow_dispatch:

inputs:
pr_number:
description: 'Pull request number'
required: false
type: string
check_run_id:
description: 'Check run ID for status updates'
required: false
type: string
pr_head_sha:
description: 'PR head SHA'
required: false
type: string

permissions:
contents: read
checks: write

jobs:

Expand Down Expand Up @@ -132,5 +148,44 @@ jobs:
cargo test --profile release-nonlto --test sqllogictests -- --include-sqlite
cargo clean
# If the workflow was triggered by the PR comment we need to manually update check status to display in UI
update-check-status:
needs: [linux-build-lib, linux-test-extended, hash-collisions, sqllogictest-sqlite]
runs-on: ubuntu-latest
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
steps:
- name: Determine workflow status
id: status
run: |
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "workflow_status=failure" >> $GITHUB_OUTPUT
echo "conclusion=failure" >> $GITHUB_OUTPUT
else
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,
check_run_id: ${{ github.event.inputs.check_run_id }},
status: 'completed',
conclusion: '${{ steps.status.outputs.conclusion }}',
output: {
title: '${{ steps.status.outputs.conclusion == 'success' && 'Extended Tests Passed' || 'Extended Tests Failed' }}',
summary: `Extended tests have completed with status: ${{ steps.status.outputs.conclusion }}.\n\n[View workflow run](${workflowRunUrl})`
},
details_url: workflowRunUrl
});
26 changes: 15 additions & 11 deletions .github/workflows/pr_comment_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,11 @@ jobs:
// Extract the branch name
const branchName = pullRequest.head.ref;
// Dispatch the workflow with the PR branch name
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'extended.yml',
ref: branchName,
});
// Create a check run that links to the Actions tab so the run will be visible in GitHub UI
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}`;
await github.rest.checks.create({
// 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,
repo: context.repo.repo,
name: 'Extended Tests',
Expand All @@ -73,6 +64,19 @@ jobs:
details_url: workflowRunsUrl
});
// Dispatch the workflow with the PR branch name
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'extended.yml',
ref: branchName,
inputs: {
pr_number: context.payload.issue.number.toString(),
check_run_id: check.data.id.toString(),
pr_head_sha: headSha
}
});
- name: Add reaction to comment
uses: actions/github-script@v7
with:
Expand Down

0 comments on commit 5525ac8

Please sign in to comment.