feat: show workflow name for scheduled runs (#11770)

Previously, a scheduled run would appear like a run triggered by a push. That could be confusing, especially if a scheduled run was unrelated to that particular commit. Now, either the workflow's name (taken from the field `name:`) is displayed or the path to workflow file, matching the behaviour of `workflow_dispatch`.

As a side-effect, the description of all run types were improved. They are no longer pieced together from individual translations. `workflow_dispatch` also no longer misattributes commits to the user that triggered the workflow.

Resolves https://codeberg.org/forgejo/forgejo/issues/11688.

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests for Go changes

(can be removed for JavaScript changes)

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I ran...
  - [x] `make pr-go` before pushing

### Tests for JavaScript changes

(can be removed for Go changes)

- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change.
- [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change.

*The decision if the pull request will be shown in the release notes is up to the mergers / release team.*

The content of the `release-notes/<pull request number>.md` file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11770
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
Co-authored-by: Andreas Ahlenstorf <andreas@ahlenstorf.ch>
Co-committed-by: Andreas Ahlenstorf <andreas@ahlenstorf.ch>
This commit is contained in:
Andreas Ahlenstorf 2026-03-24 01:27:32 +01:00 committed by Mathieu Fenniak
parent 5b83cb5508
commit b01278e534
17 changed files with 407 additions and 52 deletions

View file

@ -104,6 +104,13 @@ func (run *ActionRun) Link() string {
return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.Index)
}
func (run *ActionRun) CommitLink() string {
if run.Repo == nil {
return ""
}
return fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA)
}
// WorkflowPath returns the path in the git repo to the workflow file that this run was based on
func (run *ActionRun) WorkflowPath() string {
if run.WorkflowDirectory == "" {
@ -240,6 +247,14 @@ func (run *ActionRun) FindOuterWorkflowCall(ctx context.Context, innerCall *Acti
return nil, fmt.Errorf("no workflow call with ID %s found in run %d", parent, run.ID)
}
func (run *ActionRun) IsScheduledRun() bool {
return run.TriggerEvent == "schedule"
}
func (run *ActionRun) IsDispatchedRun() bool {
return run.TriggerEvent == "workflow_dispatch"
}
func actionsCountOpenCacheKey(repoID int64) string {
return fmt.Sprintf("Actions:CountOpenActionRuns:%d", repoID)
}

View file

@ -11,6 +11,8 @@ import (
repo_model "forgejo.org/models/repo"
"forgejo.org/models/unittest"
"forgejo.org/modules/cache"
"forgejo.org/modules/setting"
"forgejo.org/modules/test"
"code.forgejo.org/forgejo/runner/v12/act/jobparser"
"github.com/stretchr/testify/assert"
@ -53,6 +55,47 @@ func TestGetWorkflowPath(t *testing.T) {
assert.Equal(t, ".some/path/to/workflows/ci.yml", run.WorkflowPath())
}
func TestGetCommitLink(t *testing.T) {
require.NoError(t, unittest.PrepareTestDatabase())
defer test.MockVariableValue(&setting.AppSubURL, "/sub")()
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
run := ActionRun{
Repo: repo,
CommitSHA: "a356d1f1f82945a039cd16d4ce0137bd55284e77",
}
assert.Equal(t, "/sub/user2/repo1/commit/a356d1f1f82945a039cd16d4ce0137bd55284e77", run.CommitLink())
}
func TestIsScheduledRun(t *testing.T) {
scheduledRun := ActionRun{
CommitSHA: "a356d1f1f82945a039cd16d4ce0137bd55284e77",
TriggerEvent: "schedule",
}
pushRun := ActionRun{
CommitSHA: "8f9b5c6ab342eb11d7422deecef7195b18058b90",
TriggerEvent: "push",
}
assert.True(t, scheduledRun.IsScheduledRun())
assert.False(t, pushRun.IsScheduledRun())
}
func TestIsManualRun(t *testing.T) {
manualRunRun := ActionRun{
CommitSHA: "a356d1f1f82945a039cd16d4ce0137bd55284e77",
TriggerEvent: "workflow_dispatch",
}
pushRun := ActionRun{
CommitSHA: "8f9b5c6ab342eb11d7422deecef7195b18058b90",
TriggerEvent: "push",
}
assert.True(t, manualRunRun.IsDispatchedRun())
assert.False(t, pushRun.IsDispatchedRun())
}
func TestRepoNumOpenActions(t *testing.T) {
require.NoError(t, unittest.PrepareTestDatabase())
err := cache.Init()

View file

@ -5,6 +5,7 @@ package actions
import (
"bytes"
"fmt"
"io"
"strings"
@ -30,6 +31,12 @@ type DetectedWorkflow struct {
NeedApproval actions_model.ApprovalType
}
// GetWorkflowPath returns the full path to the workflow from the repository root, for example,
// .forgejo/workflows/test.yaml.
func (wf *DetectedWorkflow) GetWorkflowPath() string {
return fmt.Sprintf("%s/%s", wf.EntryDirectory, wf.EntryName)
}
func init() {
model.OnDecodeNodeError = func(node yaml.Node, out any, err error) {
// Log the error instead of panic or fatal.

View file

@ -19,6 +19,14 @@ import (
"github.com/stretchr/testify/require"
)
func TestDetectedWorkflowGetWorkflowPath(t *testing.T) {
buildWorkflow := DetectedWorkflow{EntryDirectory: ".github/workflows", EntryName: "build.yaml"}
testWorkflow := DetectedWorkflow{EntryDirectory: ".forgejo/workflows", EntryName: "test.yaml"}
assert.Equal(t, ".github/workflows/build.yaml", buildWorkflow.GetWorkflowPath())
assert.Equal(t, ".forgejo/workflows/test.yaml", testWorkflow.GetWorkflowPath())
}
func TestActionsWorkflowsDetectMatched(t *testing.T) {
testCases := []struct {
desc string

View file

@ -513,9 +513,9 @@
"actions.runs.viewing_out_of_date_run": "You are viewing an out-of-date run of this job that was executed %[1]s.",
"actions.runs.view_most_recent_run": "View most recent run",
"actions.runs.all_workflows": "All workflows",
"actions.runs.commit": "Commit",
"actions.runs.scheduled": "Scheduled",
"actions.runs.pushed_by": "pushed by",
"actions.runs.scheduled_description": "Scheduled run of commit <a href=\"%[1]s\">%[2]s</a>",
"actions.runs.workflow_dispatch_description": "Run of commit <a href=\"%[1]s\">%[2]s</a> triggered by <a href=\"%[3]s\">%[4]s</a>",
"actions.runs.on_push_description": "Commit <a href=\"%[1]s\">%[2]s</a> pushed by <a href=\"%[3]s\">%[4]s</a>",
"actions.runs.workflow": "Workflow",
"actions.runs.invalid_workflow_helper": "Workflow config file is invalid. Please check your config file: %s",
"actions.runs.no_matching_online_runner.helper": "No matching online runner with label: %s",

View file

@ -173,6 +173,7 @@ type ViewRunInfo struct {
Title string `json:"title"`
TitleHTML template.HTML `json:"titleHTML"`
Status string `json:"status"`
Description string `json:"description"`
CanCancel bool `json:"canCancel"`
CanApprove bool `json:"canApprove"` // the run needs an approval and the doer has permission to approve
CanRerun bool `json:"canRerun"`
@ -203,8 +204,6 @@ type ViewJob struct {
}
type ViewCommit struct {
LocaleCommit string `json:"localeCommit"`
LocalePushedBy string `json:"localePushedBy"`
LocaleWorkflow string `json:"localeWorkflow"`
LocaleAllRuns string `json:"localeAllRuns"`
ShortSha string `json:"shortSHA"`
@ -281,6 +280,18 @@ func getViewResponse(ctx *app_context.Context, req *ViewRequest, runIndex, jobIn
metas := ctx.Repo.Repository.ComposeMetas(ctx)
var runDescription string
if run.IsScheduledRun() {
runDescription = ctx.Locale.TrString("actions.runs.scheduled_description", run.CommitLink(),
base.ShortSha(run.CommitSHA))
} else if run.IsDispatchedRun() {
runDescription = ctx.Locale.TrString("actions.runs.workflow_dispatch_description", run.CommitLink(),
base.ShortSha(run.CommitSHA), run.TriggerUser.HomeLink(), run.TriggerUser.GetDisplayName())
} else {
runDescription = ctx.Locale.TrString("actions.runs.on_push_description", run.CommitLink(),
base.ShortSha(run.CommitSHA), run.TriggerUser.HomeLink(), run.TriggerUser.GetDisplayName())
}
resp.State.Run.Title = run.Title
resp.State.Run.TitleHTML = templates.RenderCommitMessage(ctx, run.Title, metas)
resp.State.Run.Link = run.Link()
@ -290,6 +301,7 @@ func getViewResponse(ctx *app_context.Context, req *ViewRequest, runIndex, jobIn
resp.State.Run.Jobs = make([]*ViewJob, 0, len(jobs)) // marshal to '[]' instead of 'null' in json
resp.State.Run.Status = run.Status.String()
resp.State.Run.PreExecutionError = actions_model.TranslatePreExecutionError(ctx.Locale, run)
resp.State.Run.Description = runDescription
// It's possible for the run to be marked with a finalized status (eg. failure) because of a single job within the
// run; eg. one job fails, the run fails. But other jobs can still be running. The frontend RepoActionView uses the
@ -332,8 +344,6 @@ func getViewResponse(ctx *app_context.Context, req *ViewRequest, runIndex, jobIn
}
resp.State.Run.Commit = ViewCommit{
LocaleCommit: ctx.Locale.TrString("actions.runs.commit"),
LocalePushedBy: ctx.Locale.TrString("actions.runs.pushed_by"),
LocaleWorkflow: ctx.Locale.TrString("actions.runs.workflow"),
LocaleAllRuns: ctx.Locale.TrString("actions.runs.all_runs_link"),
ShortSha: base.ShortSha(run.CommitSHA),

View file

@ -150,6 +150,7 @@ func baseExpectedViewResponse() *ViewResponse {
Title: "update actions",
TitleHTML: template.HTML("update actions"),
Status: "success",
Description: "actions.runs.on_push_description",
CanCancel: false,
CanApprove: false,
CanRerun: false,
@ -165,8 +166,6 @@ func baseExpectedViewResponse() *ViewResponse {
},
},
Commit: ViewCommit{
LocaleCommit: "actions.runs.commit",
LocalePushedBy: "actions.runs.pushed_by",
LocaleWorkflow: "actions.runs.workflow",
LocaleAllRuns: "actions.runs.all_runs_link",
ShortSha: "c2d72f5484",

View file

@ -574,8 +574,13 @@ func handleSchedules(
continue
}
title := workflow.Name
if len(title) < 1 {
title = dwf.GetWorkflowPath()
}
run := &actions_model.ActionSchedule{
Title: strings.SplitN(commit.CommitMessage, "\n", 2)[0],
Title: title,
RepoID: input.Repo.ID,
OwnerID: input.Repo.OwnerID,
WorkflowID: dwf.EntryName,

View file

@ -16,14 +16,13 @@
</a>
<div class="flex-item-body">
<b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b> -
{{if .ScheduleID -}}
{{ctx.Locale.Tr "actions.runs.scheduled"}}
{{- else -}}
{{ctx.Locale.Tr "actions.runs.commit"}}
<a href="{{$.RepoLink}}/commit/{{.CommitSHA}}">{{ShortSha .CommitSHA}}</a>
{{ctx.Locale.Tr "actions.runs.pushed_by"}}
<a href="{{.TriggerUser.HomeLink}}">{{.TriggerUser.GetDisplayName}}</a>
{{- end -}}
{{if .IsScheduledRun -}}
{{ctx.Locale.Tr "actions.runs.scheduled_description" .CommitLink (ShortSha .CommitSHA)}}
{{else if .IsDispatchedRun -}}
{{ctx.Locale.Tr "actions.runs.workflow_dispatch_description" .CommitLink (ShortSha .CommitSHA) .TriggerUser.HomeLink .TriggerUser.GetDisplayName}}
{{else -}}
{{ctx.Locale.Tr "actions.runs.on_push_description" .CommitLink (ShortSha .CommitSHA) .TriggerUser.HomeLink .TriggerUser.GetDisplayName}}
{{end -}}
</div>
</div>
<div class="flex-item-trailing">

View file

@ -5,14 +5,17 @@ package integration
import (
"net/http"
"regexp"
"testing"
"forgejo.org/models/unittest"
"forgejo.org/tests"
"github.com/stretchr/testify/assert"
)
func TestActionRunsList(t *testing.T) {
defer unittest.OverrideFixtures("tests/integration/fixtures/TestActionRunsList")()
defer tests.PrepareTestEnv(t)()
req := NewRequest(t, "GET", "/user5/repo4/actions")
@ -20,7 +23,28 @@ func TestActionRunsList(t *testing.T) {
htmlDoc := NewHTMLParser(t, resp.Body)
runSubLine := htmlDoc.Find(".run-list .flex-item-body").Text()
assert.Contains(t, runSubLine, "Commit")
assert.NotContains(t, runSubLine, "-Commit")
runDescriptions := htmlDoc.Find(".run-list .flex-item-body")
allWhitespacePattern := regexp.MustCompile(`\s+`)
assert.Equal(t, 8, runDescriptions.Length())
assert.Contains(t, allWhitespacePattern.ReplaceAllString(runDescriptions.Eq(0).Text(), " "),
"dispatch.yaml #210 - Run of commit dc67f0a1a0 triggered by user29")
assert.Equal(t, "/user5/repo4/commit/dc67f0a1a0dc2417cd0b1a9f0b95e2e5d91876e9",
runDescriptions.Eq(0).Find("a").Eq(0).AttrOr("href", ""))
assert.Equal(t, "/user29",
runDescriptions.Eq(0).Find("a").Eq(1).AttrOr("href", ""))
assert.Contains(t, allWhitespacePattern.ReplaceAllString(runDescriptions.Eq(1).Text(), " "),
"scheduled.yaml #209 - Scheduled run of commit 64357baca8")
assert.Equal(t, "/user5/repo4/commit/64357baca84bfff631e7dfae5a3433b26d005646",
runDescriptions.Eq(1).Find("a").Eq(0).AttrOr("href", ""))
assert.Contains(t, allWhitespacePattern.ReplaceAllString(runDescriptions.Eq(2).Text(), " "),
"test.yaml #192 - Commit c2d72f5484 pushed by user1")
assert.Equal(t, "/user5/repo4/commit/c2d72f548424103f01ee1dc02889c1e2bff816b0",
runDescriptions.Eq(2).Find("a").Eq(0).AttrOr("href", ""))
assert.Equal(t, "/user1",
runDescriptions.Eq(2).Find("a").Eq(1).AttrOr("href", ""))
}

View file

@ -1134,3 +1134,83 @@ func TestActionsWorkflowDispatchConcurrencyGroup(t *testing.T) {
assert.Equal(t, actions_model.StatusCancelled, firstRunReload.Status)
})
}
func TestActionsScheduledWorkflow(t *testing.T) {
testCases := []struct {
name string
workflowID string
workflowDirectory string
workflowContent string
expectedWorkflowTitle string
expectedCronSpecs []string
}{
{
name: "GitHub",
workflowID: "scheduled.yml",
workflowDirectory: ".github/workflows",
workflowContent: `
on:
schedule:
- cron: "30 5,17 * * *"
jobs:
test:
steps:
- run: echo OK
`,
expectedWorkflowTitle: ".github/workflows/scheduled.yml",
expectedCronSpecs: []string{"30 5,17 * * *"},
},
{
name: "Gitea",
workflowID: "test.yml",
workflowDirectory: ".gitea/workflows",
workflowContent: `
name: My scheduled workflow
on:
schedule:
- cron: "* * * * *"
jobs:
test:
steps:
- run: echo OK
`,
expectedWorkflowTitle: "My scheduled workflow",
expectedCronSpecs: []string{"* * * * *"},
},
}
onApplicationRun(t, func(t *testing.T, u *url.URL) {
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
// create the repo
repo, sha, f := tests.CreateDeclarativeRepo(t, user2, "repo-workflow-dispatch",
[]unit_model.Type{unit_model.TypeActions}, nil,
[]*files_service.ChangeRepoFile{
{
Operation: "create",
TreePath: fmt.Sprintf("%s/%s", testCase.workflowDirectory, testCase.workflowID),
ContentReader: strings.NewReader(testCase.workflowContent),
},
},
)
defer f()
schedules, err := db.Find[actions_model.ActionSchedule](t.Context(), actions_model.FindScheduleOptions{RepoID: repo.ID})
require.NoError(t, err)
require.Len(t, schedules, 1)
assert.Equal(t, testCase.expectedWorkflowTitle, schedules[0].Title)
assert.Equal(t, testCase.expectedCronSpecs, schedules[0].Specs)
assert.Equal(t, repo.ID, schedules[0].RepoID)
assert.Equal(t, repo.OwnerID, schedules[0].OwnerID)
assert.Equal(t, testCase.workflowID, schedules[0].WorkflowID)
assert.Equal(t, testCase.workflowDirectory, schedules[0].WorkflowDirectory)
assert.Equal(t, int64(-2), schedules[0].TriggerUserID)
assert.Equal(t, sha, schedules[0].CommitSHA)
assert.Equal(t, webhook_module.HookEventPush, schedules[0].Event)
assert.Equal(t, []byte(testCase.workflowContent), schedules[0].Content)
})
}
})
}

View file

@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
"testing"
@ -128,9 +129,50 @@ func TestActionViewsArtifactDownload(t *testing.T) {
}
func TestActionViewsView(t *testing.T) {
defer unittest.OverrideFixtures("tests/integration/fixtures/TestActionViewsView")()
defer tests.PrepareTestEnv(t)()
req := NewRequest(t, "GET", "/user5/repo4/actions/runs/187")
testCases := []struct {
name string
url string
runIndex int64
jobIndex int64
attempt int64
expectedJSON string
expectedArtifacts string
}{
{
name: "push",
url: "/user5/repo4/actions/runs/187",
runIndex: 187,
jobIndex: 0,
attempt: 1,
expectedJSON: "{\"state\":{\"run\":{\"preExecutionError\":\"\",\"link\":\"/user5/repo4/actions/runs/187\",\"title\":\"update actions\",\"titleHTML\":\"update actions\",\"status\":\"success\",\"canCancel\":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\":\"success\"},{\"summary\":\"Complete job\",\"duration\":\"_duration_\",\"status\":\"success\"}],\"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",
},
{
name: "scheduled",
url: "/user5/repo4/actions/runs/209",
runIndex: 209,
jobIndex: 0,
attempt: 1,
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,\"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",
},
{
name: "workflow_dispatch",
url: "/user5/repo4/actions/runs/210",
runIndex: 210,
jobIndex: 0,
attempt: 1,
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,\"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",
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
req := NewRequest(t, "GET", testCase.url)
intermediateRedirect := MakeRequest(t, req, http.StatusTemporaryRedirect)
finalURL := intermediateRedirect.Result().Header.Get("Location")
@ -140,9 +182,9 @@ func TestActionViewsView(t *testing.T) {
htmlDoc := NewHTMLParser(t, resp.Body)
selector := "#repo-action-view"
// Verify key properties going into the `repo-action-view` to initialize the Vue component.
htmlDoc.AssertAttrEqual(t, selector, "data-run-index", "187")
htmlDoc.AssertAttrEqual(t, selector, "data-job-index", "0")
htmlDoc.AssertAttrEqual(t, selector, "data-attempt-number", "1")
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.AssertAttrPredicate(t, selector, "data-initial-post-response", func(actual string) bool {
// Remove dynamic "duration" fields for comparison.
pattern := `"duration":"[^"]*"`
@ -153,9 +195,11 @@ func TestActionViewsView(t *testing.T) {
re = regexp.MustCompile(pattern)
actualClean = re.ReplaceAllString(actualClean, `"time_since_started_html":"_time_"`)
return assert.JSONEq(t, "{\"state\":{\"run\":{\"preExecutionError\":\"\",\"link\":\"/user5/repo4/actions/runs/187\",\"title\":\"update actions\",\"titleHTML\":\"update actions\",\"status\":\"success\",\"canCancel\":false,\"canApprove\":false,\"canRerun\":false,\"canDeleteArtifact\":false,\"done\":true,\"jobs\":[{\"id\":192,\"name\":\"job_2\",\"status\":\"success\",\"canRerun\":false,\"duration\":\"_duration_\"}],\"commit\":{\"localeCommit\":\"Commit\",\"localePushedBy\":\"pushed by\",\"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\":\"success\"},{\"summary\":\"Complete job\",\"duration\":\"_duration_\",\"status\":\"success\"}],\"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", actualClean)
return assert.JSONEq(t, testCase.expectedJSON, actualClean)
})
htmlDoc.AssertAttrEqual(t, selector, "data-initial-artifacts-response", "{\"artifacts\":[{\"name\":\"multi-file-download\",\"size\":2048,\"status\":\"completed\"}]}\n")
htmlDoc.AssertAttrEqual(t, selector, "data-initial-artifacts-response", testCase.expectedArtifacts)
})
}
}
// Action re-run will redirect the user to an attempt that may not exist in the database yet, since attempts are only
@ -185,7 +229,7 @@ func TestActionViewsViewAttemptOutOfRange(t *testing.T) {
re = regexp.MustCompile(pattern)
actualClean = re.ReplaceAllString(actualClean, `"time_since_started_html":"_time_"`)
return assert.JSONEq(t, "{\"state\":{\"run\":{\"preExecutionError\":\"\",\"link\":\"/user5/repo4/actions/runs/190\",\"title\":\"job output\",\"titleHTML\":\"job output\",\"status\":\"success\",\"canCancel\":false,\"canApprove\":false,\"canRerun\":false,\"canDeleteArtifact\":false,\"done\":false,\"jobs\":[{\"id\":396,\"name\":\"job_2\",\"status\":\"waiting\",\"canRerun\":false,\"duration\":\"_duration_\"}],\"commit\":{\"localeCommit\":\"Commit\",\"localePushedBy\":\"pushed by\",\"localeWorkflow\":\"Workflow\",\"localeAllRuns\":\"all runs\",\"shortSHA\":\"c2d72f5484\",\"link\":\"/user5/repo4/commit/c2d72f548424103f01ee1dc02889c1e2bff816b0\",\"pusher\":{\"displayName\":\"user1\",\"link\":\"/user1\"},\"branch\":{\"name\":\"test\",\"link\":\"/user5/repo4/src/branch/test\",\"isDeleted\":true}}},\"currentJob\":{\"title\":\"job_2\",\"details\":[\"Waiting for a runner with the following label: fedora\"],\"steps\":[],\"allAttempts\":null}},\"logs\":{\"stepsLog\":[]}}\n", actualClean)
return assert.JSONEq(t, "{\"state\":{\"run\":{\"preExecutionError\":\"\",\"link\":\"/user5/repo4/actions/runs/190\",\"title\":\"job output\",\"titleHTML\":\"job output\",\"status\":\"success\",\"canCancel\":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\":false,\"jobs\":[{\"id\":396,\"name\":\"job_2\",\"status\":\"waiting\",\"canRerun\":false,\"duration\":\"_duration_\"}],\"commit\":{\"localeWorkflow\":\"Workflow\",\"localeAllRuns\":\"all runs\",\"shortSHA\":\"c2d72f5484\",\"link\":\"/user5/repo4/commit/c2d72f548424103f01ee1dc02889c1e2bff816b0\",\"pusher\":{\"displayName\":\"user1\",\"link\":\"/user1\"},\"branch\":{\"name\":\"test\",\"link\":\"/user5/repo4/src/branch/test\",\"isDeleted\":true}}},\"currentJob\":{\"title\":\"job_2\",\"details\":[\"Waiting for a runner with the following label: fedora\"],\"steps\":[],\"allAttempts\":null}},\"logs\":{\"stepsLog\":[]}}\n", actualClean)
})
htmlDoc.AssertAttrEqual(t, selector, "data-initial-artifacts-response", "{\"artifacts\":[]}\n")
}

View file

@ -0,0 +1,34 @@
- id: 1000
title: "A scheduled workflow"
repo_id: 4
owner_id: 5
workflow_id: "scheduled.yaml"
index: 209
trigger_user_id: -2
ref: "refs/heads/main"
commit_sha: "64357baca84bfff631e7dfae5a3433b26d005646"
trigger_event: "schedule"
is_fork_pull_request: false
status: 6 # running
started: 1683636528
created: 1683636108
updated: 1683636626
need_approval: false
approved_by: 0
- id: 1001
title: "Running workflow_dispatch"
repo_id: 4
owner_id: 5
workflow_id: "dispatch.yaml"
index: 210
trigger_user_id: 29
ref: "refs/heads/main"
commit_sha: "dc67f0a1a0dc2417cd0b1a9f0b95e2e5d91876e9"
trigger_event: "workflow_dispatch"
is_fork_pull_request: false
status: 6 # running
started: 1683636528
created: 1683636108
updated: 1683636626
need_approval: false
approved_by: 0

View file

@ -0,0 +1,34 @@
- id: 1000
title: "A scheduled workflow"
repo_id: 4
owner_id: 5
workflow_id: "scheduled.yaml"
index: 209
trigger_user_id: -2
ref: "refs/heads/master"
commit_sha: "64357baca84bfff631e7dfae5a3433b26d005646"
trigger_event: "schedule"
is_fork_pull_request: false
status: 5 # waiting
started: 0
created: 1683636108
updated: 0
need_approval: false
approved_by: 0
- id: 1001
title: "A triggered run"
repo_id: 4
owner_id: 5
workflow_id: "dispatch.yaml"
index: 210
trigger_user_id: 29
ref: "refs/heads/master"
commit_sha: "f4100ac14112a3740490afb22b07b69b0b5d4e8b"
trigger_event: "workflow_dispatch"
is_fork_pull_request: false
status: 5 # waiting
started: 0
created: 1683636108
updated: 0
need_approval: false
approved_by: 0

View file

@ -0,0 +1,28 @@
- id: 2153
run_id: 1000
repo_id: 4
owner_id: 5
commit_sha: 64357baca84bfff631e7dfae5a3433b26d005646
is_fork_pull_request: false
name: job_2
attempt: 1
runs_on: ["debian", "gpu"]
job_id: job_2
task_id: 8753
status: 5 # StatusWaiting
started: 0
stopped: 0
- id: 2154
run_id: 1001
repo_id: 4
owner_id: 5
runs_on: ["windows"]
commit_sha: f4100ac14112a3740490afb22b07b69b0b5d4e8b
is_fork_pull_request: false
name: mirror
attempt: 1
job_id: mirror
task_id: 8754
status: 5 # StatusWaiting
started: 0
stopped: 0

View file

@ -0,0 +1,28 @@
- id: 8753
job_id: 2153
attempt: 1
runner_id: 0
status: 1 # Waiting
started: 0
stopped: 0
repo_id: 4
owner_id: 5
commit_sha: 64357baca84bfff631e7dfae5a3433b26d005646
is_fork_pull_request: false
token_hash: 5fd2714302a06027c0184dbaa697dd1bea7ec80823b673aac8e378dbabdb3f4156bfad6995a8701ec18c187483db7253110e
token_salt: ffffffffff
token_last_eight: ffffffff
- id: 8754
job_id: 2154
attempt: 1
runner_id: 0
status: 5 # Waiting
started: 0
stopped: 0
repo_id: 4
owner_id: 5
commit_sha: f4100ac14112a3740490afb22b07b69b0b5d4e8b
is_fork_pull_request: false
token_hash: 9c104fe0db29aa6d737001707e1de2201fdfefb6d2316ec4fb38c44a1820a5948af2f9e1cb5e58ab95cc8fbe589fd4e82f95
token_salt: ffffffffff
token_last_eight: ffffffff

View file

@ -82,6 +82,7 @@ export default {
title: '',
titleHTML: '',
status: '',
description: '',
canCancel: false,
canApprove: false,
canRerun: false,
@ -97,8 +98,6 @@ export default {
// },
],
commit: {
localeCommit: '',
localePushedBy: '',
localeWorkflow: '',
localeAllRuns: '',
shortSHA: '',
@ -482,10 +481,8 @@ export default {
</div>
</div>
<div class="action-summary">
{{ run.commit.localeCommit }}
<a class="muted" :href="run.commit.link">{{ run.commit.shortSHA }}</a>
{{ run.commit.localePushedBy }}
<a class="muted" :href="run.commit.pusher.link">{{ run.commit.pusher.displayName }}</a>
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="run.description"/>
<span class="ui label tw-max-w-full" v-if="run.commit.shortSHA">
<span v-if="run.commit.branch.isDeleted" class="gt-ellipsis tw-line-through" :data-tooltip-content="run.commit.branch.name">{{ run.commit.branch.name }}</span>
<a v-else class="gt-ellipsis" :href="run.commit.branch.link" :data-tooltip-content="run.commit.branch.name">{{ run.commit.branch.name }}</a>
@ -493,7 +490,7 @@ export default {
</div>
<div class="action-summary">
{{ run.commit.localeWorkflow }}
<a class="muted" :href="workflowSourceURL">{{ workflowName }}</a> <span>(<a class="muted" :href="workflowURL">{{ run.commit.localeAllRuns }}</a>)</span>
<a :href="workflowSourceURL">{{ workflowName }}</a> <span>(<a :href="workflowURL">{{ run.commit.localeAllRuns }}</a>)</span>
</div>
<div class="ui error message pre-execution-error" v-if="run.preExecutionError">
<div class="header">