Skip to content
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0

- name: Install JDK 11
uses: actions/setup-java@v5
- name: Install JDK 17
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: zulu
java-version: '11'
java-version: '17'
java-package: jdk

- name: Install SBT
uses: sbt/setup-sbt@v1
uses: sbt/setup-sbt@66fb4376e81982c7d92a4074170846fff88e2e30 # v1.5.0

- name: Cache SBT
uses: coursier/cache-action@v8
uses: coursier/cache-action@95e5b1029b6b86e7bac033ee44a0697d8a527d2d # v8.1.1
with:
extraKey: v1
extraKey: v2

- name: Lint
run: sbt --client "++${{ matrix.scala }} scalafmtCheckAll"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ jobs:
name: Publish
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Install JDK 11
uses: actions/setup-java@v5
- name: Install JDK 17
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: zulu
java-version: '11'
java-version: '17'
java-package: jdk

- name: Install SBT
uses: sbt/setup-sbt@v1
uses: sbt/setup-sbt@66fb4376e81982c7d92a4074170846fff88e2e30 # v1.5.0

- name: Cache SBT
uses: coursier/cache-action@v8
uses: coursier/cache-action@95e5b1029b6b86e7bac033ee44a0697d8a527d2d # v8.1.1
with:
extraKey: v1
extraKey: v2

- name: Release
run: sbt ci-release
Expand Down
118 changes: 43 additions & 75 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// format: off

import sbt.util.CacheImplicits.given
import xsbti.HashedVirtualFileRef

val catsVersion = "2.13.0"
val fs2Version = "3.13.0"
val zioVersion = "2.1.19"

val Scala213 = "2.13.18"
val Scala3 = "3.3.7"

inThisBuild(Seq(
organization := "io.github.guymers",
homepage := Some(url("https://github.com/guymers/ceesvee")),
licenses := List(License.MIT),
developers := List(
Developer("guymers", "Sam Guymer", "@guymers", url("https://github.com/guymers"))
),
scmInfo := Some(ScmInfo(url("https://github.com/guymers/ceesvee"), "git@github.com:guymers/ceesvee.git")),
))
val Scala3 = "3.3.8"

organization := "io.github.guymers"
homepage := Some(url("https://github.com/guymers/ceesvee"))
licenses := List(License.MIT)
developers := List(
Developer("guymers", "Sam Guymer", "@guymers", url("https://github.com/guymers"))
)
ThisBuild / scmInfo := Some(ScmInfo(url("https://github.com/guymers/ceesvee"), "git@github.com:guymers/ceesvee.git"))

lazy val commonSettings = Seq(
scalaVersion := Scala213,
Expand All @@ -26,7 +27,7 @@ lazy val commonSettings = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-release", "11",
"-release", "17",
"-unchecked",
),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
Expand Down Expand Up @@ -144,7 +145,7 @@ lazy val fs2 = module("fs2")
"dev.zio" %% "zio-interop-cats" % "23.1.0.5" % Test,
),
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) => Seq(compilerPlugin("org.typelevel" % "kind-projector" % "0.13.4" cross CrossVersion.full))
case Some((2, _)) => Seq(compilerPlugin(("org.typelevel" % "kind-projector" % "0.13.4").cross(CrossVersion.full)))
case _ => Seq.empty
}),
)
Expand Down Expand Up @@ -173,60 +174,32 @@ lazy val benchmark = proj("benchmark", None)

Global / excludeLintKeys += benchmark / Compile / compile / wartremoverErrors

lazy val testDataResourceDirectory = settingKey[File]("Directory for downloaded real-world test data files")
lazy val testDataResources = taskKey[Seq[HashedVirtualFileRef]]("Downloaded real-world test data files")

val TestCsvFiles = Map(
// https://www.stats.govt.nz/large-datasets/csv-files-for-download/
"nz-greenhouse-gas-emissions-2019.csv" -> (
"https://www.stats.govt.nz/assets/Uploads/Greenhouse-gas-emissions-industry-and-household/Greenhouse-gas-emissions-industry-and-household-Year-ended-2019/Download-data/Greenhouse-gas-emissions-industry-and-household-year-ended-2019-csv.csv",
"2561a652157c5eb8f23a7f84f3648440fe67ba8d",
),

// https://data.gov.uk/dataset/48c917d5-11a0-429f-a0db-0c5ae6ffa1c8/places-to-visit-in-causeway-coast-and-glens
"uk-causeway-coast-and-glens.csv" -> (
"https://ccgbcodni-cbcni.opendata.arcgis.com/datasets/42b6ad70a304442dbdb963974d44b433_0.csv",
"5a15f2bf5861b34f985da88b33523f18aba10c08",
),

// https://www.gov.uk/government/statistical-data-sets/price-paid-data-downloads
"uk-property-sales-price-paid-2019.csv" -> (
"http://prod.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-2019.csv",
"7c9cf6b70599b8ad54365171e5343273a5a91b04",
),
)

val TestTsvFiles = Map(
// https://data.gov.au/data/dataset/fedora-pid_csiro-66416
"cape-ivy-population-genomics.tsv" -> (
"https://data.csiro.au/dap/ws/v2/collections/66416/data/86166655",
"07ad1b72deb4cf6251713704f294483f4ffc844a",
)
)

