feat: add Check Runs query type - #802
Open
pkucia wants to merge 4 commits into
Open
Conversation
Adds support for listing GitHub check runs for a git reference via
GET /repos/{owner}/{repo}/commits/{ref}/check-runs.
The query is ref-scoped and supports optional filtering by check name,
status and the GitHub 'filter' parameter (latest/all). Results are
paginated and flattened into a check_runs data frame, including a
derived duration_seconds field for CI latency dashboards.
Adds the Check_Runs query type to the query editor with inputs for the git ref, an optional check name, and comboboxes for status and the latest/all filter.
Adds the Check Runs query type to the query editor documentation and a changeset entry for the release notes.
Adds tests that exercise the real go-github client against a mock GitHub server to confirm the request path, query parameters, and response parsing for the check runs endpoint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
Check Runsquery type that lists the check runs reported against a git reference, backed byGET /repos/{owner}/{repo}/commits/{ref}/check-runs.Check runs are the individual checks that GitHub Apps report against a commit: GitHub Actions jobs, external CI,
linters. There is currently no way to see them in Grafana.
Workflow Runscovers GitHub Actions at the workflowlevel, but not the per-check results that show up on a commit or PR, and not checks reported by other apps.
This makes it possible to build CI health dashboards per commit or branch, such as pass/fail rates by check name and
check latency over time.
Options are Owner, Repository and Ref (required), plus optional Check name, Status and Filter. Filtering is delegated
to the GitHub API rather than done client side, and empty options are omitted from the request so GitHub's own
defaults apply. Full option and response documentation is in
docs/sources/query-editor.md.May partially help #326, since check runs map roughly to jobs and the frame includes a duration per check run.
Implementation
Backend (Go):
pkg/models/checkruns.go—CheckRunsOptions, with the usualWithRepovariantpkg/github/checkruns.go— paginated fetch and frame construction, followingCode Scanningfor the clientpattern and
Commit Filesfor the ref scoped shapepkg/github/checkruns_handler.go,datasource.go,query_handler.go— handler wired into the query muxpkg/github/client/client.go—ListCheckRunsForRefadded to the REST client and theClientinterfaceUses
Checks.ListCheckRunsForReffromgo-github, which is already a direct dependency, so there are no newdependencies.
Frontend (TypeScript/React):
src/views/QueryEditorCheckRuns.tsx— editor for ref, check name, status and filtersrc/types/query.ts,src/constants.ts,src/validation.ts—CheckRunsOptionstype and registrationDocs:
docs/sources/query-editor.md— list entry plus a### Check runsreference sectionOne thing worth flagging: I did not register this in
schema.go. The other ref scoped query types (Commit Files,Pull Request Files,Branches) are not registered either, since there is no table parameter for a free text gitref, so I followed that precedent. Happy to add it if you would prefer.
completed_atandduration_secondsare nullable so that in flight check runs are represented honestly rather thanwith zero values.
duration_secondsis derived rather than a raw API field; I can drop it if you would rather keepthe frame a straight mirror of the API.
The editor uses
Comboboxrather than the deprecatedSelect, in line with #324.Test plan
go test ./...yarn test:ci,yarn typecheck,yarn lint,yarn spellcheck,yarn buildfile for the
check_runsframego-githubclient against a mock server, asserting request path, queryparameters and response parsing
SHA refs,
heads/<branch>refs, and the check name, status and filter optionsCheck Suites and the legacy Combined Status endpoint are deliberately out of scope to keep this reviewable. Happy to
follow up with those separately if there is interest.