@@ -19,18 +19,66 @@ package org.typelevel.sbt.gha
1919sealed abstract class WorkflowJob extends Product with Serializable {
2020 def id : String
2121 def name : String
22+ def needs : List [String ]
2223 def outputs : Map [String , String ]
2324 // TODO: Check for other common properites, like `cond` and `need`
2425
2526 def withId (id : String ): WorkflowJob
2627 def withName (name : String ): WorkflowJob
28+ def withNeeds (needs : List [String ]): WorkflowJob
2729 def withOutputs (outputs : Map [String , String ]): WorkflowJob
2830
2931 def updatedOutputs (name : String , value : String ): WorkflowJob
3032 def concatOutputs (outputs : TraversableOnce [(String , String )]): WorkflowJob
3133}
3234
3335object WorkflowJob {
36+ def apply (
37+ id : String ,
38+ name : String ,
39+ steps : List [WorkflowStep ],
40+ sbtStepPreamble : List [String ] = List (s " ++ $$ {{ matrix.scala }} " ),
41+ cond : Option [String ] = None ,
42+ permissions : Option [Permissions ] = None ,
43+ env : Map [String , String ] = Map (),
44+ outputs : Map [String , String ] = Map .empty,
45+ oses : List [String ] = List (" ubuntu-22.04" ),
46+ scalas : List [String ] = List (" 2.13" ),
47+ javas : List [JavaSpec ] = List (JavaSpec .temurin(" 11" )),
48+ needs : List [String ] = List (),
49+ matrixFailFast : Option [Boolean ] = None ,
50+ matrixAdds : Map [String , List [String ]] = Map (),
51+ matrixIncs : List [MatrixInclude ] = List (),
52+ matrixExcs : List [MatrixExclude ] = List (),
53+ runsOnExtraLabels : List [String ] = List (),
54+ container : Option [JobContainer ] = None ,
55+ environment : Option [JobEnvironment ] = None ,
56+ concurrency : Option [Concurrency ] = None ,
57+ timeoutMinutes : Option [Int ] = None
58+ ): Run =
59+ Run (
60+ id = id,
61+ name = name,
62+ steps = steps,
63+ sbtStepPreamble = sbtStepPreamble,
64+ cond = cond,
65+ permissions = permissions,
66+ env = env,
67+ outputs = outputs,
68+ oses = oses,
69+ scalas = scalas,
70+ javas = javas,
71+ needs = needs,
72+ matrixFailFast = matrixFailFast,
73+ matrixAdds = matrixAdds,
74+ matrixIncs = matrixIncs,
75+ matrixExcs = matrixExcs,
76+ runsOnExtraLabels = runsOnExtraLabels,
77+ container = container,
78+ environment = environment,
79+ concurrency = concurrency,
80+ timeoutMinutes = timeoutMinutes
81+ )
3482 sealed abstract class Run extends WorkflowJob {
3583 def id : String
3684 def name : String
@@ -92,6 +140,7 @@ object WorkflowJob {
92140 cond : Option [String ] = None ,
93141 permissions : Option [Permissions ] = None ,
94142 env : Map [String , String ] = Map (),
143+ outputs : Map [String , String ] = Map .empty,
95144 oses : List [String ] = List (" ubuntu-22.04" ),
96145 scalas : List [String ] = List (" 2.13" ),
97146 javas : List [JavaSpec ] = List (JavaSpec .temurin(" 11" )),
@@ -114,7 +163,7 @@ object WorkflowJob {
114163 cond = cond,
115164 permissions = permissions,
116165 env = env,
117- outputs = Map .empty ,
166+ outputs = outputs ,
118167 oses = oses,
119168 scalas = scalas,
120169 javas = javas,
@@ -192,12 +241,14 @@ object WorkflowJob {
192241 def id : String
193242 def name : String
194243 def uses : String
244+ def needs : List [String ]
195245 def secrets : Option [Secrets ]
196246 def params : Map [String , String ]
197247 def outputs : Map [String , String ]
198248
199249 def withId (id : String ): Use
200250 def withName (name : String ): Use
251+ def withNeeds (needs : List [String ]): Use
201252 def withUses (uses : String ): Use
202253 def withSecrets (secrets : Option [Secrets ]): Use
203254 def withParams (params : Map [String , String ]): Use
@@ -213,13 +264,15 @@ object WorkflowJob {
213264 id : String ,
214265 name : String ,
215266 uses : String ,
267+ needs : List [String ] = List .empty,
216268 secrets : Option [Secrets ] = None ,
217269 params : Map [String , String ] = Map .empty,
218270 outputs : Map [String , String ] = Map .empty
219271 ): Use = new Impl (
220272 id = id,
221273 name = name,
222274 uses = uses,
275+ needs = needs,
223276 secrets = secrets,
224277 params = params,
225278 outputs = outputs
@@ -228,12 +281,14 @@ object WorkflowJob {
228281 id : String ,
229282 name : String ,
230283 uses : String ,
284+ needs : List [String ],
231285 secrets : Option [Secrets ],
232286 params : Map [String , String ],
233287 outputs : Map [String , String ]
234288 ) extends Use {
235289 override def withId (id : String ): Use = copy(id = id)
236290 override def withName (name : String ): Use = copy(name = name)
291+ override def withNeeds (needs : List [String ]): Use = copy(needs = needs)
237292 override def withUses (uses : String ): Use = copy(uses = uses)
238293 override def withSecrets (secrets : Option [Secrets ]): Use = copy(secrets = secrets)
239294 override def withParams (params : Map [String , String ]): Use = copy(params = params)
0 commit comments