Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more with*, update*, and add* for Workflow step and jobs. #732

Merged
merged 7 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions github-actions/mima.sbt
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import com.typesafe.tools.mima.core._
mimaBinaryIssueFilters ++= Seq(
"org.typelevel.sbt.gha.WorkflowJob.withId",
"org.typelevel.sbt.gha.WorkflowJob.withName",
"org.typelevel.sbt.gha.WorkflowJob.withSteps",
"org.typelevel.sbt.gha.WorkflowJob.withSbtStepPreamble",
"org.typelevel.sbt.gha.WorkflowJob.withCond",
"org.typelevel.sbt.gha.WorkflowJob.withPermissions",
"org.typelevel.sbt.gha.WorkflowJob.withEnv",
"org.typelevel.sbt.gha.WorkflowJob.withOses",
"org.typelevel.sbt.gha.WorkflowJob.withScalas",
"org.typelevel.sbt.gha.WorkflowJob.withJavas",
"org.typelevel.sbt.gha.WorkflowJob.withNeeds",
"org.typelevel.sbt.gha.WorkflowJob.withMatrixFailFast",
"org.typelevel.sbt.gha.WorkflowJob.withMatrixAdds",
"org.typelevel.sbt.gha.WorkflowJob.withMatrixIncs",
"org.typelevel.sbt.gha.WorkflowJob.withMatrixExcs",
"org.typelevel.sbt.gha.WorkflowJob.withRunsOnExtraLabels",
"org.typelevel.sbt.gha.WorkflowJob.withContainer",
"org.typelevel.sbt.gha.WorkflowJob.withEnvironment",
"org.typelevel.sbt.gha.WorkflowJob.withConcurrency",
"org.typelevel.sbt.gha.WorkflowJob.withTimeoutMinutes"
"org.typelevel.sbt.gha.WorkflowJob.*",
"org.typelevel.sbt.gha.WorkflowStep.**",
"org.typelevel.sbt.gha.WorkflowStep#Sbt.*",
"org.typelevel.sbt.gha.WorkflowStep#Run.*",
"org.typelevel.sbt.gha.WorkflowStep#Use.*"
).map(ProblemFilters.exclude[ReversedMissingMethodProblem](_))
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ sealed abstract class WorkflowJob {
def withEnvironment(environment: Option[JobEnvironment]): WorkflowJob
def withConcurrency(concurrency: Option[Concurrency]): WorkflowJob
def withTimeoutMinutes(timeoutMinutes: Option[Int]): WorkflowJob

def updatedEnv(name: String, value: String): WorkflowJob
def concatEnv(envs: TraversableOnce[(String, String)]): WorkflowJob
def appendedStep(step: WorkflowStep): WorkflowJob
def concatSteps(suffixSteps: TraversableOnce[WorkflowStep]): WorkflowJob
}

