@@ -18,7 +18,6 @@ import (
1818 api "code.gitea.io/gitea/modules/structs"
1919
2020 runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
21-
2221 "github.com/stretchr/testify/assert"
2322)
2423
@@ -31,8 +30,11 @@ func TestJobWithNeeds(t *testing.T) {
3130 }{
3231 {
3332 treePath : ".gitea/workflows/job-with-needs.yml" ,
34- fileContent : `name: test
35- on: push
33+ fileContent : `name: job-with-needs
34+ on:
35+ push:
36+ paths:
37+ - '.gitea/workflows/job-with-needs.yml'
3638jobs:
3739 job1:
3840 runs-on: ubuntu-latest
5961 },
6062 {
6163 treePath : ".gitea/workflows/job-with-needs-fail.yml" ,
62- fileContent : `name: test
63- on: push
64+ fileContent : `name: job-with-needs-fail
65+ on:
66+ push:
67+ paths:
68+ - '.gitea/workflows/job-with-needs-fail.yml'
6469jobs:
6570 job1:
6671 runs-on: ubuntu-latest
8287 "job2" : actions_model .StatusSkipped .String (),
8388 },
8489 },
90+ {
91+ treePath : ".gitea/workflows/job-with-needs-fail-if.yml" ,
92+ fileContent : `name: job-with-needs-fail-if
93+ on:
94+ push:
95+ paths:
96+ - '.gitea/workflows/job-with-needs-fail-if.yml'
97+ jobs:
98+ job1:
99+ runs-on: ubuntu-latest
100+ steps:
101+ - run: echo job1
102+ job2:
103+ runs-on: ubuntu-latest
104+ needs: [job1]
105+ if: ${{ always() }}
106+ steps:
107+ - run: echo job2
108+ ` ,
109+ execPolicies : map [string ]* taskExecPolicy {
110+ "job1" : {
111+ result : runnerv1 .Result_RESULT_FAILURE ,
112+ },
113+ "job2" : {
114+ result : runnerv1 .Result_RESULT_SUCCESS ,
115+ },
116+ },
117+ expectedStatuses : map [string ]string {
118+ "job1" : actions_model .StatusFailure .String (),
119+ "job2" : actions_model .StatusSuccess .String (),
120+ },
121+ },
85122 }
86123 onGiteaRun (t , func (t * testing.T , u * url.URL ) {
87124 runner := newMockRunner (t )
@@ -155,6 +192,8 @@ jobs:
155192 assert .Equal (t , status , tc .expectedStatuses [apiTask .Name ])
156193 }
157194 }
195+
196+ // time.Sleep(30 * time.Second)
158197 })
159198}
160199
0 commit comments