Skip to content

Commit 7a41c57

Browse files
Merge branch 'main' into dependabot/npm_and_yarn/happy-dom-20.0.0
2 parents 879571e + 25c4eb1 commit 7a41c57

File tree

15 files changed

+60
-44
lines changed

15 files changed

+60
-44
lines changed

models/actions/run_job.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"code.gitea.io/gitea/modules/timeutil"
1515
"code.gitea.io/gitea/modules/util"
1616

17+
"github.com/nektos/act/pkg/jobparser"
1718
"xorm.io/builder"
1819
)
1920

@@ -99,6 +100,24 @@ func (job *ActionRunJob) LoadAttributes(ctx context.Context) error {
99100
return job.Run.LoadAttributes(ctx)
100101
}
101102

103+
// ParseJob parses the job structure from the ActionRunJob.WorkflowPayload
104+
func (job *ActionRunJob) ParseJob() (*jobparser.Job, error) {
105+
// job.WorkflowPayload is a SingleWorkflow created from an ActionRun's workflow, which exactly contains this job's YAML definition.
106+
// Ideally it shouldn't be called "Workflow", it is just a job with global workflow fields + trigger
107+
parsedWorkflows, err := jobparser.Parse(job.WorkflowPayload)
108+
if err != nil {
109+
return nil, fmt.Errorf("job %d single workflow: unable to parse: %w", job.ID, err)
110+
} else if len(parsedWorkflows) != 1 {
111+
return nil, fmt.Errorf("job %d single workflow: not single workflow", job.ID)
112+
}
113+
_, workflowJob := parsedWorkflows[0].Job()
114+
if workflowJob == nil {
115+
// it shouldn't happen, and since the callers don't check nil, so return an error instead of nil
116+
return nil, util.ErrorWrap(util.ErrNotExist, "job %d single workflow: payload doesn't contain a job", job.ID)
117+
}
118+
return workflowJob, nil
119+
}
120+
102121
func GetRunJobByID(ctx context.Context, id int64) (*ActionRunJob, error) {
103122
var job ActionRunJob
104123
has, err := db.GetEngine(ctx).Where("id=?", id).Get(&job)

models/actions/task.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
2323
lru "github.com/hashicorp/golang-lru/v2"
24-
"github.com/nektos/act/pkg/jobparser"
2524
"google.golang.org/protobuf/types/known/timestamppb"
2625
"xorm.io/builder"
2726
)
@@ -278,13 +277,10 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
278277
return nil, false, err
279278
}
280279

281-
parsedWorkflows, err := jobparser.Parse(job.WorkflowPayload)
280+
workflowJob, err := job.ParseJob()
282281
if err != nil {
283-
return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err)
284-
} else if len(parsedWorkflows) != 1 {
285-
return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID)
282+
return nil, false, fmt.Errorf("load job %d: %w", job.ID, err)
286283
}
287-
_, workflowJob := parsedWorkflows[0].Job()
288284

