@@ -53,14 +53,19 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
5353 return fmt .Errorf ("get action run: %w" , err )
5454 }
5555
56- return db .WithTx (ctx , func (ctx context.Context ) error {
56+ var jobsToCreateCommitStatus []* actions_model.ActionRunJob
57+
58+ if err := db .WithTx (ctx , func (ctx context.Context ) error {
5759 // check jobs of the current run
58- if err := checkJobsOfRun (ctx , run ); err != nil {
60+ if jobs , err := checkJobsOfRun (ctx , run ); err != nil {
5961 return err
62+ } else {
63+ jobsToCreateCommitStatus = append (jobsToCreateCommitStatus , jobs ... )
6064 }
6165
6266 // check run (workflow-level) concurrency
6367 concurrentRunIDs := make (container.Set [int64 ])
68+ concurrentRunIDs .Add (run .ID )
6469 if run .ConcurrencyGroup != "" {
6570 concurrentRuns , err := db .Find [actions_model.ActionRun ](ctx , actions_model.FindRunOptions {
6671 RepoID : run .RepoID ,
@@ -71,12 +76,17 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
7176 return err
7277 }
7378 for _ , concurrentRun := range concurrentRuns {
79+ if concurrentRunIDs .Contains (concurrentRun .ID ) {
80+ continue
81+ }
7482 concurrentRunIDs .Add (concurrentRun .ID )
7583 if concurrentRun .NeedApproval {
7684 continue
7785 }
78- if err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
86+ if jobs , err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
7987 return err
88+ } else {
89+ jobsToCreateCommitStatus = append (jobsToCreateCommitStatus , jobs ... )
8090 }
8191 updatedRun , err := actions_model .GetRunByID (ctx , concurrentRun .ID )
8292 if err != nil {
@@ -108,15 +118,18 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
108118 if concurrentRunIDs .Contains (concurrentJob .RunID ) {
109119 continue
110120 }
121+ concurrentRunIDs .Add (concurrentJob .RunID )
111122 concurrentRun , err := actions_model .GetRunByID (ctx , concurrentJob .RunID )
112123 if err != nil {
113124 return err
114125 }
115126 if concurrentRun .NeedApproval {
116127 continue
117128 }
118- if err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
129+ if jobs , err := checkJobsOfRun (ctx , concurrentRun ); err != nil {
119130 return err
131+ } else {
132+ jobsToCreateCommitStatus = append (jobsToCreateCommitStatus , jobs ... )
120133 }
121134 updatedJob , err := actions_model .GetRunJobByID (ctx , concurrentJob .ID )
122135 if err != nil {
@@ -130,18 +143,24 @@ func checkJobsByRunID(ctx context.Context, runID int64) error {
130143 }
131144
132145 return nil
133- })
146+ }); err != nil {
147+ return err
148+ }
149+
150+ CreateCommitStatus (ctx , jobsToCreateCommitStatus ... )
151+
152+ return nil
134153}
135154
136- func checkJobsOfRun (ctx context.Context , run * actions_model.ActionRun ) error {
155+ func checkJobsOfRun (ctx context.Context , run * actions_model.ActionRun ) ([] * actions_model. ActionRunJob , error ) {
137156 jobs , err := db .Find [actions_model.ActionRunJob ](ctx , actions_model.FindRunJobOptions {RunID : run .ID })
138157 if err != nil {
139- return err
158+ return nil , err
140159 }
141160
142161 vars , err := actions_model .GetVariablesOfRun (ctx , run )
143162 if err != nil {
144- return fmt .Errorf ("get run %d variables: %w" , run .ID , err )
163+ return nil , fmt .Errorf ("get run %d variables: %w" , run .ID , err )
145164 }
146165
147166 if err := db .WithTx (ctx , func (ctx context.Context ) error {
@@ -162,10 +181,9 @@ func checkJobsOfRun(ctx context.Context, run *actions_model.ActionRun) error {
162181 }
163182 return nil
164183 }); err != nil {
165- return err
184+ return nil , err
166185 }
167- CreateCommitStatus (ctx , jobs ... )
168- return nil
186+ return jobs , nil
169187}
170188
171189type jobStatusResolver struct {
0 commit comments