object WorkflowJob {
Expand Down Expand Up @@ -149,6 +154,11 @@ object WorkflowJob {
override def withEnvironment(environment: Option[JobEnvironment]): WorkflowJob = copy(environment = environment)
override def withConcurrency(concurrency: Option[Concurrency]): WorkflowJob = copy(concurrency = concurrency)
override def withTimeoutMinutes(timeoutMinutes: Option[Int]): WorkflowJob = copy(timeoutMinutes = timeoutMinutes)

def updatedEnv(name: String, value: String): WorkflowJob = copy(env = env.updated(name, value))
def concatEnv(envs: TraversableOnce[(String, String)]): WorkflowJob = copy(env = this.env ++ envs)
def appendedStep(step: WorkflowStep): WorkflowJob = copy(steps = this.steps :+ step)
def concatSteps(suffixSteps: TraversableOnce[WorkflowStep]): WorkflowJob = copy(steps = this.steps ++ suffixSteps)
// scalafmt: { maxColumn = 96 }

override def productPrefix = "WorkflowJob"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ sealed abstract class WorkflowStep extends Product with Serializable {
def withCond(cond: Option[String]): WorkflowStep
def withEnv(env: Map[String, String]): WorkflowStep
def withTimeoutMinutes(minutes: Option[Int]): WorkflowStep

def updatedEnv(name: String, value: String): WorkflowStep
def concatEnv(env: TraversableOnce[(String, String)]): WorkflowStep
}

object WorkflowStep {
Expand Down Expand Up @@ -118,6 +121,15 @@ object WorkflowStep {
def commands: List[String]
def params: Map[String, String]
def workingDirectory: Option[String]

def withCommands(commands: List[String]): Run
def withParams(params: Map[String, String]): Run
def withWorkingDirectory(workingDirectory: Option[String]): Run

def updatedEnv(name: String, value: String): Run
def concatEnv(env: TraversableOnce[(String, String)]): Run
def updatedParams(name: String, value: String): Run
def concatParams(params: TraversableOnce[(String, String)]): Run
}

object Run {
Expand All @@ -143,18 +155,38 @@ object WorkflowStep {
workingDirectory: Option[String])
extends Run {
override def productPrefix = "Run"
// scalafmt: { maxColumn = 200 }
def withId(id: Option[String]) = copy(id = id)
def withName(name: Option[String]) = copy(name = name)
def withCond(cond: Option[String]) = copy(cond = cond)
def withEnv(env: Map[String, String]) = copy(env = env)
def withTimeoutMinutes(minutes: Option[Int]) = copy(timeoutMinutes = minutes)

def withCommands(commands: List[String]) = copy(commands = commands)
def withParams(params: Map[String, String]) = copy(params = params)
def withWorkingDirectory(workingDirectory: Option[String]) = copy(workingDirectory = workingDirectory)

def updatedEnv(name: String, value: String) = copy(env = this.env.updated(name, value))
def concatEnv(env: TraversableOnce[(String, String)]) = copy(env = this.env ++ env)
def updatedParams(name: String, value: String) = copy(params = this.params.updated(name, value))
def concatParams(params: TraversableOnce[(String, String)]) = copy(params = this.params ++ params)
// scalafmt: { maxColumn = 96 }
}
}

sealed abstract class Sbt extends WorkflowStep {
def commands: List[String]
def params: Map[String, String]
def preamble: Boolean

def withCommands(commands: List[String]): Sbt
def withParams(params: Map[String, String]): Sbt
def withPreamble(preamble: Boolean): Sbt

def updatedEnv(name: String, value: String): Sbt
def concatEnv(env: TraversableOnce[(String, String)]): Sbt
def updatedParams(name: String, value: String): Sbt
def concatParams(params: TraversableOnce[(String, String)]): Sbt
}

object Sbt {
Expand All @@ -180,17 +212,36 @@ object WorkflowStep {
preamble: Boolean)
extends Sbt {
override def productPrefix = "Sbt"
// scalafmt: { maxColumn = 200 }
def withId(id: Option[String]) = copy(id = id)
def withName(name: Option[String]) = copy(name = name)
def withCond(cond: Option[String]) = copy(cond = cond)
def withEnv(env: Map[String, String]) = copy(env = env)
def withTimeoutMinutes(minutes: Option[Int]) = copy(timeoutMinutes = minutes)

def withCommands(commands: List[String]) = copy(commands = commands)
def withParams(params: Map[String, String]) = copy(params = params)
def withPreamble(preamble: Boolean) = copy(preamble = preamble)

def updatedEnv(name: String, value: String) = copy(env = this.env.updated(name, value))
def concatEnv(env: TraversableOnce[(String, String)]) = copy(env = this.env ++ env)
def updatedParams(name: String, value: String) = copy(params = params.updated(name, value))
def concatParams(params: TraversableOnce[(String, String)]) = copy(params = this.params ++ params)
// scalafmt: { maxColumn = 96 }
}
}

sealed abstract class Use extends WorkflowStep {
def ref: UseRef
def params: Map[String, String]

def withRef(ref: UseRef): Use
def withParams(params: Map[String, String]): Use

def updatedEnv(name: String, value: String): Use
def concatEnv(env: TraversableOnce[(String, String)]): Use
def updatedParams(name: String, value: String): Use
def concatParams(params: TraversableOnce[(String, String)]): Use
}

object Use {
Expand All @@ -215,11 +266,21 @@ object WorkflowStep {
timeoutMinutes: Option[Int])
extends Use {
override def productPrefix = "Use"
// scalafmt: { maxColumn = 200 }
def withId(id: Option[String]) = copy(id = id)
def withName(name: Option[String]) = copy(name = name)
def withCond(cond: Option[String]) = copy(cond = cond)
def withEnv(env: Map[String, String]) = copy(env = env)
def withTimeoutMinutes(minutes: Option[Int]) = copy(timeoutMinutes = minutes)

def withRef(ref: UseRef) = copy(ref = ref)
def withParams(params: Map[String, String]) = copy(params = params)

def updatedEnv(name: String, value: String) = copy(env = this.env.updated(name, value))
def concatEnv(env: TraversableOnce[(String, String)]) = copy(env = this.env ++ env)
def updatedParams(name: String, value: String) = copy(params = params.updated(name, value))
def concatParams(params: TraversableOnce[(String, String)]) = copy(params = this.params ++ params)
// scalafmt: { maxColumn = 96 }
}
}
}
Loading