Skip to content

Commit

Permalink
Merge pull request #310 from armanbilge/merge/0.4-main
Browse files Browse the repository at this point in the history
Merge 0.4 -> main
  • Loading branch information
armanbilge authored Jun 19, 2022
2 parents 2ee19cb + 696418d commit 6b3cf98
Show file tree
Hide file tree
Showing 28 changed files with 296 additions and 73 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ name: Continuous Integration

on:
pull_request:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
push:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
tags: [v*]

env:
Expand All @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.15]
scala: [2.12.16]
java: [temurin@8]
project: [sbt-typelevelJVM]
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -71,6 +71,10 @@ jobs:
- name: Test
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test

- name: Check scalafix lints
if: matrix.java == 'temurin@8'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'scalafixAll --check'

- name: Check binary compatibility
if: matrix.java == 'temurin@8'
run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues
Expand All @@ -81,11 +85,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p github/target github-actions/target kernel/target versioning/target ci-release/target .jvm/target mdocs/target site/target ci-signing/target mergify/target unidoc/target .native/target mima/target no-publish/target sonatype/target ci/target sonatype-ci-release/target core/target settings/target target .js/target project/target
run: mkdir -p github/target github-actions/target kernel/target versioning/target ci-release/target scalafix/target .jvm/target mdocs/target site/target ci-signing/target mergify/target unidoc/target .native/target mima/target no-publish/target sonatype/target ci/target sonatype-ci-release/target core/target settings/target target .js/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar github/target github-actions/target kernel/target versioning/target ci-release/target .jvm/target mdocs/target site/target ci-signing/target mergify/target unidoc/target .native/target mima/target no-publish/target sonatype/target ci/target sonatype-ci-release/target core/target settings/target target .js/target project/target
run: tar cf targets.tar github/target github-actions/target kernel/target versioning/target ci-release/target scalafix/target .jvm/target mdocs/target site/target ci-signing/target mergify/target unidoc/target .native/target mima/target no-publish/target sonatype/target ci/target sonatype-ci-release/target core/target settings/target target .js/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand All @@ -101,7 +105,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.15]
scala: [2.12.16]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -138,12 +142,12 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.15, sbt-typelevelJVM)
- name: Download target directories (2.12.16, sbt-typelevelJVM)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-sbt-typelevelJVM
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.16-sbt-typelevelJVM

- name: Inflate target directories (2.12.15, sbt-typelevelJVM)
- name: Inflate target directories (2.12.16, sbt-typelevelJVM)
run: |
tar xf targets.tar
rm targets.tar
Expand Down Expand Up @@ -177,7 +181,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.15]
scala: [2.12.16]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down
10 changes: 9 additions & 1 deletion .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pull_request_rules:
- or:
- body~=labels:.*early-semver-patch
- body~=labels:.*early-semver-minor
- status-success=Build and Test (ubuntu-latest, 2.12.15, temurin@8, sbt-typelevelJVM)
- status-success=Build and Test (ubuntu-latest, 2.12.16, temurin@8, sbt-typelevelJVM)
- '#approved-reviews-by>=1'
actions:
merge: {}
Expand Down Expand Up @@ -112,6 +112,14 @@ pull_request_rules:
add:
- no-publish
remove: []
- name: Label scalafix PRs
conditions:
- files~=^scalafix/
actions:
label:
add:
- scalafix
remove: []
- name: Label settings PRs
conditions:
- files~=^settings/
Expand Down
3 changes: 3 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules = [
OrganizeImports
]
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.5.2
version = 3.5.8

runner.dialect = scala212source3

Expand Down
15 changes: 14 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "sbt-typelevel"

