Simon Ser: 1 builds show: print job group status 5 files changed, 31 insertions(+), 9 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~emersion/hut-dev/patches/43729/mbox | git am -3Learn more about email & git
If a job is part of a group, print the IDs and statuses for other jobs in the same group as well. Requires a sr.ht patch [1] to work correctly. [1]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/43728 --- builds.go | 10 ++++++++++ srht/buildssrht/gql.go | 8 ++++---- srht/buildssrht/operations.graphql | 6 ++++++ srht/buildssrht/schema.graphqls | 12 +++++++----- srht/buildssrht/strings.go | 4 ++++ 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/builds.go b/builds.go index 687e211ca43d..f9ed33cac180 100644 --- a/builds.go @@ -615,6 +615,16 @@ func printJob(w io.Writer, job *buildssrht.Job) { } fmt.Fprintln(w) + if job.Group != nil && len(job.Group.Jobs) > 1 { + fmt.Fprintf(w, "Group: ") + for _, j := range job.Group.Jobs { + if j.Id == job.Id { + continue + } + fmt.Fprintf(w, "%s %s ", job.Status.TermIcon(), termfmt.DarkYellow.Sprintf("#%d", j.Id)) + } + } + if job.Note != nil && *job.Note != "" { fmt.Fprintln(w, "\n"+indent(strings.TrimSpace(*job.Note), " ")) } diff --git a/srht/buildssrht/gql.go b/srht/buildssrht/gql.go index b73cb5bc082e..5b71eb2cba37 100644 --- a/srht/buildssrht/gql.go +++ b/srht/buildssrht/gql.go @@ -1,4 +1,4 @@ -// Code generated by gqlclientgen - DO NOT EDIT +// Code generated by gqlclientgen - DO NOT EDIT.
Just a drive-by comment: You probably upgraded the go dependencies without committing.Hm. It turns out I was using a Go workspace for gqlclient. I'll make sure to disable that, and respin the patch once the upstream bug is fixed.
package buildssrht @@ -163,8 +163,8 @@ const ( type Log struct { // The most recently written 128 KiB of the build log. Last128KiB string `json:"last128KiB"` - // The URL at which the full build log can be downloaded with a GET request - // (text/plain). + // The URL at which the full build log can be downloaded with an authenticated + // GET request (text/plain). FullURL string `json:"fullURL"` } @@ -630,7 +630,7 @@ func ExportJobs(client *gqlclient.Client, ctx context.Context, cursor *Cursor) ( } func Show(client *gqlclient.Client, ctx context.Context, id int32) (job *Job, err error) { - op := gqlclient.NewOperation("query show ($id: Int!) {\n\tjob(id: $id) {\n\t\tid\n\t\trunner\n\t\tstatus\n\t\tnote\n\t\ttags\n\t\tlog {\n\t\t\tfullURL\n\t\t}\n\t\ttasks {\n\t\t\tname\n\t\t\tstatus\n\t\t\tlog {\n\t\t\t\tfullURL\n\t\t\t}\n\t\t}\n\t}\n}\n") + op := gqlclient.NewOperation("query show ($id: Int!) {\n\tjob(id: $id) {\n\t\tid\n\t\trunner\n\t\tstatus\n\t\tnote\n\t\ttags\n\t\tlog {\n\t\t\tfullURL\n\t\t}\n\t\ttasks {\n\t\t\tname\n\t\t\tstatus\n\t\t\tlog {\n\t\t\t\tfullURL\n\t\t\t}\n\t\t}\n\t\tgroup {\n\t\t\tjobs {\n\t\t\t\tid\n\t\t\t\tstatus\n\t\t\t}\n\t\t}\n\t}\n}\n") op.Var("id", id) var respData struct { Job *Job diff --git a/srht/buildssrht/operations.graphql b/srht/buildssrht/operations.graphql index 10f96b42b476..7f2ca340fe57 100644 --- a/srht/buildssrht/operations.graphql +++ b/srht/buildssrht/operations.graphql @@ -133,6 +133,12 @@ query show($id: Int!) { fullURL } } + group { + jobs { + id + status + } + } } } diff --git a/srht/buildssrht/schema.graphqls b/srht/buildssrht/schema.graphqls index a5b968da7c2e..b8c26411a0f0 100644 --- a/srht/buildssrht/schema.graphqls +++ b/srht/buildssrht/schema.graphqls @@ -144,8 +144,8 @@ type Log { "The most recently written 128 KiB of the build log." last128KiB: String! """ - The URL at which the full build log can be downloaded with a GET request - (text/plain). + The URL at which the full build log can be downloaded with an authenticated + GET request (text/plain). """ fullURL: String! } @@ -277,7 +277,7 @@ type OAuthClient { } enum WebhookEvent { - JOB_CREATED @access(scope: JOBS, kind: RO) + JOB_CREATED } interface WebhookSubscription { @@ -437,8 +437,10 @@ type Mutation { """ Submits a new job to the queue. - 'secrets' may be set to false to disable secrets for this build. Secrets - are enabled if unspecified. + 'secrets' may be set to false to disable secrets for this build. If + unspecified, secrets are enabled if at least one is specified in the manifest + and the SECRETS:RO grant is available. Enabling secrets requires the + SECRETS:RO grant. 'execute' may be set to false to defer queueing this job. Builds are executed immediately if unspecified. diff --git a/srht/buildssrht/strings.go b/srht/buildssrht/strings.go index 3100c7de6656..f10ede7df7f1 100644 --- a/srht/buildssrht/strings.go +++ b/srht/buildssrht/strings.go @@ -41,6 +41,10 @@ func (status JobStatus) TermStyle() termfmt.Style { } } +func (status JobStatus) TermIcon() string { + return status.TermStyle().String(status.Icon()) +} + func (status JobStatus) TermString() string { return status.TermStyle().Sprintf("%s %s", status.Icon(), string(status)) } -- 2.41.0