@@ -18,7 +18,6 @@ import (
18
18
api "code.gitea.io/gitea/modules/structs"
19
19
20
20
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
21
-
22
21
"github.com/stretchr/testify/assert"
23
22
)
24
23
@@ -31,8 +30,11 @@ func TestJobWithNeeds(t *testing.T) {
31
30
}{
32
31
{
33
32
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'
36
38
jobs:
37
39
job1:
38
40
runs-on: ubuntu-latest
59
61
},
60
62
{
61
63
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'
64
69
jobs:
65
70
job1:
66
71
runs-on: ubuntu-latest
82
87
"job2" : actions_model .StatusSkipped .String (),
83
88
},
84
89
},
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
+ },
85
122
}
86
123
onGiteaRun (t , func (t * testing.T , u * url.URL ) {
87
124
runner := newMockRunner (t )
@@ -155,6 +192,8 @@ jobs:
155
192
assert .Equal (t , status , tc .expectedStatuses [apiTask .Name ])
156
193
}
157
194
}
195
+
196
+ // time.Sleep(30 * time.Second)
158
197
})
159
198
}
160
199
0 commit comments