289285
if _, err := e.Insert(task); err != nil {
290286
return nil, false, err

routers/web/repo/setting/lfs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ func LFSFileGet(ctx *context.Context) {
270270
// FIXME: there is no IsPlainText set, but template uses it
271271
ctx.Data["IsTextFile"] = st.IsText()
272272
ctx.Data["FileSize"] = meta.Size
273-
// FIXME: the last field is the URL-base64-encoded filename, it should not be "direct"
274-
ctx.Data["RawFileLink"] = fmt.Sprintf("%s%s/%s.git/info/lfs/objects/%s/%s", setting.AppURL, url.PathEscape(ctx.Repo.Repository.OwnerName), url.PathEscape(ctx.Repo.Repository.Name), url.PathEscape(meta.Oid), "direct")
273+
ctx.Data["RawFileLink"] = fmt.Sprintf("%s/%s/%s.git/info/lfs/objects/%s", setting.AppSubURL, url.PathEscape(ctx.Repo.Repository.OwnerName), url.PathEscape(ctx.Repo.Repository.Name), url.PathEscape(meta.Oid))
275274
switch {
276275
case st.IsRepresentableAsText():
277276
if meta.Size >= setting.UI.MaxDisplayFileSize {

services/actions/concurrency.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package actions
55

66
import (
77
"context"
8-
"errors"
98
"fmt"
109

1110
actions_model "code.gitea.io/gitea/models/actions"
@@ -91,17 +90,12 @@ func EvaluateJobConcurrencyFillModel(ctx context.Context, run *actions_model.Act
9190
return fmt.Errorf("get inputs: %w", err)
9291
}
9392

94-
// singleWorkflows is created from an ActionJob, which always contains exactly a single job's YAML definition.
95-
// Ideally it shouldn't be called "Workflow", it is just a job with global workflow fields + trigger
96-
singleWorkflows, err := jobparser.Parse(actionRunJob.WorkflowPayload)
93+
workflowJob, err := actionRunJob.ParseJob()
9794
if err != nil {
98-
return fmt.Errorf("parse single workflow: %w", err)
99-
} else if len(singleWorkflows) != 1 {
100-
return errors.New("not single workflow")
95+
return fmt.Errorf("load job %d: %w", actionRunJob.ID, err)
10196
}
102-
_, singleWorkflowJob := singleWorkflows[0].Job()
10397

104-
actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = jobparser.EvaluateConcurrency(&rawConcurrency, actionRunJob.JobID, singleWorkflowJob, actionsJobCtx, jobResults, vars, inputs)
98+
actionRunJob.ConcurrencyGroup, actionRunJob.ConcurrencyCancel, err = jobparser.EvaluateConcurrency(&rawConcurrency, actionRunJob.JobID, workflowJob, actionsJobCtx, jobResults, vars, inputs)
10599
if err != nil {
106100
return fmt.Errorf("evaluate concurrency: %w", err)
107101
}

services/actions/job_emitter.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"code.gitea.io/gitea/modules/util"
1919
notify_service "code.gitea.io/gitea/services/notify"
2020

21-
"github.com/nektos/act/pkg/jobparser"
2221
"xorm.io/builder"
2322
)
2423

@@ -305,9 +304,9 @@ func (r *jobStatusResolver) resolveCheckNeeds(id int64) (allDone, allSucceed boo
305304
}
306305

307306
func (r *jobStatusResolver) resolveJobHasIfCondition(actionRunJob *actions_model.ActionRunJob) (hasIf bool) {
308-
if wfJobs, _ := jobparser.Parse(actionRunJob.WorkflowPayload); len(wfJobs) == 1 {
309-
_, wfJob := wfJobs[0].Job()
310-
hasIf = len(wfJob.If.Value) > 0
307+
// FIXME evaluate this on the server side
308+
if job, err := actionRunJob.ParseJob(); err == nil {
309+
return len(job.If.Value) > 0
311310
}
312311
return hasIf
313312
}

templates/admin/config.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@
252252
{{end}}
253253
{{if .CacheConn}}
254254
<dt>{{ctx.Locale.Tr "admin.config.cache_conn"}}</dt>
255-
<dd><code>{{.CacheConn}}</code></dd>
255+
<dd>{{.CacheConn}}</dd>
256256
<dt>{{ctx.Locale.Tr "admin.config.cache_item_ttl"}}</dt>
257-
<dd><code>{{.CacheItemTTL}}</code></dd>
257+
<dd>{{.CacheItemTTL}}</dd>
258258
{{end}}
259259
<div class="divider"></div>
260260
<dt class="tw-py-1 tw-flex tw-items-center">{{ctx.Locale.Tr "admin.config.cache_test"}}</dt>
@@ -275,7 +275,7 @@
275275
<dt>{{ctx.Locale.Tr "admin.config.session_provider"}}</dt>
276276
<dd>{{.SessionConfig.Provider}}</dd>
277277
<dt>{{ctx.Locale.Tr "admin.config.provider_config"}}</dt>
278-
<dd><code>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</code></dd>
278+
<dd>{{if .SessionConfig.ProviderConfig}}{{.SessionConfig.ProviderConfig}}{{else}}-{{end}}</dd>
279279
<dt>{{ctx.Locale.Tr "admin.config.cookie_name"}}</dt>
280280
<dd>{{.SessionConfig.CookieName}}</dd>
281281
<dt>{{ctx.Locale.Tr "admin.config.gc_interval_time"}}</dt>
@@ -301,7 +301,7 @@
301301
<dt>{{ctx.Locale.Tr "admin.config.git_max_diff_files"}}</dt>
302302
<dd>{{.Git.MaxGitDiffFiles}}</dd>
303303
<dt>{{ctx.Locale.Tr "admin.config.git_gc_args"}}</dt>
304-
<dd><code>{{.Git.GCArgs}}</code></dd>
304+
<dd>{{.Git.GCArgs}}</dd>
305305

306306
<div class="divider"></div>
307307

@@ -330,7 +330,7 @@
330330

331331
{{if .Loggers.access.IsEnabled}}
332332
<dt>{{ctx.Locale.Tr "admin.config.access_log_template"}}</dt>
333-
<dd><code>{{$.AccessLogTemplate}}</code></dd>
333+
<dd>{{$.AccessLogTemplate}}</dd>
334334
{{end}}
335335

336336
{{range $loggerName, $loggerDetail := .Loggers}}

templates/admin/stacktrace-row.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
<div class="item tw-flex tw-items-center">
4747
<span class="icon tw-mr-4">{{svg "octicon-dot-fill" 16}}</span>
4848
<div class="content tw-flex-1">
49-
<div class="header"><code>{{.Function}}</code></div>
50-
<div class="description"><code>{{.File}}:{{.Line}}</code></div>
49+
<div class="header">{{.Function}}</div>
50+
<div class="description">{{.File}}:{{.Line}}</div>
5151
</div>
5252
</div>
5353
{{end}}

templates/base/alert_details.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{if .Details}}
33
<details>
44
<summary>{{.Summary}}</summary>
5-
<code>{{.Details | SanitizeHTML}}</code>
5+
{{.Details | SanitizeHTML}}
66
</details>
77
{{else}}
88
<div>

templates/projects/view.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
</div>
6666

6767
<div class="ui container project-description">
68-
{{$.Project.RenderedContent}}
68+
<div class="render-content markup">
69+
{{$.Project.RenderedContent}}
70+
</div>
6971
<div class="divider"></div>
7072
</div>
7173

templates/repo/settings/lfs_file.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<tbody>
4040
<tr>
4141
<td class="lines-num">{{.LineNums}}</td>
42-
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol>{{.FileContent}}</ol></code></pre></td>
42+
<td class="lines-code"><pre>{{.FileContent}}</pre></td>
4343
</tr>
4444
</tbody>
4545
</table>

0 commit comments

Comments
 (0)