feat(run): show runs like gh, watch them live, and download artifacts

run list prints a table with a status icon, the workflow name, title,
branch, event, elapsed time and age, and the total from the server; runs
carry workflow, workflow_path and run_number in JSON. run view shows the
run's state and trigger, its jobs with their steps and durations, the
next steps and the run's URL; --json includes the jobs, --log prints
their logs and --web opens the run.

Run commands accept #N and run URLs, and ask for a recent run in a
terminal when the argument is left out. run watch redraws the run on the
alternate screen, then prints it with a summary; an expired --timeout
names the run and suspects a missing runner when no job started.

run cancel no longer asks for confirmation, rerun refuses unfinished runs
up front, reruns a single job with --job and reports the new attempt,
and delete names the run in its prompt. run logs follows several jobs
with --follow, prefixing lines with the job's name, selects jobs by name
or with --failed, and downloads the archive with --output or --dir.
run download extracts the artifacts of a run by name, and artifact list
shows sizes and expiry.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-11 23:46:26 +02:00
1 parent b09c1aab4a
commit 9f69a89537
19 files changed
+2636 -646

No files matched your search

+32 -1
View File
@@ -53,7 +53,7 @@ func TestRunLogsStreamWithoutMixingDiagnosticsAndVerifyJobMembership(t *testing.
diagnostics.Reset()
args[5] = "--job=10"
err := Execute(context.Background(), deps, args)
require.ErrorContains(t, err, "does not belong")
require.EqualError(t, err, "job 10 not found in run 7")
require.Equal(t, 1, downloads)
require.Empty(t, out.String())
path := filepath.Join(t.TempDir(), "logs.zip")
@@ -121,3 +121,34 @@ func TestRunLogsContinuePastJobsThatHaveNotStarted(t *testing.T) {
require.Equal(t, "test output\n", out.String())
require.Equal(t, "lint (job 8): never started (skipped)\nbuild (job 9): not started yet\ntest (job 10)\ndeploy (job 11): not started yet\n", diagnostics.String())
}
func TestRunLogsSelectJobsAndFollowSeveral(t *testing.T) {
server, _ := actionsAPI(t, map[string]string{
"GET actions/runs/29/jobs": failedJobsFixture,
"GET actions/jobs/30/logs": "compiled\nlinked",
"GET actions/jobs/31/logs": "boom\n",
})
for _, tc := range []struct {
name string
args []string
out, progress string
err string
}{
{"failed jobs", []string{"--failed"}, "boom\n", "test (job 31)\n", ""},
{"a job by name", []string{"--job", "Build"}, "compiled\nlinked", "build (job 30)\n", ""},
{"follow several jobs", []string{"--follow", "--interval=1ms"}, "build\tcompiled\nbuild\tlinked\ntest\tboom\n", "build (job 30)\ntest (job 31)\n", ""},
{"unknown job", []string{"--job", "deploy"}, "", "", `job "deploy" not found in run 29`},
} {
t.Run(tc.name, func(t *testing.T) {
deps, out, diagnostics := actionsDeps(t, server.URL, false)
err := Execute(context.Background(), deps, append([]string{"run", "logs", "29", "-R", "alice/project"}, tc.args...))
if tc.err != "" {
require.EqualError(t, err, tc.err)
} else {
require.NoError(t, err)
}
require.Equal(t, tc.out, out.String())
require.Equal(t, tc.progress, diagnostics.String())
})
}
}