Skip to content

Commit

Permalink
Update pre-commit-config and apply to all files
Browse files Browse the repository at this point in the history
- Add scalafmt-native pre-commit hook
- Run pre-commit in github workflow
  • Loading branch information
mdedetrich authored and Jeff May committed Oct 12, 2022
1 parent 3207f40 commit 6ad21a8
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 63 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/format.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: pre-commit
on:
pull_request:
branches: ['**']

jobs:
build:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
23 changes: 13 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
repos:
- repo: https://github.com/softwaremill/scala-pre-commit-hooks
rev: v0.3.0
hooks:
- id: sbt-scalafmt
stages: [commit]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: scalafmt
name: Run scalafmt-native in Docker
files: '^.*\.s(cala)(bt)$'
types: [file]
language: docker_image
entry: scalameta/scalafmt:v3.5.9
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ newlines {
# This looks kinda gross with the rest of the format. We take strides to ensure that we chop down long parameter lists.
sometimesBeforeColonInMethodReturnType = false

implicitParamListModifierForce=[after]
implicitParamListModifierForce = [after]
}

# Prevent wrapping of docstrings so that they appear on a single line
Expand Down
27 changes: 14 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,31 @@ def commonSettings(subProject: Option[String]): Seq[Setting[_]] = {
val mimaPreviousVersion = scalaBinaryVersion(v => if (v == "3") "2.8.0" else "2.6.0")
Seq(
name := artifact.value,

mimaPreviousArtifacts := {
if (ScalaCheckAxis.current.value.scalaCheckVersion == ScalaCheckAxis.v1_16.scalaCheckVersion)
Set.empty
else
Set(organization.value %% artifact.value % mimaPreviousVersion.value)
},

mimaBinaryIssueFilters ++= Seq(
ProblemFilters.exclude[ReversedMissingMethodProblem](
"org.scalacheck.ops.time.ImplicitJavaTimeGenerators.arbOffsetDateTime"
)
),

scalacOptions ++= Seq(
// "-Xfatal-warnings", // some methods in Scala 2.13 are deprecated, but I don't want to maintain to copies of source
"-deprecation:false",
"-feature",
"-encoding", "UTF-8"
) ++ (if (scalaBinaryVersion.value == "3") Nil else Seq(
"-Xlint",
"-Ywarn-dead-code"
)),
"-encoding",
"UTF-8"
) ++ {
if (scalaBinaryVersion.value == "3") Nil
else
Seq(
"-Xlint",
"-Ywarn-dead-code"
)
},

// Allow publishing ScalaDoc by disabling link warnings
Compile / doc / scalacOptions += "--no-link-warnings",
Expand All @@ -69,22 +71,21 @@ lazy val core = projectMatrix
// default locations, overridden in custom rows where needed
Compile / sourceDirectory := (file("core") / "src" / "main").getAbsoluteFile,
Test / sourceDirectory := (file("core") / "src" / "test").getAbsoluteFile,

scalacOptions ++= (scalaVersion.value match {
case Scala_2_13 => Seq("-Ymacro-annotations")
case _ => Nil
}),

libraryDependencies ++= Seq(
izumiReflect,
tagging,
ScalaCheckAxis.current.value.scalaCheck,
newtype, // Test-only
ScalaCheckAxis.current.value.scalaTest // Test-only
) ++ (scalaVersion.value match {
case CrossVersion.PartialVersion("2", "12", _*) => Seq(
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)
)
case CrossVersion.PartialVersion("2", "12", _*) =>
Seq(
compilerPlugin(("org.scalamacros" % "paradise" % "2.1.1").cross(CrossVersion.full))
)
case _ => Nil
})
)
Expand Down
29 changes: 16 additions & 13 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@ object Dependencies {
final val Scala_2_13 = "2.13.6"
final val Scala_3 = "3.1.1"

final private val ScalaTest_2_2 = "2.2.6"
private final val ScalaTest_2_2 = "2.2.6"

// Newer versions of ScalaTest separate the scalatestplus %% scalacheck-1-X dependencies,
// but do not support ScalaCheck 1.13.x
// Once we no longer support ScalaCheck 1.13.x, we can upgrade to the latest version of
// ScalaTest and always pull in the appropriate ScalaTestPlus artifact for ScalaCheck >= 1.14
final private val ScalaTest_3_0 = "3.0.5"
final private val ScalaTest_3_2 = "3.2.9"
final private val scalaTest_3_2_14 = "3.2.14"

private def scalaTestPlusScalaCheckVersion(scalaVer: String, scalaCheckVersion: String) =
private final val ScalaTest_3_0 = "3.0.5"
private final val ScalaTest_3_2 = "3.2.9"
private final val scalaTest_3_2_14 = "3.2.14"

private def scalaTestPlusScalaCheckVersion(
scalaVer: String,
scalaCheckVersion: String
) =
(CrossVersion.partialVersion(scalaVer), scalaCheckVersion) match {
case (_, ScalaCheckAxis.v1_16.scalaCheckVersion) => "3.2.14.0"
case (Some((3, _)),_) => "3.2.10.0"
case (Some((3, _)), _) => "3.2.10.0"
case _ => "3.2.2.0"
}
}

final private val IzumiReflectVersion = "1.1.2"
final private val JodaTimeVersion = "2.10.10"
final private val NewtypeVersion = "0.4.4"
final private val TaggingVersion = "2.3.2"
private final val IzumiReflectVersion = "1.1.2"
private final val JodaTimeVersion = "2.10.10"
private final val NewtypeVersion = "0.4.4"
private final val TaggingVersion = "2.3.2"

val izumiReflect: ModuleID = "dev.zio" %% "izumi-reflect" % IzumiReflectVersion
val newtype: ModuleID = for3Use2("io.estatico" %% "newtype" % NewtypeVersion) % Test
Expand Down Expand Up @@ -69,7 +72,7 @@ object Dependencies {
val v1_16 = ScalaCheckAxis("1-16", "1.16.0", scalaTest_3_2_14, Seq(Scala_2_12, Scala_2_13, Scala_3))
}

abstract class CurrentAxis[T: ClassTag] {
abstract class CurrentAxis[T : ClassTag] {

def current: Def.Initialize[T] = Def.setting {
virtualAxes.value.collectFirst { case a: T => a }.get
Expand Down

0 comments on commit 6ad21a8

Please sign in to comment.