Skip to content

Show GitHub Actions results and refresh the CI status by webhook - #1465

Open
Hackwar wants to merge 1 commit into
joomla:masterfrom
Hackwar:feature/ci-status-webhook
Open

Hackwar wants to merge 1 commit into
joomla:masterfrom
Hackwar:feature/ci-status-webhook

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 11, 2026

Copy link
Copy Markdown
Member

Summary of Changes

The "GitHub merge status" of a pull request (the badge in the issue list and the status list on the item page) had two problems:

  1. GitHub Actions results never appeared. GitHubHelper::getCombinedStatus() only read the combined commit status (/commits/{ref}/status), the API that Travis and other external CI services use. GitHub Actions and other GitHub Apps report their results as check runs, which that endpoint doesn't include. For a repository that only uses GitHub Actions, GitHub reports the combined commit status as "pending" forever.
  2. The status was not refreshed when CI finished. It was only updated by pull_request webhooks (opened, synchronize, …) and by the CLI sync, so the status shown was the one from the moment the PR was last pushed.

Changes:

  • Statuses::getCheckRuns(): lists the check runs of a ref (latest run per name, up to 100).
  • GitHubHelper::getCombinedStatus(): adds every check run as a status (name as context, job URL as link, output title or conclusion as description) and computes the state from all statuses the way GitHub combines commit statuses: failure if any failed (failure, cancelled, timed out, action required, error), else pending if any is still queued or running, else success. Without check runs the combined commit status is used unchanged; if the checks API answers with an error, the commit statuses are shown as before.
  • New webhook hooks/status (ReceiveStatusHook) for the status and check_run events (actions created and completed). It finds the open pull requests of the project whose pr_head_sha is the reported commit, fetches the combined status again and stores merge_state and gh_merge_status. Payloads for other commits cost one indexed query and no GitHub request.
  • Migration 20261111001: index on #__issues (project_id, pr_head_sha) for that lookup, because check_run events arrive for every CI job.
  • The events help on the GitHub hooks page lists check_run and names the URL.

Setup after deploying: add a webhook for the status and check_run events to each repository, pointing to https://issues.joomla.org/hooks/status (Settings → Webhooks on GitHub, or the tracker's hooks page). Existing pull requests get the new status with their next push, status event or get:project sync.

Fixes #722

Testing Instructions

  • New GitHubHelperCombinedStatusTest: commit statuses only (unchanged behaviour), check runs added as statuses, the combined state for 10 combinations of commit statuses and check runs, and an error of the checks API.
  • New ReceiveStatusHookTest: a completed check run and a status event update the open pull requests with that head commit; rerequested/requested-action check runs, payloads without a commit and invalid SHAs are ignored; an unknown commit doesn't call GitHub.
  • Manually: on a test tracker, add the webhook above to a repository with GitHub Actions, open a pull request and watch the status on the item page change from pending to the result when the workflow finishes.
  • phpunit, PHPStan (as configured in CI) and php-cs-fixer pass.

Documentation Changes Required

The webhook setup above (new hooks/status URL for the status and check_run events).

🤖 Generated with Claude Code

The CI status of a pull request only contained commit statuses, the API Travis used. GitHub Actions report
their results as check runs, so they never appeared. getCombinedStatus() now also reads the check runs of
the commit, adds them as statuses and combines the state of both.

The status was also only refreshed when the pull request itself changed. The new hooks/status route receives
the "status" and "check_run" events and updates the CI status of the open pull requests whose head commit
changed. An index on project_id and pr_head_sha keeps that lookup cheap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Travis result issue

1 participant