Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

Give workflows and jobs a name and description

1cde8b9ea2ba1483beb90f19cde0f58aede2a661 · Keenan Nemetz · 8d ago · parent 30de4a44

Give workflows and jobs a name and description

The workflows page showed the file path and job IDs, so a reader had to
open the YAML comments to learn what a workflow was for. Add optional
top-level and job-level name and description fields, default them to the
file stem and job ID, pin them with a queued run, and show them on the
workflows and run pages.

Also document what the workflow format still cannot express, and state
that CI jobs are independent and unordered: only a local run uses the
declaration order.

Part of: #138

ci/runs/runs.go +45−8

@@ -67,8 +67,16 @@ type Run struct {
67 67 SHA string
68 68 Workflow string
69 69 WorkflowSHA string
70 Job string
71 Steps []Step
70 // WorkflowName, WorkflowDescription, JobName and JobDescription are the display
71 // metadata pinned when the run was queued. They are what the run page shows;
72 // Workflow and Job stay the stable keys. A workflow edited after enqueue cannot
73 // rewrite the name under a run that already happened.
74 WorkflowName string
75 WorkflowDescription string
76 JobName string
77 JobDescription string
78 Job string
79 Steps []Step
72 80 // StepsSHA is the digest of the pinned steps, recorded when the run is queued.
73 81 // It is what a runner's attestation covers, so "what ran" is the steps and not
74 82 // merely the workflow file they were read from.
@@ -125,10 +133,28 @@ type Run struct {
125 133
126 134 // runColumns is the column list scanRun reads, in order. HasLog is an EXISTS rather
127 135 // than a stored column so a list of runs stays one query as logs come and go.
128 const runColumns = `id, repo, ref, branch, sha, workflow, workflow_sha, job, steps, steps_sha,
136 const runColumns = `id, repo, ref, branch, sha, workflow, workflow_sha, workflow_name, workflow_description, job, job_name, job_description, steps, steps_sha,
129 137 artifacts, release_artifacts, pages_path, tag, tag_annotated, status, attempts, lease_owner, lease_until, created, started, finished, exit_code, os, arch, image, image_file, image_definition, image_sha, runtime, env,
130 138 EXISTS (SELECT 1 FROM run_logs WHERE run_logs.run_id = runs.id)`
131 139
140 // JobTitle is the job as a reader should see it: the declared display name, or the
141 // job ID for a run recorded before names were pinned.
142 func (r *Run) JobTitle() string {
143 if r.JobName != "" {
144 return r.JobName
145 }
146 return r.Job
147 }
148
149 // WorkflowTitle is the workflow as a reader should see it: the declared display
150 // name, or the workflow path for a run recorded before names were pinned.
151 func (r *Run) WorkflowTitle() string {
152 if r.WorkflowName != "" {
153 return r.WorkflowName
154 }
155 return r.Workflow
156 }
157
132 158 // Duration is the wall-clock time from the first lease to the finish. A queued run
133 159 // has no duration yet; a running one is measured to now so a page can show that it
134 160 // is still going rather than a stale zero.
@@ -196,7 +222,11 @@ CREATE TABLE IF NOT EXISTS runs (
196 222 sha TEXT NOT NULL,
197 223 workflow TEXT NOT NULL,
198 224 workflow_sha TEXT NOT NULL,
225 workflow_name TEXT NOT NULL DEFAULT '',
226 workflow_description TEXT NOT NULL DEFAULT '',
199 227 job TEXT NOT NULL,
228 job_name TEXT NOT NULL DEFAULT '',
229 job_description TEXT NOT NULL DEFAULT '',
200 230 steps TEXT NOT NULL,
201 231 status TEXT NOT NULL,
202 232 attempts INTEGER NOT NULL DEFAULT 0,
@@ -368,6 +398,10 @@ CREATE TABLE IF NOT EXISTS auto_merges (
368 398 `ALTER TABLE runs ADD COLUMN image_sha TEXT NOT NULL DEFAULT ''`,
369 399 `ALTER TABLE runs ADD COLUMN runtime TEXT NOT NULL DEFAULT ''`,
370 400 `ALTER TABLE runs ADD COLUMN env TEXT NOT NULL DEFAULT '{}'`,
401 `ALTER TABLE runs ADD COLUMN workflow_name TEXT NOT NULL DEFAULT ''`,
402 `ALTER TABLE runs ADD COLUMN workflow_description TEXT NOT NULL DEFAULT ''`,
403 `ALTER TABLE runs ADD COLUMN job_name TEXT NOT NULL DEFAULT ''`,
404 `ALTER TABLE runs ADD COLUMN job_description TEXT NOT NULL DEFAULT ''`,
371 405 `ALTER TABLE runner_sessions ADD COLUMN labels TEXT NOT NULL DEFAULT '[]'`,
372 406 `ALTER TABLE run_attestations ADD COLUMN commit_id TEXT NOT NULL DEFAULT ''`,
373 407 } {
@@ -462,12 +496,14 @@ func (s *Store) Enqueue(r Run, labels []string) (bool, error) {
462 496 }
463 497 defer tx.Rollback()
464 498 res, err := tx.Exec(`INSERT OR IGNORE INTO runs
465 (id, repo, ref, branch, tag, tag_annotated, sha, workflow, workflow_sha, job, steps, steps_sha,
466 image, image_file, image_definition, image_sha,
499 (id, repo, ref, branch, tag, tag_annotated, sha, workflow, workflow_sha,
500 workflow_name, workflow_description, job, job_name, job_description,
501 steps, steps_sha, image, image_file, image_definition, image_sha,
467 502 artifacts, release_artifacts, pages_path, env, status, created)
468 VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
503 VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
469 504 r.ID, r.Repo, r.Ref, r.Branch, r.Tag, boolInt(r.TagAnnotated), r.SHA, r.Workflow,
470 r.WorkflowSHA, r.Job, string(steps), r.StepsSHA,
505 r.WorkflowSHA, r.WorkflowName, r.WorkflowDescription, r.Job, r.JobName, r.JobDescription,
506 string(steps), r.StepsSHA,
471 507 r.Image, r.ImageFile, r.ImageDefinition, r.ImageSHA,
472 508 string(arts), string(rel), r.PagesPath, string(env), r.Status, r.Created.Unix())
473 509 if err != nil {
@@ -1677,7 +1713,8 @@ func scanRun(row scannable) (*Run, error) {
1677 1713 var leaseUntil, created, started, finished int64
1678 1714 var env string
1679 1715 if err := row.Scan(&r.ID, &r.Repo, &r.Ref, &r.Branch, &r.SHA, &r.Workflow, &r.WorkflowSHA,
1680 &r.Job, &steps, &r.StepsSHA, &artifacts, &releaseArtifacts, &r.PagesPath, &r.Tag, &tagAnnotated,
1716 &r.WorkflowName, &r.WorkflowDescription, &r.Job, &r.JobName, &r.JobDescription,
1717 &steps, &r.StepsSHA, &artifacts, &releaseArtifacts, &r.PagesPath, &r.Tag, &tagAnnotated,
1681 1718 &r.Status, &r.Attempts, &r.LeaseOwner, &leaseUntil,
1682 1719 &created, &started, &finished, &r.ExitCode, &r.OS, &r.Arch,
1683 1720 &r.Image, &r.ImageFile, &r.ImageDefinition, &r.ImageSHA, &r.Runtime, &env, &r.HasLog); err != nil {