Skip to content

Commit

Permalink
updates and dedup scalaworkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ThijsBroersen committed Nov 27, 2024
1 parent b2a7d1a commit 3fe9f88
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 155 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: CI
env:
JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags
'on':
workflow_dispatch: {}
release:
types:
- published
Expand Down Expand Up @@ -34,7 +35,7 @@ jobs:
with:
distribution: corretto
java-version: '17'
check-latest: 'true'
check-latest: true
- name: Cache Dependencies
uses: coursier/cache-action@v6
- name: Check all code compiles
Expand All @@ -59,7 +60,7 @@ jobs:
with:
distribution: corretto
java-version: '17'
check-latest: 'true'
check-latest: true
- name: Cache Dependencies
uses: coursier/cache-action@v6
- name: Check if the site workflow is up to date
Expand All @@ -85,7 +86,7 @@ jobs:
with:
distribution: corretto
java-version: ${{ matrix.java }}
check-latest: 'true'
check-latest: true
- name: Cache Dependencies
uses: coursier/cache-action@v6
- name: Git Checkout
Expand All @@ -111,7 +112,7 @@ jobs:
with:
distribution: corretto
java-version: '17'
check-latest: 'true'
check-latest: true
- name: Cache Dependencies
uses: coursier/cache-action@v6
- name: Generate Readme
Expand All @@ -132,17 +133,17 @@ jobs:
id: cpr
uses: peter-evans/create-pull-request@v6
with:
title: Update README.md
commit-message: Update README.md
branch: zio-sbt-website/update-readme
delete-branch: true
body: |-
Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin.
I will automatically update the README.md file whenever there is new change for README.md, e.g.
- After each release, I will update the version in the installation section.
- After any changes to the "docs/index.md" file, I will update the README.md file accordingly.
branch: zio-sbt-website/update-readme
commit-message: Update README.md
token: ${{ steps.generate-token.outputs.token }}
delete-branch: 'true'
title: Update README.md
- name: Approve PR
if: ${{ steps.cpr.outputs.pull-request-number }}
run: gh pr review "$PR_URL" --approve
Expand Down Expand Up @@ -185,7 +186,7 @@ jobs:
with:
distribution: corretto
java-version: '17'
check-latest: 'true'
check-latest: true
- name: Cache Dependencies
uses: coursier/cache-action@v6
- name: Release
Expand Down Expand Up @@ -214,7 +215,7 @@ jobs:
with:
distribution: corretto
java-version: '17'
check-latest: 'true'
check-latest: true
- name: Cache Dependencies
uses: coursier/cache-action@v6
- name: Setup NodeJs
Expand Down
1 change: 1 addition & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Dsbt.io.implicit.relative.glob.conversion=allow
2 changes: 1 addition & 1 deletion project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ object Versions {
val Scala212 = "2.12.20"
val Scala213 = "2.13.15"
val Scala3 = "3.3.4"
val zio = "2.1.9"
val zio = "2.1.13"
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.10.2
sbt.version = 1.10.5
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Build Server Plugins
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.3")
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.5")

// Linting Plugins
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
Expand Down
2 changes: 1 addition & 1 deletion zio-sbt-ci/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
libraryDependencies += "dev.zio" %% "zio" % "2.1.9"
libraryDependencies += "dev.zio" %% "zio" % "2.1.13"
libraryDependencies += "dev.zio" %% "zio-json" % "0.7.3"
libraryDependencies += "dev.zio" %% "zio-json-yaml" % "0.7.3"
2 changes: 1 addition & 1 deletion zio-sbt-ci/src/main/scala/zio/sbt/V.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object V {
Map(
"peter-evans/create-pull-request" -> "v6",
"zio/generate-github-app-token" -> "v1.0.0",
"pierotofy/set-swap-space" -> "master",
"pierotofy/set-swap-space" -> "49819abfb41bd9b44fb781159c033dba90353a7c", // 1.0,
"actions/checkout" -> "v4",
"coursier/cache-action" -> "v6",
"actions/setup-java" -> "v4",
Expand Down
98 changes: 50 additions & 48 deletions zio-sbt-ci/src/main/scala/zio/sbt/ZioSbtCiPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
val checkWebsiteBuildProcess = ciCheckWebsiteBuildProcess.value

Seq(
"build" -> JobValue(
Job(
name = "Build",
continueOnError = true,
steps = {
Expand All @@ -127,7 +127,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
val lint = Lint.value

Seq(
"lint" -> JobValue(
Job(
name = "Lint",
steps = (if (swapSizeGB > 0) Seq(setSwapSpace) else Seq.empty) ++
Seq(checkout, SetupLibuv, SetupJava(javaVersion), CacheDependencies) ++ checkGithubWorkflow.flatMap(
Expand Down Expand Up @@ -156,13 +156,13 @@ object ZioSbtCiPlugin extends AutoPlugin {
versions.contains(scalaVersion)
}.map(e => e._1 + "/test").mkString(" ")}"

"test" -> JobValue(
Job(
name = "Test",
strategy = Some(
Strategy(
matrix = Map(
"java" -> javaPlatforms.toList,
"scala" -> scalaVersionMatrix.values.flatten.toSet.toList
matrix = ListMap(
"java" -> javaPlatforms.toList.sorted,
"scala" -> scalaVersionMatrix.values.flatten.toList.distinct.sorted
),
maxParallel = matrixMaxParallel,
failFast = false
Expand Down Expand Up @@ -218,15 +218,15 @@ object ZioSbtCiPlugin extends AutoPlugin {
}

val FlattenTests =
"test" -> JobValue(
Job(
name = "Test",
strategy = Some(
Strategy(
matrix = Map(
"java" -> javaPlatforms.toList
matrix = ListMap(
"java" -> javaPlatforms.toList.sorted
) ++
(if (javaPlatformMatrix.isEmpty) {
Map("scala-project" -> scalaVersionMatrix.flatMap { case (moduleName, versions) =>
ListMap("scala-project" -> scalaVersionMatrix.flatMap { case (moduleName, versions) =>
versions.map { version =>
s"++$version $moduleName"
}
Expand Down Expand Up @@ -290,11 +290,13 @@ object ZioSbtCiPlugin extends AutoPlugin {
)

val DefaultTestStrategy =
"test" -> JobValue(
Job(
name = "Test",
strategy = Some(
Strategy(
matrix = Map("java" -> javaPlatforms.toList),
matrix = ListMap(
"java" -> javaPlatforms.toList.sorted
),
maxParallel = matrixMaxParallel,
failFast = false
)
Expand Down Expand Up @@ -322,7 +324,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
val pullRequestApprovalJobs = ciPullRequestApprovalJobs.value

Seq(
"ci" -> JobValue(
Job(
name = "ci",
needs = Some(pullRequestApprovalJobs),
steps = Seq(
Expand All @@ -344,7 +346,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
val generateReadme = GenerateReadme.value

Seq(
"update-readme" -> JobValue(
Job(
name = "Update README",
`if` = updateReadmeCondition orElse Some(Condition.Expression("github.event_name == 'push'")),
steps = (if (swapSizeGB > 0) Seq(setSwapSpace) else Seq.empty) ++
Expand All @@ -367,9 +369,9 @@ object ZioSbtCiPlugin extends AutoPlugin {
id = Some("generate-token"),
uses = Some(ActionRef(V("zio/generate-github-app-token"))),
`with` = Some(
Map(
"app_id" -> "${{ secrets.APP_ID }}",
"app_private_key" -> "${{ secrets.APP_PRIVATE_KEY }}"
ListMap(
"app_id" -> "${{ secrets.APP_ID }}".toJsonAST.right.get,
"app_private_key" -> "${{ secrets.APP_PRIVATE_KEY }}".toJsonAST.right.get
)
)
),
Expand All @@ -378,26 +380,26 @@ object ZioSbtCiPlugin extends AutoPlugin {
id = Some("cpr"),
uses = Some(ActionRef(V("peter-evans/create-pull-request"))),
`with` = Some(
Map(
"title" -> "Update README.md",
"commit-message" -> "Update README.md",
"branch" -> "zio-sbt-website/update-readme",
"delete-branch" -> "true",
ListMap(
"title" -> "Update README.md".toJsonAST.right.get,
"commit-message" -> "Update README.md".toJsonAST.right.get,
"branch" -> "zio-sbt-website/update-readme".toJsonAST.right.get,
"delete-branch" -> true.toJsonAST.right.get,
"body" ->
"""|Autogenerated changes after running the `sbt docs/generateReadme` command of the [zio-sbt-website](https://zio.dev/zio-sbt) plugin.
|
|I will automatically update the README.md file whenever there is new change for README.md, e.g.
| - After each release, I will update the version in the installation section.
| - After any changes to the "docs/index.md" file, I will update the README.md file accordingly.""".stripMargin,
"token" -> "${{ steps.generate-token.outputs.token }}"
| - After any changes to the "docs/index.md" file, I will update the README.md file accordingly.""".stripMargin.toJsonAST.right.get,
"token" -> "${{ steps.generate-token.outputs.token }}".toJsonAST.right.get
)
)
),
Step.SingleStep(
name = "Approve PR",
`if` = Some(Condition.Expression("steps.cpr.outputs.pull-request-number")),
env = Some(
Map(
ListMap(
"GITHUB_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}",
"PR_URL" -> "${{ steps.cpr.outputs.pull-request-url }}"
)
Expand All @@ -408,7 +410,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
name = "Enable Auto-Merge",
`if` = Some(Condition.Expression("steps.cpr.outputs.pull-request-number")),
env = Some(
Map(
ListMap(
"GITHUB_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}",
"PR_URL" -> "${{ steps.cpr.outputs.pull-request-url }}"
)
Expand All @@ -429,7 +431,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
val jobs = ciReleaseApprovalJobs.value

Seq(
"release" -> JobValue(
Job(
name = "Release",
needs = Some(jobs),
`if` = Some(Condition.Expression("github.event_name != 'pull_request'")),
Expand All @@ -453,7 +455,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
val publishToNpmRegistry = PublishToNpmRegistry.value

Seq(
"release-docs" -> JobValue(
Job(
name = "Release Docs",
needs = Some(Seq("release")),
`if` = Some(
Expand All @@ -472,7 +474,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
publishToNpmRegistry
)
),
"notify-docs-release" -> JobValue(
Job(
name = "Notify Docs Release",
needs = Some(Seq("release-docs")),
`if` = Some(
Expand Down Expand Up @@ -534,18 +536,18 @@ object ZioSbtCiPlugin extends AutoPlugin {
val workflow =
Workflow(
name = workflowName,
env = jvmMap ++ nodeMap,
env = Some(jvmMap ++ nodeMap),
on = Some(
Triggers(
release = Some(Triggers.Release(Seq(Triggers.ReleaseType.Published))),
push = Some(Triggers.Push(branches = Some(enabledBranches.map(Branch.Named)).filter(_.nonEmpty))),
pullRequest = Some(Triggers.PullRequest(branchesIgnore = Some(Seq(Branch.Named("gh-pages")))))
release = Some(Trigger.Release(Seq(Trigger.ReleaseType.Published))),
push = Some(Trigger.Push(branches = Some(enabledBranches.map(Branch.Named)).filter(_.nonEmpty))),
pullRequest = Some(Trigger.PullRequest(branchesIgnore = Some(Seq(Branch.Named("gh-pages")))))
)
),
jobs = ListMap.empty[
String,
JobValue
] ++ buildJobs ++ lintJobs ++ testJobs ++ updateReadmeJobs ++ reportSuccessful ++ releaseJobs ++ postReleaseJobs
jobs = ListMap(
(buildJobs ++ lintJobs ++ testJobs ++ updateReadmeJobs ++ reportSuccessful ++ releaseJobs ++ postReleaseJobs)
.map(job => job.id -> job): _*
)
)

val yaml: String = workflow.toJsonAST.flatMap(_.toYaml(yamlOptions).left.map(_.getMessage())) match {
Expand Down Expand Up @@ -645,7 +647,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
Step.SingleStep(
name = "Set Swap Space",
uses = Some(ActionRef(V("pierotofy/set-swap-space"))),
`with` = Some(Map("swap-size-gb" -> swapSizeGB.toString))
`with` = Some(ListMap("swap-size-gb" -> swapSizeGB.toString.toJsonAST.right.get))
)
}

Expand All @@ -654,7 +656,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
Step.SingleStep(
name = "Git Checkout",
uses = Some(ActionRef(V("actions/checkout"))),
`with` = Some(Map("fetch-depth" -> "0"))
`with` = Some(ListMap("fetch-depth" -> "0".toJsonAST.right.get))
)
}

Expand All @@ -667,10 +669,10 @@ object ZioSbtCiPlugin extends AutoPlugin {
name = "Setup Scala",
uses = Some(ActionRef(V("actions/setup-java"))),
`with` = Some(
Map(
"distribution" -> "corretto",
"java-version" -> version,
"check-latest" -> "true"
ListMap(
"distribution" -> "corretto".toJsonAST.right.get,
"java-version" -> version.toJsonAST.right.get,
"check-latest" -> true.toJsonAST.right.get
)
)
)
Expand Down Expand Up @@ -712,7 +714,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
name = "Release",
run = Some(prefixJobs + "sbt ci-release"),
env = Some(
Map(
ListMap(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
Expand All @@ -726,9 +728,9 @@ object ZioSbtCiPlugin extends AutoPlugin {
name = "Setup NodeJs",
uses = Some(ActionRef(V("actions/setup-node"))),
`with` = Some(
Map(
"node-version" -> "16.x",
"registry-url" -> "https://registry.npmjs.org"
ListMap(
"node-version" -> "16.x".toJsonAST.right.get,
"registry-url" -> "https://registry.npmjs.org".toJsonAST.right.get
)
)
)
Expand All @@ -742,7 +744,7 @@ object ZioSbtCiPlugin extends AutoPlugin {
Step.SingleStep(
name = "Publish Docs to NPM Registry",
run = Some(prefixJobs + s"sbt docs/${docsVersioning.npmCommand}"),
env = Some(Map("NODE_AUTH_TOKEN" -> "${{ secrets.NPM_TOKEN }}"))
env = Some(ListMap("NODE_AUTH_TOKEN" -> "${{ secrets.NPM_TOKEN }}"))
)
}

Expand Down
2 changes: 1 addition & 1 deletion zio-sbt-ecosystem/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7")
addSbtPlugin("pl.project13.scala" % "sbt-jcstress" % "0.2.0")

// Binary Compatibility Plugin
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3")
libraryDependencies += "dev.zio" %% "zio" % "2.1.13"

libraryDependencies += "dev.zio" %% "zio" % "2.1.9"
libraryDependencies += "dev.zio" %% "zio-json" % "0.7.3"
Expand Down
2 changes: 1 addition & 1 deletion zio-sbt-ecosystem/src/main/scala/zio/sbt/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object Versions {
val scala212 = "2.12.20"
val scala213 = "2.13.15"

val zioVersion = "2.1.9"
val zioVersion = "2.1.13"

lazy val betterMonadFor: ModuleID = "com.olegpy" %% "better-monadic-for" % "0.3.1"
}
Loading

0 comments on commit 3fe9f88

Please sign in to comment.