Skip to content

Commit 56b550c

Browse files
committed
Merge branch 'main' into lunny/remove_wiki_path_ref
2 parents 6f69370 + 662a44d commit 56b550c

File tree

23 files changed

+219
-100
lines changed

23 files changed

+219
-100
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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"eslint-plugin-vue-scoped-css": "2.12.0",
9797
"eslint-plugin-wc": "3.0.2",
9898
"globals": "16.4.0",
99-
"happy-dom": "19.0.2",
99+
"happy-dom": "20.0.0",
100100
"markdownlint-cli": "0.45.0",
101101
"material-icon-theme": "5.27.0",
102102
"nolyfill": "1.0.44",

pnpm-lock.yaml

Lines changed: 44 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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
}

0 commit comments

Comments
 (0)