|
|
|
@@ -139,6 +139,7 @@ func TestActionViewsView(t *testing.T) {
|
|
|
|
|
runIndex int64
|
|
|
|
|
jobIndex int64
|
|
|
|
|
attempt int64
|
|
|
|
|
workflowSourceURL string
|
|
|
|
|
expectedJSON string
|
|
|
|
|
expectedArtifacts string
|
|
|
|
|
}{
|
|
|
|
@@ -148,6 +149,7 @@ func TestActionViewsView(t *testing.T) {
|
|
|
|
|
runIndex: 187,
|
|
|
|
|
jobIndex: 0,
|
|
|
|
|
attempt: 3,
|
|
|
|
|
workflowSourceURL: "/user5/repo4/src/commit/c2d72f548424103f01ee1dc02889c1e2bff816b0/.forgejo/workflows/artifact.yaml",
|
|
|
|
|
expectedJSON: "{\"state\":{\"run\":{\"preExecutionError\":\"\",\"link\":\"/user5/repo4/actions/runs/187\",\"title\":\"update actions\",\"titleHTML\":\"update actions\",\"status\":\"success\",\"canCancel\":false,\"canDelete\":false,\"canApprove\":false,\"canRerun\":false,\"canDeleteArtifact\":false,\"description\":\"Commit <a href=\\\"/user5/repo4/commit/c2d72f548424103f01ee1dc02889c1e2bff816b0\\\">c2d72f5484</a> pushed by <a href=\\\"/user1\\\">user1</a>\",\"done\":true,\"jobs\":[{\"id\":192,\"name\":\"job_2\",\"status\":\"success\",\"canRerun\":false,\"duration\":\"_duration_\"}],\"commit\":{\"localeWorkflow\":\"Workflow\",\"localeAllRuns\":\"all runs\",\"shortSHA\":\"c2d72f5484\",\"link\":\"/user5/repo4/commit/c2d72f548424103f01ee1dc02889c1e2bff816b0\",\"pusher\":{\"displayName\":\"user1\",\"link\":\"/user1\"},\"branch\":{\"name\":\"master\",\"link\":\"/user5/repo4/src/branch/master\",\"isDeleted\":false}}},\"currentJob\":{\"title\":\"job_2\",\"details\":[\"Success\"],\"steps\":[{\"summary\":\"Set up job\",\"duration\":\"_duration_\",\"status\":\"running\"},{\"summary\":\"Complete job\",\"duration\":\"_duration_\",\"status\":\"waiting\"}],\"allAttempts\":[{\"number\":3,\"time_since_started_html\":\"_time_\",\"status\":\"running\",\"status_diagnostics\":[\"Running\"]},{\"number\":2,\"time_since_started_html\":\"_time_\",\"status\":\"success\",\"status_diagnostics\":[\"Success\"]},{\"number\":1,\"time_since_started_html\":\"_time_\",\"status\":\"success\",\"status_diagnostics\":[\"Success\"]}]}},\"logs\":{\"stepsLog\":[]}}\n",
|
|
|
|
|
expectedArtifacts: "{\"artifacts\":[{\"name\":\"multi-file-download\",\"size\":2048,\"status\":\"completed\"}]}\n",
|
|
|
|
|
},
|
|
|
|
@@ -157,6 +159,7 @@ func TestActionViewsView(t *testing.T) {
|
|
|
|
|
runIndex: 209,
|
|
|
|
|
jobIndex: 0,
|
|
|
|
|
attempt: 1,
|
|
|
|
|
workflowSourceURL: "/user5/repo4/src/commit/64357baca84bfff631e7dfae5a3433b26d005646/.forgejo/workflows/scheduled.yaml",
|
|
|
|
|
expectedJSON: "{\"state\":{\"run\":{\"link\":\"/user5/repo4/actions/runs/209\",\"title\":\"A scheduled workflow\",\"titleHTML\":\"A scheduled workflow\",\"status\":\"waiting\",\"description\":\"Scheduled run of commit \\u003ca href=\\\"/user5/repo4/commit/64357baca84bfff631e7dfae5a3433b26d005646\\\"\\u003e64357baca8\\u003c/a\\u003e\",\"canCancel\":false,\"canDelete\":false,\"canApprove\":false,\"canRerun\":false,\"canDeleteArtifact\":false,\"done\":false,\"jobs\":[{\"id\":2153,\"name\":\"job_2\",\"status\":\"waiting\",\"canRerun\":false,\"duration\":\"_duration_\"}],\"commit\":{\"localeWorkflow\":\"Workflow\",\"localeAllRuns\":\"all runs\",\"shortSHA\":\"64357baca8\",\"link\":\"/user5/repo4/commit/64357baca84bfff631e7dfae5a3433b26d005646\",\"pusher\":{\"displayName\":\"forgejo-actions\",\"link\":\"/forgejo-actions\"},\"branch\":{\"name\":\"master\",\"link\":\"/user5/repo4/src/branch/master\",\"isDeleted\":false}},\"preExecutionError\":\"\"},\"currentJob\":{\"title\":\"job_2\",\"details\":[\"Waiting for a runner with the following labels: debian, gpu\"],\"steps\":[{\"summary\":\"Set up job\",\"duration\":\"_duration_\",\"status\":\"success\"},{\"summary\":\"Complete job\",\"duration\":\"_duration_\",\"status\":\"success\"}],\"allAttempts\":[{\"number\":1,\"time_since_started_html\":\"-\",\"status\":\"success\",\"status_diagnostics\":[\"Success\"]}]}},\"logs\":{\"stepsLog\":[]}}\n",
|
|
|
|
|
expectedArtifacts: "{\"artifacts\":[]}\n",
|
|
|
|
|
},
|
|
|
|
@@ -166,9 +169,20 @@ func TestActionViewsView(t *testing.T) {
|
|
|
|
|
runIndex: 210,
|
|
|
|
|
jobIndex: 0,
|
|
|
|
|
attempt: 1,
|
|
|
|
|
workflowSourceURL: "/user5/repo4/src/commit/f4100ac14112a3740490afb22b07b69b0b5d4e8b/.forgejo/workflows/dispatch.yaml",
|
|
|
|
|
expectedJSON: "{\"state\":{\"run\":{\"link\":\"/user5/repo4/actions/runs/210\",\"title\":\"A triggered run\",\"titleHTML\":\"A triggered run\",\"status\":\"waiting\",\"description\":\"Run of commit \\u003ca href=\\\"/user5/repo4/commit/f4100ac14112a3740490afb22b07b69b0b5d4e8b\\\"\\u003ef4100ac141\\u003c/a\\u003e triggered by \\u003ca href=\\\"/user29\\\"\\u003euser29\\u003c/a\\u003e\",\"canCancel\":false,\"canDelete\":false,\"canApprove\":false,\"canRerun\":false,\"canDeleteArtifact\":false,\"done\":false,\"jobs\":[{\"id\":2154,\"name\":\"mirror\",\"status\":\"waiting\",\"canRerun\":false,\"duration\":\"_duration_\"}],\"commit\":{\"localeWorkflow\":\"Workflow\",\"localeAllRuns\":\"all runs\",\"shortSHA\":\"f4100ac141\",\"link\":\"/user5/repo4/commit/f4100ac14112a3740490afb22b07b69b0b5d4e8b\",\"pusher\":{\"displayName\":\"user29\",\"link\":\"/user29\"},\"branch\":{\"name\":\"master\",\"link\":\"/user5/repo4/src/branch/master\",\"isDeleted\":false}},\"preExecutionError\":\"\"},\"currentJob\":{\"title\":\"mirror\",\"details\":[\"Waiting for a runner with the following label: windows\"],\"steps\":[{\"summary\":\"Set up job\",\"duration\":\"_duration_\",\"status\":\"running\"},{\"summary\":\"Complete job\",\"duration\":\"_duration_\",\"status\":\"waiting\"}],\"allAttempts\":[{\"number\":1,\"time_since_started_html\":\"-\",\"status\":\"waiting\",\"status_diagnostics\":[\"Waiting for a runner with the following label: windows\"]}]}},\"logs\":{\"stepsLog\":[]}}\n",
|
|
|
|
|
expectedArtifacts: "{\"artifacts\":[]}\n",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "pull_request_target",
|
|
|
|
|
url: "/user5/repo4/actions/runs/211",
|
|
|
|
|
runIndex: 211,
|
|
|
|
|
jobIndex: 0,
|
|
|
|
|
attempt: 1,
|
|
|
|
|
workflowSourceURL: "/user5/repo4/src/commit/deadbeef/.forgejo/workflows/pull_request_target.yaml",
|
|
|
|
|
expectedJSON: "{\"state\":{\"run\":{\"link\":\"/user5/repo4/actions/runs/211\",\"title\":\"A pull_request_target run\",\"titleHTML\":\"A pull_request_target run\",\"status\":\"waiting\",\"description\":\"Commit \\u003ca href=\\\"/user5/repo4/commit/f4100ac14112a3740490afb22b07b69b0b5d4e8b\\\"\\u003ef4100ac141\\u003c/a\\u003e pushed by \\u003ca href=\\\"/user29\\\"\\u003euser29\\u003c/a\\u003e\",\"canCancel\":false,\"canApprove\":false,\"canRerun\":false,\"canDeleteArtifact\":false,\"canDelete\":false,\"done\":false,\"jobs\":[{\"id\":2155,\"name\":\"target_job\",\"status\":\"waiting\",\"canRerun\":false,\"duration\":\"_duration_\"}],\"commit\":{\"localeWorkflow\":\"Workflow\",\"localeAllRuns\":\"all runs\",\"shortSHA\":\"f4100ac141\",\"link\":\"/user5/repo4/commit/f4100ac14112a3740490afb22b07b69b0b5d4e8b\",\"pusher\":{\"displayName\":\"user29\",\"link\":\"/user29\"},\"branch\":{\"name\":\"master\",\"link\":\"/user5/repo4/src/branch/master\",\"isDeleted\":false}},\"preExecutionError\":\"\"},\"currentJob\":{\"title\":\"target_job\",\"details\":[\"Waiting for a runner with the following label: macos\"],\"steps\":[{\"summary\":\"Set up job\",\"duration\":\"_duration_\",\"status\":\"running\"},{\"summary\":\"Complete job\",\"duration\":\"_duration_\",\"status\":\"waiting\"}],\"allAttempts\":[{\"number\":1,\"time_since_started_html\":\"-\",\"status\":\"waiting\",\"status_diagnostics\":[\"Waiting for a runner with the following label: macos\"]}]}},\"logs\":{\"stepsLog\":[]}}\n",
|
|
|
|
|
expectedArtifacts: "{\"artifacts\":[]}\n",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, testCase := range testCases {
|
|
|
|
@@ -186,6 +200,7 @@ func TestActionViewsView(t *testing.T) {
|
|
|
|
|
htmlDoc.AssertAttrEqual(t, selector, "data-run-index", strconv.FormatInt(testCase.runIndex, 10))
|
|
|
|
|
htmlDoc.AssertAttrEqual(t, selector, "data-job-index", strconv.FormatInt(testCase.jobIndex, 10))
|
|
|
|
|
htmlDoc.AssertAttrEqual(t, selector, "data-attempt-number", strconv.FormatInt(testCase.attempt, 10))
|
|
|
|
|
htmlDoc.AssertAttrEqual(t, selector, "data-workflow-source-url", testCase.workflowSourceURL)
|
|
|
|
|
htmlDoc.AssertAttrPredicate(t, selector, "data-initial-post-response", func(actual string) {
|
|
|
|
|
// Remove dynamic "duration" fields for comparison.
|
|
|
|
|
pattern := `"duration":"[^"]*"`
|
|
|
|
|