Skip to content

Commit 799536d

Browse files
authored
Fix checks for needs in Actions (#23789) (#23831)
Backport #23789. Fix: - https://gitea.com/gitea/act_runner/issues/77 - https://gitea.com/gitea/act_runner/issues/81 Before: <img width="1489" alt="image" src="https://user-images.githubusercontent.com/9418365/228501567-f752cf87-a7ed-42c6-8f3d-ba741795c1fe.png"> Highlights: - Upgrade act to make things doable, related to - https://gitea.com/gitea/act/pulls/32 - https://gitea.com/gitea/act/pulls/33 - https://gitea.com/gitea/act/pulls/35 - Make `needs` works - Sort jobs in the original order in the workflow files
1 parent c68650a commit 799536d

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
285285

286286
replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix
287287

288-
replace github.com/nektos/act => gitea.com/gitea/act v0.243.1
288+
replace github.com/nektos/act => gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab
289289

290290
exclude github.com/gofrs/uuid v3.2.0+incompatible
291291

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsi
7070
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
7171
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
7272
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
73-
gitea.com/gitea/act v0.243.1 h1:zIVlhGOLE4SHFPW++u3+5Y/jX5mub3QIhB13oNf6rtA=
74-
gitea.com/gitea/act v0.243.1/go.mod h1:iLHCXqOPUElA2nSyHo4wtxSmvdkym3WU7CkP3AxF39Q=
73+
gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab h1:HDImhO/XpMJrw2PJcADI/wgur9Gro/pegLFaRt8Wpg0=
74+
gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab/go.mod h1:mabw6AZAiDgxGlK83orWLrNERSPvgBJzEUS3S7u2bHI=
7575
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4=
7676
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
7777
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=

models/actions/run.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
199199
for _, v := range jobs {
200200
id, job := v.Job()
201201
needs := job.Needs()
202-
job.EraseNeeds()
202+
if err := v.SetJob(id, job.EraseNeeds()); err != nil {
203+
return err
204+
}
203205
payload, _ := v.Marshal()
204206
status := StatusWaiting
205207
if len(needs) > 0 {

modules/actions/workflows.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
106106
webhook_module.HookEventRepository,
107107
webhook_module.HookEventRelease,
108108
webhook_module.HookEventPackage:
109-
if len(evt.Acts) != 0 {
110-
log.Warn("Ignore unsupported %s event arguments %q", triggedEvent, evt.Acts)
109+
if len(evt.Acts()) != 0 {
110+
log.Warn("Ignore unsupported %s event arguments %v", triggedEvent, evt.Acts())
111111
}
112112
// no special filter parameters for these events, just return true if name matched
113113
return true
@@ -132,7 +132,7 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
132132

133133
func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobparser.Event) bool {
134134
// with no special filter parameters
135-
if len(evt.Acts) == 0 {
135+
if len(evt.Acts()) == 0 {
136136
return true
137137
}
138138

@@ -141,7 +141,7 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
141141
hasTagFilter := false
142142
refName := git.RefName(pushPayload.Ref)
143143
// all acts conditions should be satisfied
144-
for cond, vals := range evt.Acts {
144+
for cond, vals := range evt.Acts() {
145145
switch cond {
146146
case "branches":
147147
hasBranchFilter = true
@@ -225,18 +225,18 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
225225
if hasBranchFilter && hasTagFilter {
226226
matchTimes++
227227
}
228-
return matchTimes == len(evt.Acts)
228+
return matchTimes == len(evt.Acts())
229229
}
230230

231231
func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *jobparser.Event) bool {
232232
// with no special filter parameters
233-
if len(evt.Acts) == 0 {
233+
if len(evt.Acts()) == 0 {
234234
return true
235235
}
236236

237237
matchTimes := 0
238238
// all acts conditions should be satisfied
239-
for cond, vals := range evt.Acts {
239+
for cond, vals := range evt.Acts() {
240240
switch cond {
241241
case "types":
242242
for _, val := range vals {
@@ -249,19 +249,19 @@ func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *j
249249
log.Warn("issue event unsupported condition %q", cond)
250250
}
251251
}
252-
return matchTimes == len(evt.Acts)
252+
return matchTimes == len(evt.Acts())
253253
}
254254

255255
func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload, evt *jobparser.Event) bool {
256256
// with no special filter parameters
257-
if len(evt.Acts) == 0 {
257+
if len(evt.Acts()) == 0 {
258258
// defaultly, only pull request opened and synchronized will trigger workflow
259259
return prPayload.Action == api.HookIssueSynchronized || prPayload.Action == api.HookIssueOpened
260260
}
261261

262262
matchTimes := 0
263263
// all acts conditions should be satisfied
264-
for cond, vals := range evt.Acts {
264+
for cond, vals := range evt.Acts() {
265265
switch cond {
266266
case "types":
267267
action := prPayload.Action
@@ -323,18 +323,18 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
323323
log.Warn("pull request event unsupported condition %q", cond)
324324
}
325325
}
326-
return matchTimes == len(evt.Acts)
326+
return matchTimes == len(evt.Acts())
327327
}
328328

329329
func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCommentPayload, evt *jobparser.Event) bool {
330330
// with no special filter parameters
331-
if len(evt.Acts) == 0 {
331+
if len(evt.Acts()) == 0 {
332332
return true
333333
}
334334

335335
matchTimes := 0
336336
// all acts conditions should be satisfied
337-
for cond, vals := range evt.Acts {
337+
for cond, vals := range evt.Acts() {
338338
switch cond {
339339
case "types":
340340
for _, val := range vals {
@@ -347,5 +347,5 @@ func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCo
347347
log.Warn("issue comment unsupported condition %q", cond)
348348
}
349349
}
350-
return matchTimes == len(evt.Acts)
350+
return matchTimes == len(evt.Acts())
351351
}

0 commit comments

Comments
 (0)