def downloadTestFile(log: Logger, file: File, _url: String, _hash: String): Unit = {
import scala.sys.process.*

val currentHash = FileInfo.hash(file)
val expected = FileInfo.hash(file, _hash.sliding(2, 2).map(Integer.parseInt(_, 16).toByte).toArray)

if (currentHash != expected) {
file.getParentFile.mkdirs()
file.createNewFile()

log.info(s"Downloading test file: ${file.name}")
ThisBuild / testDataResourceDirectory := rootOutputDirectory.value.resolve("test-data-resources").toFile

url(_url) #> file !
ThisBuild / testDataResources := Def.cachedTask {
val converter = fileConverter.value
val s = streams.value

log.info(s"Downloaded test file: ${file.name}")

val hash = FileInfo.hash(file)
if (hash != expected) {
throw new IllegalStateException(s"Test file ${file.name} does not match expected hash")
}
val dir = (ThisBuild / testDataResourceDirectory).value
val files = TestFiles.Csv.toSeq.map { case (f, (url, hash)) =>
val file = dir / "csv" / f
TestFiles.download(s.log, file, url, hash)
file
} ++ TestFiles.Tsv.map { case (f, (url, hash)) =>
val file = dir / "tsv" / f
TestFiles.download(s.log, file, url, hash)
file
}
}

// only want to download the files once no matter how many cross Scala versions there are
def _testFilesDir(base: File) = base / "target" / "scala" / "resource_managed" / "test"
files.map { file =>
val vf = converter.toVirtualFile(file.toPath)
Def.declareOutput(vf)
vf: HashedVirtualFileRef
}
}.value

lazy val tests = proj("tests", None)
.settings(publish / skip := true)
Expand All @@ -236,20 +209,15 @@ lazy val tests = proj("tests", None)
"co.fs2" %% "fs2-io" % fs2Version % Test,
),
Test / resourceGenerators += Def.task {
val s = streams.value

val dir = _testFilesDir((Test / baseDirectory).value)
TestCsvFiles.toSeq.map { case (f, (url, hash)) =>
val file = dir / "csv" / f
downloadTestFile(s.log, file, url, hash)
file
} ++ TestTsvFiles.map { case (f, (url, hash)) =>
val file = dir / "tsv" / f
downloadTestFile(s.log, file, url, hash)
file
}
val converter = fileConverter.value
(ThisBuild / testDataResources).value.map(vf => converter.toPath(vf).toFile)
}.taskValue,
Test / managedResourceDirectories += _testFilesDir((Test / baseDirectory).value),
Test / managedResourceDirectories := Seq((ThisBuild / testDataResourceDirectory).value),
)
.dependsOn(core, fs2, zio)
.disablePlugins(MimaPlugin)

Global / excludeLintKeys ++= Set(
com.github.sbt.git.SbtGit.GitKeys.gitDescribedVersion,
com.github.sbt.git.SbtGit.GitKeys.gitUncommittedChanges,
)
55 changes: 55 additions & 0 deletions project/TestFiles.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import sbt.*

object TestFiles {

val Csv = Map(
// https://www.stats.govt.nz/large-datasets/csv-files-for-download/
"nz-greenhouse-gas-emissions-2019.csv" -> (
"https://www.stats.govt.nz/assets/Uploads/Greenhouse-gas-emissions-industry-and-household/Greenhouse-gas-emissions-industry-and-household-Year-ended-2019/Download-data/Greenhouse-gas-emissions-industry-and-household-year-ended-2019-csv.csv",
"2561a652157c5eb8f23a7f84f3648440fe67ba8d",
),

// https://data.gov.uk/dataset/48c917d5-11a0-429f-a0db-0c5ae6ffa1c8/places-to-visit-in-causeway-coast-and-glens
"uk-causeway-coast-and-glens.csv" -> (
"https://ccgbcodni-cbcni.opendata.arcgis.com/datasets/42b6ad70a304442dbdb963974d44b433_0.csv",
"5a15f2bf5861b34f985da88b33523f18aba10c08",
),

// https://www.gov.uk/government/statistical-data-sets/price-paid-data-downloads
"uk-property-sales-price-paid-2019.csv" -> (
"http://prod.publicdata.landregistry.gov.uk.s3-website-eu-west-1.amazonaws.com/pp-2019.csv",
"406fe6d20ea0ef4e21b693ac961650121e508e5e",
),
)

val Tsv = Map(
// https://github.com/schappim/australian-postcodes
"australian-postcodes.tsv" -> (
"https://raw.githubusercontent.com/schappim/australian-postcodes/refs/tags/v2026.5.27/australian-postcodes-2021-04-23.tsv",
"5a4f6888e5f5cd9b3e632b6ed63756a081e26ec1",
),
)

def download(log: Logger, file: File, _url: String, _hash: String): Unit = {
val currentHash = FileInfo.hash(file)
val expected = FileInfo.hash(file, _hash.sliding(2, 2).map(Integer.parseInt(_, 16).toByte).toArray)

if (currentHash != expected) {
file.getParentFile.mkdirs()
file.createNewFile()

log.info(s"Downloading test file: ${file.name}")

sbt.io.Using.urlInputStream(url(_url).toURL) { in =>
sbt.io.IO.transfer(in, file)
}

log.info(s"Downloaded test file: ${file.name}")

val hash = FileInfo.hash(file)
if (hash != expected) {
throw new IllegalStateException(s"Test file ${file.name} does not match expected hash")
}
}
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.12.6
sbt.version=2.0.1
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.8")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.5.6")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.1")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.6.1")

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.5")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.6")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2")

//addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.7.0")
2 changes: 1 addition & 1 deletion project/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// reload plugins; dependencyUpdates
//addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
//addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.7.0")
Loading