Skip to content
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

Fix Workflow names instead of workflow file name #31474

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kiatt210
Copy link
Contributor

Fixes #31458 and maybe #25912

I added the name from the YAML file to the workflow object. If there is no name in the file, the name remains the filename.
I created an object to connect the run and workflow together, which was necessary to show workflow name in action run list.

(Easier to review with disabled whitespace changes, unfortunately there is a lot of them in runs_list.tmpl :( )

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 24, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 24, 2024
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Jun 24, 2024
{{- end -}}
{{$CurWorkflow := $.CurWorkflow}}
{{$WorkflowName := .Workflow.Name}}
{{with .ActionRun}}
Copy link
Contributor

@wxiaoguang wxiaoguang Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable shadowing is more complex now. And the name Run also seems ambiguous

I think it's better to do so:

{{range $run = .WorkflowActionRuns}}
    {{$actionRun := $run.ActionRun}}
    {{$workflow = $run.Workflow}}
    {{$actionRun.Title}}
    ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the idea, I did the changes.

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 24, 2024
wxiaoguang
wxiaoguang previously approved these changes Jun 24, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 24, 2024
Copy link
Contributor

@kemzeb kemzeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 24, 2024
@silverwind
Copy link
Member

silverwind commented Jun 25, 2024

If there is no name in the file, the name remains the filename.

I tested in GitHub actions and they show the full path to the file when workflow name is absent, e.g. .github/workflows/ci2.yaml. Might be especially relevant to us because we look into both .github and .gitea folders so filename alone can be ambigous.

@yp05327
Copy link
Contributor

yp05327 commented Jun 25, 2024

IIRC, GitHub has some bugs of display workflow name. That’s why no one fix this issue for a long time I think.
I have no time the check the code, as this is approved too quickly, so I’m not sure whether this PR can handle some special cases which GitHub can not.

@kiatt210
Copy link
Contributor Author

Do you have any idea which special cases I should check or where I should look for them?
Thank you!

@yp05327
Copy link
Contributor

yp05327 commented Jun 25, 2024

I still remember the details of one test I did. And I tested it in this PR. The result is as my thought.

For example, you have 2 branches, and the workflow files have same file name, but the workflow names are different.
Then the result is this:
image
In the list, the workflow name is Gitea Actions Demo which is defined in the main branch:
image

But in test branch, the workflow name is Gitea Actions Demo in test:
image

But they are all detected as the workflow Gitea Actions Demo.

So actually, the logic is still based on the file name, not the workflow name defined in the yml file.
That's why we are using file name but not workflow name here.

IIRC, this is caused by the original design of Gitea Action, if we want to use workflow names instead of file names,
we need to rewrite many places.

Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per @yp05327, we should probably iron out edge cases first

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. labels Jun 26, 2024
@wxiaoguang
Copy link
Contributor

Stale for long time

@wxiaoguang wxiaoguang added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workflow names instead of workflow file name
7 participants