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
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: ci

on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- main
Expand Down Expand Up @@ -49,7 +53,7 @@ jobs:
distribution: 'temurin'
java-version: 17

- run: ./mill -i "__.test" + generateTutorial + generateReference && git diff --exit-code
- run: ./mill -i "__.test" && ./mill -i generateTutorial + generateReference && git diff --exit-code

check-scalafix:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .mill-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12.0
9 changes: 5 additions & 4 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $file.docs.generateDocs
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.github.lolgab::mill-mima::0.1.0`
import $ivy.`com.goyeau::mill-scalafix::0.4.0`
import $ivy.`com.goyeau::mill-scalafix::0.4.2`
import de.tobiasroeser.mill.vcs.version.VcsVersion
import com.goyeau.mill.scalafix.ScalafixModule
import mill._, scalalib._, publish._
Expand Down Expand Up @@ -67,6 +67,7 @@ trait ScalaSql extends Common{ common =>
def testFramework = "scalasql.UtestFramework"

def forkArgs = Seq("-Duser.timezone=Asia/Singapore")
def forkEnv = Map("MILL_WORKSPACE_ROOT" -> T.workspace.toString())
}

private def indent(code: Iterable[String]): String =
Expand Down Expand Up @@ -212,13 +213,13 @@ trait ScalaSql extends Common{ common =>
val generatedCodeHeader = "[//]: # (GENERATED SOURCES, DO NOT EDIT DIRECTLY)"
def generateTutorial() = T.command {
generateDocs.generateTutorial(
os.pwd / "scalasql" / "test" / "src" / "WorldSqlTests.scala",
os.pwd / "docs" / "tutorial.md"
T.workspace / "scalasql" / "test" / "src" / "WorldSqlTests.scala",
T.workspace / "docs" / "tutorial.md"
)
}
def generateReference() = T.command {
generateDocs.generateReference(
os.pwd / "docs" / "reference.md",
T.workspace / "docs" / "reference.md",
(sources, config) =>
mill.scalalib.scalafmt.ScalafmtWorkerModule
.worker()
Expand Down
8 changes: 4 additions & 4 deletions docs/generateDocs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def generateTutorial(sourcePath: os.Path, destPath: os.Path) = {
case ("", _) => outputLines.append("")

case (s"// +INCLUDE $rest", _) =>
os.read.lines(os.pwd / os.SubPath(rest)).foreach(outputLines.append)
os.read.lines(mill.api.WorkspaceRoot.workspaceRoot / os.SubPath(rest)).foreach(outputLines.append)

case (s"//$rest", false) => outputLines.append(rest.stripPrefix(" "))

Expand All @@ -49,14 +49,14 @@ def generateTutorial(sourcePath: os.Path, destPath: os.Path) = {
}
def generateReference(dest: os.Path, scalafmtCallback: (Seq[os.Path], os.Path) => Unit) = {
def dropExprPrefix(s: String) = s.split('.').drop(2).mkString(".")
val records = upickle.default.read[Seq[Record]](os.read.stream(os.pwd / "out" / "recordedTests.json"))
val suiteDescriptions = upickle.default.read[Map[String, String]](os.read.stream(os.pwd / "out" / "recordedSuiteDescriptions.json"))
val records = upickle.default.read[Seq[Record]](os.read.stream(mill.api.WorkspaceRoot.workspaceRoot / "out" / "recordedTests.json"))
val suiteDescriptions = upickle.default.read[Map[String, String]](os.read.stream(mill.api.WorkspaceRoot.workspaceRoot / "out" / "recordedSuiteDescriptions.json"))
.map{case (k, v) => (dropExprPrefix(k), v)}

val rawScalaStrs = records.flatMap(r => Seq(r.queryCodeString) ++ r.resultCodeString)
val formattedScalaStrs = {
val tmps = rawScalaStrs.map(os.temp(_, suffix = ".scala"))
scalafmtCallback(tmps, os.pwd / ".scalafmt.conf")
scalafmtCallback(tmps, mill.api.WorkspaceRoot.workspaceRoot / ".scalafmt.conf")

tmps.map(os.read(_).trim)
}
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ val dbClient = new DbClient.Connection(
)

val db = dbClient.getAutoCommitClientConnection
db.updateRaw(os.read(os.pwd / "scalasql" / "test" / "resources" / "world-schema.sql"))
db.updateRaw(os.read(os.pwd / "scalasql" / "test" / "resources" / "world-data.sql"))
db.updateRaw(os.read(os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "world-schema.sql"))
db.updateRaw(os.read(os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "world-data.sql"))

```
We use `dbClient.getAutoCommitClientConnection` in order to create a client that
Expand Down
6 changes: 4 additions & 2 deletions mill
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e

if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
DEFAULT_MILL_VERSION=0.11.11
DEFAULT_MILL_VERSION=0.11.12
fi

if [ -z "$MILL_VERSION" ] ; then
Expand Down Expand Up @@ -53,7 +53,9 @@ if [ -z "$MILL_MAIN_CLI" ] ; then
fi

MILL_FIRST_ARG=""
if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then

# first arg is a long flag for "--interactive" or starts with "-i"
if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then
# Need to preserve the first position of those listed options
MILL_FIRST_ARG=$1
shift
Expand Down
5 changes: 3 additions & 2 deletions scalasql/test/src/UtestFramework.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ class UtestFramework extends utest.runner.Framework {
}
override def teardown() = {
println("Tearing down CustomFramework " + recordedTests.size)
val workspaceRoot = os.Path(sys.env("MILL_WORKSPACE_ROOT"))
os.write.over(
os.pwd / "out" / "recordedTests.json",
workspaceRoot / "out" / "recordedTests.json",
upickle.default.write(UtestFramework.recordedTests, indent = 4)
)
os.write.over(
os.pwd / "out" / "recordedSuiteDescriptions.json",
workspaceRoot / "out" / "recordedSuiteDescriptions.json",
upickle.default.write(UtestFramework.recordedSuiteDescriptions, indent = 4)
)
recordedTests.clear()
Expand Down
4 changes: 2 additions & 2 deletions scalasql/test/src/WorldSqlTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ object WorldSqlTests extends TestSuite {
)

val db = dbClient.getAutoCommitClientConnection
db.updateRaw(os.read(os.pwd / "scalasql" / "test" / "resources" / "world-schema.sql"))
db.updateRaw(os.read(os.pwd / "scalasql" / "test" / "resources" / "world-data.sql"))
db.updateRaw(os.read(os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "world-schema.sql"))
db.updateRaw(os.read(os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "world-data.sql"))
// We use `dbClient.getAutoCommitClientConnection` in order to create a client that
// will automatically run every SQL command in a new transaction and commit it. For
// the majority of examples in this page, the exact transaction configuration doesn't
Expand Down
4 changes: 2 additions & 2 deletions scalasql/test/src/utils/TestChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class TestChecker(
val autoCommitConnection = dbClient.getAutoCommitClientConnection
def reset() = {
autoCommitConnection.updateRaw(
os.read(os.pwd / "scalasql" / "test" / "resources" / testSchemaFileName)
os.read(os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / testSchemaFileName)
)
autoCommitConnection.updateRaw(
os.read(os.pwd / "scalasql" / "test" / "resources" / testDataFileName)
os.read(os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / testDataFileName)
)
}

Expand Down
Loading