-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Add "Run" prefix for unnamed action steps #36624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
52ad5cb
Add localized "Run" prefix for unnamed action steps
silverwind 991e3e5
Rename locale key to actions.runs.run
silverwind 954fe95
Avoid mutating task steps, extract hasName slice instead
silverwind 604deef
Revert "Avoid mutating task steps, extract hasName slice instead"
silverwind c0bfd08
x
silverwind 6544e42
Add "Run " prefix for unnamed action steps at creation time
silverwind 82d7f8a
fine tune
wxiaoguang 93f8b79
fix test
wxiaoguang 67a6235
Extract stepDisplayName and add proper unit test
silverwind 0f9db3f
Check Uses and Run fields explicitly in makeTaskStepDisplayName
silverwind 9f452bf
add test
wxiaoguang 53abe77
revert test
wxiaoguang de27d0a
revert test
wxiaoguang d55d3af
Revert "Check Uses and Run fields explicitly in makeTaskStepDisplayName"
silverwind 8bd8c00
Match GitHub's step display name derivation
silverwind 3eb5e14
Add reference link to GitHub Actions runner source
silverwind 7f2d3d8
Restore comment on explicit step name
silverwind 5ac5df7
Restore else clause structure, add "Run " prefix to all unnamed steps
silverwind d104802
Use production limit of 255 in step display name tests
silverwind 41bb013
clean up comments
silverwind 2905714
Simplify step display name logic
silverwind 489a802
Restore comment, handle CRLF line endings in step display name
silverwind a5080ce
Merge branch 'main' into runprefix
silverwind 89b243c
Use TrimSpace instead of TrimRight for run step display name
silverwind 107f829
Update models/actions/task_test.go
wxiaoguang 2fabf1c
merge test cases
wxiaoguang 12d28ee
Merge branch 'main' into runprefix
GiteaBot 402c861
Merge branch 'main' into runprefix
GiteaBot 5da1860
Merge branch 'main' into runprefix
GiteaBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package actions | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/nektos/act/pkg/jobparser" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestMakeTaskStepDisplayName(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| jobStep *jobparser.Step | ||
| expected string | ||
| }{ | ||
| { | ||
| name: "explicit name", | ||
| jobStep: &jobparser.Step{ | ||
| Name: "Test Step", | ||
| }, | ||
| expected: "Test Step", | ||
| }, | ||
| { | ||
| name: "uses step", | ||
| jobStep: &jobparser.Step{ | ||
| Uses: "actions/checkout@v4", | ||
| }, | ||
| expected: "Run actions/checkout@v4", | ||
| }, | ||
| { | ||
| name: "single-line run", | ||
| jobStep: &jobparser.Step{ | ||
| Run: "echo hello", | ||
| }, | ||
| expected: "Run echo hello", | ||
| }, | ||
| { | ||
| name: "multi-line run", | ||
| jobStep: &jobparser.Step{ | ||
| Run: "echo hello\necho world", | ||
| }, | ||
| expected: "Run echo hello", | ||
| }, | ||
| { | ||
| name: "multi-line run block scalar", // run: |\n echo hello\n echo world\n | ||
| jobStep: &jobparser.Step{ | ||
| Run: "echo hello\necho world\n", | ||
|
wxiaoguang marked this conversation as resolved.
Outdated
|
||
| }, | ||
| expected: "Run echo hello", | ||
| }, | ||
| { | ||
| name: "multi-line run with leading newline", | ||
| jobStep: &jobparser.Step{ | ||
| Run: "\n echo hello\n echo world", | ||
| }, | ||
| expected: "Run echo hello", | ||
| }, | ||
| { | ||
| name: "multi-line run with CRLF", | ||
| jobStep: &jobparser.Step{ | ||
| Run: "echo hello\r\necho world", | ||
| }, | ||
| expected: "Run echo hello", | ||
| }, | ||
| { | ||
| name: "fallback to id", | ||
| jobStep: &jobparser.Step{ | ||
| ID: "step-id", | ||
| }, | ||
| expected: "Run step-id", | ||
| }, | ||
| { | ||
| name: "very long name truncated", | ||
| jobStep: &jobparser.Step{ | ||
| Name: strings.Repeat("a", 300), | ||
| }, | ||
| expected: strings.Repeat("a", 252) + "…", | ||
| }, | ||
| { | ||
| name: "very long run truncated", | ||
| jobStep: &jobparser.Step{ | ||
| Run: strings.Repeat("a", 300), | ||
| }, | ||
| expected: "Run " + strings.Repeat("a", 248) + "…", | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| result := makeTaskStepDisplayName(tt.jobStep, 255) | ||
| assert.Equal(t, tt.expected, result) | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2025 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package actions | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| actions_model "code.gitea.io/gitea/models/actions" | ||
| "code.gitea.io/gitea/modules/timeutil" | ||
| "code.gitea.io/gitea/modules/translation" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestConvertToViewModel(t *testing.T) { | ||
| task := &actions_model.ActionTask{ | ||
| Status: actions_model.StatusSuccess, | ||
| Steps: []*actions_model.ActionTaskStep{ | ||
| {Name: "Run step-name", Index: 0, Status: actions_model.StatusSuccess, LogLength: 1, Started: timeutil.TimeStamp(1), Stopped: timeutil.TimeStamp(5)}, | ||
| }, | ||
| Stopped: timeutil.TimeStamp(20), | ||
| } | ||
|
|
||
| viewJobSteps, _, err := convertToViewModel(t.Context(), translation.MockLocale{}, nil, task) | ||
| require.NoError(t, err) | ||
|
|
||
| expectedViewJobs := []*ViewJobStep{ | ||
| { | ||
| Summary: "Set up job", | ||
| Duration: "0s", | ||
| Status: "success", | ||
| }, | ||
| { | ||
| Summary: "Run step-name", | ||
| Duration: "4s", | ||
| Status: "success", | ||
| }, | ||
| { | ||
| Summary: "Complete job", | ||
| Duration: "15s", | ||
| Status: "success", | ||
| }, | ||
| } | ||
| assert.Equal(t, expectedViewJobs, viewJobSteps) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.