Skip to content

Commit

Permalink
Merge pull request #505 from Dwolla/validate-steward-scala-version
Browse files Browse the repository at this point in the history
omit build matrix axes when they're empty in the sbt config
  • Loading branch information
armanbilge authored May 12, 2023
2 parents 8950243 + 10018e6 commit 896088a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.17]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -201,14 +200,13 @@ jobs:
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)
- name: Publish
run: sbt '++ ${{ matrix.scala }}' tlCiRelease
run: sbt tlCiRelease

validate-steward:
name: Validate Steward Config
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.6]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -242,7 +240,6 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.17]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -296,7 +293,7 @@ jobs:
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Generate site
run: sbt '++ ${{ matrix.scala }}' docs/tlSite
run: sbt docs/tlSite

- name: Publish site
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/series/0.4'
Expand Down
2 changes: 2 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pull_request_rules:
- body~=labels:.*early-semver-minor
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@8, rootJVM)
- status-success=Build and Test (ubuntu-latest, 2.12.17, temurin@17, rootJVM)
- status-success=Validate Steward Config (ubuntu-latest, temurin@11)
- status-success=Generate Site (ubuntu-latest, temurin@8)
- '#approved-reviews-by>=1'
actions:
merge: {}
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ThisBuild / mergifyPrRules += MergifyPrRule(
MergifyAction.RequestReviews.fromUsers("armanbilge")
)
)

ThisBuild / mergifyRequiredJobs ++= Seq("validate-steward", "site")
ThisBuild / scalafixDependencies ++= Seq(
"com.github.liancheng" %% "organize-imports" % "0.6.0"
)
Expand Down
3 changes: 2 additions & 1 deletion ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ object TypelevelCiPlugin extends AutoPlugin {
UseRef.Public("coursier", "setup-action", "v1"),
Map("apps" -> "scala-steward")
) ::
WorkflowStep.Run(List(s"scala-steward validate-repo-config $config")) :: Nil
WorkflowStep.Run(List(s"scala-steward validate-repo-config $config")) :: Nil,
scalas = List.empty
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,7 @@ ${indent(rendered.mkString("\n"), 1)}"""
val body = s"""name: ${wrap(job.name)}${renderedNeeds}${renderedCond}
strategy:${renderedFailFast}
matrix:
os:${compileList(job.oses, 3)}
scala:${compileList(job.scalas, 3)}
java:${compileList(job.javas.map(_.render), 3)}${renderedMatrices}
${buildMatrix(2, "os" -> job.oses, "scala" -> job.scalas, "java" -> job.javas.map(_.render))}${renderedMatrices}
runs-on: ${runsOn}${renderedEnvironment}${renderedContainer}${renderedEnv}
steps:
${indent(job.steps.map(compileStep(_, sbt, job.sbtStepPreamble, declareShell = declareShell)).mkString("\n\n"), 1)}"""
Expand All @@ -443,6 +441,15 @@ ${indent(job.steps.map(compileStep(_, sbt, job.sbtStepPreamble, declareShell = d
s"${job.id}:\n${indent(body, 1)}"
}

private def buildMatrix(level: Int, prefixWithEntries: (String, List[String])*): String =
prefixWithEntries
.collect {
case (prefix, entries) if entries.nonEmpty =>
s"$prefix:${compileList(entries, level + 1)}"
}
.map(indent(_, level))
.mkString("\n")

def compileWorkflow(
name: String,
branches: List[String],
Expand Down Expand Up @@ -714,7 +721,8 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}
githubWorkflowPublishPostamble.value.toList,
cond = Some(publicationCond.value),
oses = githubWorkflowOSes.value.toList.take(1),
scalas = List(scalaVersion.value),
scalas = List.empty,
sbtStepPreamble = List.empty,
javas = List(githubWorkflowJavaVersions.value.head),
needs = List("build")
)).filter(_ => !githubWorkflowPublishTargetBranches.value.isEmpty)
Expand Down Expand Up @@ -878,6 +886,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}

// expand the matrix
keys
.filterNot(matrix.getOrElse(_, Nil).isEmpty)
.foldLeft(List(List.empty[String])) { (cells, key) =>
val values = matrix.getOrElse(key, Nil)
cells.flatMap { cell => values.map(v => cell ::: v :: Nil) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ object TypelevelSitePlugin extends AutoPlugin {
WorkflowJob(
"site",
"Generate Site",
scalas = List((ThisBuild / scalaVersion).value),
scalas = List.empty,
sbtStepPreamble = List.empty,
javas = List(githubWorkflowJavaVersions.value.head),
steps =
githubWorkflowJobSetup.value.toList ++ tlSiteGenerate.value ++ tlSitePublish.value
Expand Down

0 comments on commit 896088a

Please sign in to comment.