feat(workflow run): retrieve workflow dispatch run details#12695
feat(workflow run): retrieve workflow dispatch run details#12695babakks merged 12 commits intotrunkcli/cli:trunkfrom babakks/retrieve-workflow-dispatch-run-idcli/cli:babakks/retrieve-workflow-dispatch-run-idCopy head branch name to clipboard
Conversation
…tch features Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
There was a problem hiding this comment.
Pull request overview
Adds feature detection and conditional behavior to gh workflow run so it can request and output workflow dispatch run details (URL/ID) on hosts that support it, while remaining compatible with older GHES versions that still return 204 No Content.
Changes:
- Introduces
ActionsFeaturesfeature detection to determine support forreturn_run_detailson workflow dispatches. - Updates
workflow runto includereturn_run_details: truewhen supported and to handle200responses with run details (printing URL/ID appropriately). - Expands/adjusts tests to cover both legacy (
204) and new (200 + body) dispatch behaviors.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/workflow/run/run.go | Adds detector plumbing, conditionally requests run details, and prints run URL/ID when returned. |
| pkg/cmd/workflow/run/run_test.go | Adds stub variants and test cases for both 204 and 200 dispatch responses; updates expected output. |
| internal/featuredetection/feature_detection.go | Adds ActionsFeatures and enterprise version gating for dispatch run details support. |
| internal/featuredetection/feature_detection_test.go | Adds unit tests for ActionsFeatures across github.com, ghe.com, and GHES versions. |
| internal/featuredetection/detector_mock.go | Extends detector mocks to implement ActionsFeatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…nges Signed-off-by: Babak K. Shandiz <babakks@github.com>
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
| return ActionsFeatures{}, err | ||
| } | ||
|
|
||
| hostVersion, err := resolveEnterpriseVersion(d.httpClient, d.host) |
There was a problem hiding this comment.
Food For Thought
Out of scope for this but it feels like something we should be caching for a reasonable amount of time.
There was a problem hiding this comment.
The HTTP client comes from the caller (e.g. the command) and we usually make them 24h-cached.
There was a problem hiding this comment.
Oh, right, yeah I forgot about all these things everywhere:
cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
I wonder if this should just be baked into the feature detector. It's also idempotent.
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…pefully) upgrade with cli/cli#12695
Fixes #12672
This PR adds a new feature detection method,
ActionsFeaturesthat checks the API server's support for returning dispatched workflow run details.Since it's a temporary situation, I've added
// TODO workflowDispatchRunDetailsCleanupmarkers. They indicate the places (including test cases) that we should remove once the workflow run details are retrievable from supported host versions.Also, those test cases that has nothing to do with the feature detection phase (e.g. checking for wrong inputs), are now set up with an enabled mock since that would be the default/common scenario, and this way we don't need to change them during the future cleanup.
Verification
In the screenshot, the first invocation is non-interactive and the second is interactive.
1. With run details on
github.comThis will soon be the default behaviour for all
github.comrepos:Before this,
ghwould only exit with zero (see below images), but now we print out the created workflow run URL. This is backward compatible (since users would only rely on the exit code as that was the only indicator), and consistent withpr createorissue createexperience.2. Without run details on
github.comThis is what users see if they run the updated
gh workflow runnow (i.e. the new API changes not published), and it's how the experience originally was.In this case, although the
return_run_detailsfield is set in the request (because the host isgithub.com), but the API server has ignored it and didn't return the run details. Here,ghworks fine because regardless of the request fields, it'll still able to handle bot200or204responses.3. Without run details on GHES
v3.19(i.e. <=v3.20)This is what GHES users see, as GHES does not support the new API changes. This is unchanged, too.
In this case, due feature detection results,
ghdon't even set thereturn_run_detailsfield.