ThisBuild / tlBaseVersion := "0.5"
ThisBuild / tlSitePublishBranch := Some("series/0.4")
ThisBuild / crossScalaVersions := Seq("2.12.15")
ThisBuild / crossScalaVersions := Seq("2.12.16")
ThisBuild / developers ++= List(
tlGitHubDev("armanbilge", "Arman Bilge"),
tlGitHubDev("rossabaker", "Ross A. Baker"),
Expand All @@ -14,6 +14,10 @@ ThisBuild / mergifyStewardConfig ~= { _.map(_.copy(mergeMinors = true)) }
ThisBuild / mergifySuccessConditions += MergifyCondition.Custom("#approved-reviews-by>=1")
ThisBuild / mergifyLabelPaths += { "docs" -> file("docs") }

ThisBuild / scalafixDependencies ++= Seq(
"com.github.liancheng" %% "organize-imports" % "0.6.0"
)

lazy val `sbt-typelevel` = tlCrossRootProject.aggregate(
kernel,
noPublish,
Expand All @@ -24,6 +28,7 @@ lazy val `sbt-typelevel` = tlCrossRootProject.aggregate(
versioning,
mima,
sonatype,
scalafix,
ciSigning,
sonatypeCiRelease,
ci,
Expand Down Expand Up @@ -104,6 +109,14 @@ lazy val sonatype = project
)
.dependsOn(kernel)

lazy val scalafix = project
.in(file("scalafix"))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-typelevel-scalafix",
tlVersionIntroduced := Map("2.12" -> "0.4.10")
)

lazy val ciSigning = project
.in(file("ci-signing"))
.enablePlugins(SbtPlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
package org.typelevel.sbt

import io.crashbox.gpg.SbtGpg
import sbt._, Keys._
import org.typelevel.sbt.gha.GenerativePlugin
import org.typelevel.sbt.gha.GitHubActionsPlugin
import org.typelevel.sbt.gha.GenerativePlugin.autoImport._
import org.typelevel.sbt.gha.GitHubActionsPlugin
import sbt._

import Keys._

object TypelevelCiSigningPlugin extends AutoPlugin {

Expand Down
2 changes: 1 addition & 1 deletion ci/src/main/scala/org/typelevel/sbt/CrossRootProject.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package org.typelevel.sbt

import sbt._
import org.typelevel.sbt.gha.GenerativePlugin.autoImport._
import sbt._

/**
* Simultaneously creates a root project, a Scala JVM aggregate project, a Scala.js aggregate
Expand Down
108 changes: 93 additions & 15 deletions ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package org.typelevel.sbt

import sbt._
import com.typesafe.tools.mima.plugin.MimaPlugin
import org.typelevel.sbt.gha.GenerativePlugin
import org.typelevel.sbt.gha.GitHubActionsPlugin
import org.typelevel.sbt.gha.GenerativePlugin.autoImport._
import com.typesafe.tools.mima.plugin.MimaPlugin
import org.typelevel.sbt.gha.GitHubActionsPlugin
import sbt._

import scala.language.experimental.macros

object TypelevelCiPlugin extends AutoPlugin {
Expand All @@ -30,23 +31,100 @@ object TypelevelCiPlugin extends AutoPlugin {

object autoImport {
def tlCrossRootProject: CrossRootProject = macro CrossRootProjectMacros.crossRootProjectImpl

lazy val tlCiHeaderCheck =
settingKey[Boolean]("Whether to do header check in CI (default: false)")
lazy val tlCiScalafmtCheck =
settingKey[Boolean]("Whether to do scalafmt check in CI (default: false)")
lazy val tlCiScalafixCheck =
settingKey[Boolean]("Whether to do scalafix check in CI (default: false)")
lazy val tlCiMimaBinaryIssueCheck =
settingKey[Boolean]("Whether to do MiMa binary issues check in CI (default: true)")
lazy val tlCiDocCheck =
settingKey[Boolean]("Whether to build API docs in CI (default: true)")
}

import autoImport._

override def buildSettings = Seq(
tlCiHeaderCheck := false,
tlCiScalafmtCheck := false,
tlCiScalafixCheck := false,
tlCiMimaBinaryIssueCheck := true,
tlCiDocCheck := true,
githubWorkflowTargetBranches ++= Seq(
"!update/**", // ignore steward branches
"!pr/**" // escape-hatch to disable ci on a branch
),
githubWorkflowPublishTargetBranches := Seq(),
githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("test"), name = Some("Test")),
WorkflowStep.Sbt(
List("mimaReportBinaryIssues"),
name = Some("Check binary compatibility"),
cond = Some(primaryJavaCond.value)
),
WorkflowStep.Sbt(
List("doc"),
name = Some("Generate API documentation"),
cond = Some(primaryJavaCond.value)
githubWorkflowBuild := {

val style = (tlCiHeaderCheck.value, tlCiScalafmtCheck.value) match {
case (true, true) => // headers + formatting
List(
WorkflowStep.Sbt(
List("headerCheckAll", "scalafmtCheckAll", "project /", "scalafmtSbtCheck"),
name = Some("Check headers and formatting"),
cond = Some(primaryJavaCond.value)
)
)
case (true, false) => // headers
List(
WorkflowStep.Sbt(
List("headerCheckAll"),
name = Some("Check headers"),
cond = Some(primaryJavaCond.value)
)
)
case (false, true) => // formatting
List(
WorkflowStep.Sbt(
List("scalafmtCheckAll", "project /", "scalafmtSbtCheck"),
name = Some("Check formatting"),
cond = Some(primaryJavaCond.value)
)
)
case (false, false) => Nil // nada
}

val test = List(
WorkflowStep.Sbt(List("test"), name = Some("Test"))
)
),

val scalafix =
if (tlCiScalafixCheck.value)
List(
WorkflowStep.Sbt(
List("scalafixAll --check"),
name = Some("Check scalafix lints"),
cond = Some(primaryJavaCond.value)
)
)
else Nil

val mima =
if (tlCiMimaBinaryIssueCheck.value)
List(
WorkflowStep.Sbt(
List("mimaReportBinaryIssues"),
name = Some("Check binary compatibility"),
cond = Some(primaryJavaCond.value)
))
else Nil

val doc =
if (tlCiDocCheck.value)
List(
WorkflowStep.Sbt(
List("doc"),
name = Some("Generate API documentation"),
cond = Some(primaryJavaCond.value)
)
)
else Nil

style ++ test ++ scalafix ++ mima ++ doc
},
githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"))
)

Expand Down
20 changes: 11 additions & 9 deletions core/src/main/scala/org/typelevel/sbt/TypelevelPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@

package org.typelevel.sbt

import sbt._, Keys._
import de.heikoseeberger.sbtheader.HeaderPlugin
import org.typelevel.sbt.gha.GenerativePlugin
import org.typelevel.sbt.gha.GitHubActionsPlugin
import de.heikoseeberger.sbtheader.HeaderPlugin
import sbt._

import scala.collection.immutable

import Keys._

/**
* The [[TypelevelPlugin]] brings together the [[TypelevelCiReleasePlugin]] and the
* [[TypelevelSettingsPlugin]]
*/
object TypelevelPlugin extends AutoPlugin {

override def requires =
Expand All @@ -41,6 +47,7 @@ object TypelevelPlugin extends AutoPlugin {

import autoImport._
import TypelevelKernelPlugin.mkCommand
import TypelevelCiPlugin.autoImport._
import TypelevelSettingsPlugin.autoImport._
import TypelevelSonatypeCiReleasePlugin.autoImport._
import GenerativePlugin.autoImport._
Expand All @@ -62,6 +69,8 @@ object TypelevelPlugin extends AutoPlugin {
},
startYear := Some(java.time.YearMonth.now().getYear()),
licenses += "Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.txt"),
tlCiHeaderCheck := true,
tlCiScalafmtCheck := true,
tlCiReleaseBranches := Seq("main"),
Def.derive(tlFatalWarnings := (tlFatalWarningsInCi.value && githubIsWorkflowBuild.value)),
githubWorkflowBuildMatrixExclusions ++= {
Expand All @@ -70,13 +79,6 @@ object TypelevelPlugin extends AutoPlugin {
scala <- githubWorkflowScalaVersions.value.filterNot(_ == defaultScala)
java <- githubWorkflowJavaVersions.value.tail // default java is head
} yield MatrixExclude(Map("scala" -> scala, "java" -> java.render))
},
githubWorkflowBuild := {
WorkflowStep.Sbt(
List("headerCheckAll", "scalafmtCheckAll", "project /", "scalafmtSbtCheck"),
name = Some("Check headers and formatting"),
cond = Some(primaryJavaCond.value)
) +: githubWorkflowBuild.value
}
) ++ addCommandAlias(
"prePR",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

package org.typelevel.sbt.gha

import sbt._, Keys._
import sbt.io.Using

import org.yaml.snakeyaml.Yaml
import sbt._
import sbt.io.Using

import scala.collection.JavaConverters._

import Keys._

object GitHubActionsPlugin extends AutoPlugin {

override def requires = plugins.JvmPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

package org.typelevel.sbt

import sbt._, Keys._
import sbt._

import scala.util.Try

import Keys._

object TypelevelGitHubPlugin extends AutoPlugin {

override def trigger = allRequirements
Expand Down
Loading

0 comments on commit 6b3cf98

Please sign in to comment.