Skip to content

Commit 964a057

Browse files
authored
Fix checks for needs in Actions (#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 aa4d1d9 commit 964a057

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
289289

290290
replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix
291291

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

294294
exclude github.com/gofrs/uuid v3.2.0+incompatible
295295

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsi
5252
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
5353
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
5454
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
55-
gitea.com/gitea/act v0.243.1 h1:zIVlhGOLE4SHFPW++u3+5Y/jX5mub3QIhB13oNf6rtA=
56-
gitea.com/gitea/act v0.243.1/go.mod h1:iLHCXqOPUElA2nSyHo4wtxSmvdkym3WU7CkP3AxF39Q=
55+
gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab h1:HDImhO/XpMJrw2PJcADI/wgur9Gro/pegLFaRt8Wpg0=
56+
gitea.com/gitea/act v0.243.2-0.20230329055922-5e76853b55ab/go.mod h1:mabw6AZAiDgxGlK83orWLrNERSPvgBJzEUS3S7u2bHI=
5757
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4=
5858
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
5959
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=

models/actions/run.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
197197
for _, v := range jobs {
198198
id, job := v.Job()
199199
needs := job.Needs()
200-
job.EraseNeeds()
200+
if err := v.SetJob(id, job.EraseNeeds()); err != nil {
201+
return err
202+
}
201203
payload, _ := v.Marshal()
202204
status := StatusWaiting
203205
if len(needs) > 0 || run.NeedApproval {

modules/actions/workflows.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
122122
webhook_module.HookEventRepository,
123123
webhook_module.HookEventRelease,
124124
webhook_module.HookEventPackage:
125-
if len(evt.Acts) != 0 {
126-
log.Warn("Ignore unsupported %s event arguments %q", triggedEvent, evt.Acts)
125+
if len(evt.Acts()) != 0 {
126+
log.Warn("Ignore unsupported %s event arguments %v", triggedEvent, evt.Acts())
127127
}
128128
// no special filter parameters for these events, just return true if name matched
129129
return true
@@ -148,7 +148,7 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
148148

149149
func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobparser.Event) bool {
150150
// with no special filter parameters
151-
if len(evt.Acts) == 0 {
151+
if len(evt.Acts()) == 0 {
152152
return true
153153
}
154154

@@ -157,7 +157,7 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
157157
hasTagFilter := false
158158
refName := git.RefName(pushPayload.Ref)
159159
// all acts conditions should be satisfied
160-
for cond, vals := range evt.Acts {
160+
for cond, vals := range evt.Acts() {
161161
switch cond {
162162
case "branches":
163163
hasBranchFilter = true
@@ -241,18 +241,18 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
241241
if hasBranchFilter && hasTagFilter {
242242
matchTimes++
243243
}
244-
return matchTimes == len(evt.Acts)
244+
return matchTimes == len(evt.Acts())
245245
}
246246

247247
func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *jobparser.Event) bool {
248248
// with no special filter parameters
249-
if len(evt.Acts) == 0 {
249+
if len(evt.Acts()) == 0 {
250250
return true
251251
}
252252

253253
matchTimes := 0
254254
// all acts conditions should be satisfied
255-
for cond, vals := range evt.Acts {
255+
for cond, vals := range evt.Acts() {
256256
switch cond {
257257
case "types":
258258
for _, val := range vals {
@@ -265,19 +265,19 @@ func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *j
265265
log.Warn("issue event unsupported condition %q", cond)
266266
}
267267
}
268-
return matchTimes == len(evt.Acts)
268+
return matchTimes == len(evt.Acts())
269269
}
270270

271271
func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload, evt *jobparser.Event) bool {
272272
// with no special filter parameters
273-
if len(evt.Acts) == 0 {
273+
if len(evt.Acts()) == 0 {
274274
// defaultly, only pull request opened and synchronized will trigger workflow
275275
return prPayload.Action == api.HookIssueSynchronized || prPayload.Action == api.HookIssueOpened
276276
}
277277

278278
matchTimes := 0
279279
// all acts conditions should be satisfied
280-
for cond, vals := range evt.Acts {
280+
for cond, vals := range evt.Acts() {
281281
switch cond {
282282
case "types":
283283
action := prPayload.Action
@@ -339,18 +339,18 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
339339
log.Warn("pull request event unsupported condition %q", cond)
340340
}
341341
}
342-
return matchTimes == len(evt.Acts)
342+
return matchTimes == len(evt.Acts())
343343
}
344344

345345
func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCommentPayload, evt *jobparser.Event) bool {
346346
// with no special filter parameters
347-
if len(evt.Acts) == 0 {
347+
if len(evt.Acts()) == 0 {
348348
return true
349349
}
350350

351351
matchTimes := 0
352352
// all acts conditions should be satisfied
353-
for cond, vals := range evt.Acts {
353+
for cond, vals := range evt.Acts() {
354354
switch cond {
355355
case "types":
356356
for _, val := range vals {
@@ -363,5 +363,5 @@ func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCo
363363
log.Warn("issue comment unsupported condition %q", cond)
364364
}
365365
}
366-
return matchTimes == len(evt.Acts)
366+
return matchTimes == len(evt.Acts())
367367
}

web_src/js/components/RepoActionView.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="action-view-container">
33
<div class="action-view-header">
4-
<div class="action-info-summary">
4+
<div class="action-info-summary gt-ac">
55
<ActionRunStatus :status="run.status" :size="20"/>
66
<div class="action-title">
77
{{ run.title }}
@@ -30,7 +30,7 @@
3030
<div class="job-brief-item" v-for="(job, index) in run.jobs" :key="job.id">
3131
<a class="job-brief-link" :href="run.link+'/jobs/'+index">
3232
<ActionRunStatus :status="job.status"/>
33-
<span class="ui text">{{ job.name }}</span>
33+
<span class="ui text gt-mx-3">{{ job.name }}</span>
3434
</a>
3535
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.canRerun">
3636
<SvgIcon name="octicon-sync" class="ui text black"/>
@@ -404,7 +404,6 @@ export function initRepositoryActionView() {
404404
}
405405
406406
.job-group-section .job-brief-list .job-brief-item .job-brief-link span {
407-
margin-right: 8px;
408407
display: flex;
409408
align-items: center;
410409
}

0 commit comments

Comments
 (0)