Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update .mill-version #143

Merged
merged 9 commits into from
Oct 24, 2024
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
21 changes: 20 additions & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,26 @@ jobs:
- name: Run tests
run: |
set -eux
./mill -i --disable-ticker __.testLocal
./mill -ikj1 --disable-ticker __.testLocal

test-examples:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '11' ]
name: Tests for Java ${{ matrix.Java }}
steps:
- uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Run tests
run: |
set -eux
./mill __.publishLocal
./mill -ikj1 --disable-ticker testExamples

publish-sonatype:
if: github.repository == 'com-lihaoyi/cask' && contains(github.ref, 'refs/tags/')
Expand Down
3 changes: 1 addition & 2 deletions .mill-version
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
0.11.11

0.12.0
198 changes: 198 additions & 0 deletions build.mill
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
package build

import mill._, scalalib._, scalajslib._, publish._
import mill.scalalib.api.ZincWorkerUtil

import $packages._
import $file.ci.upload
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.github.lolgab::mill-mima::0.0.23`
import de.tobiasroeser.mill.vcs.version.VcsVersion

val scala213 = "2.13.10"
val scala212 = "2.12.17"
val scala3 = "3.2.2"
val scalaJS = "1.13.0"
val communityBuildDottyVersion = sys.props.get("dottyVersion").toList

val scalaVersions = List(scala212, scala213, scala3) ++ communityBuildDottyVersion

trait CaskModule extends CrossScalaModule with PublishModule{
def isScala3 = ZincWorkerUtil.isScala3(crossScalaVersion)

def publishVersion = VcsVersion.vcsState().format()

def pomSettings = PomSettings(
description = artifactName(),
organization = "com.lihaoyi",
url = "https://github.com/com-lihaoyi/cask",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("com-lihaoyi", "cask"),
developers = Seq(
Developer("lihaoyi", "Li Haoyi","https://github.com/lihaoyi")
)
)
}

trait CaskMainModule extends CaskModule {
def ivyDeps = T{
Agg(
ivy"io.undertow:undertow-core:2.3.10.Final",
ivy"com.lihaoyi::upickle:3.0.0"
) ++
Agg.when(!isScala3)(ivy"org.scala-lang:scala-reflect:$crossScalaVersion")
}

def compileIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.6")
def scalacOptions = Agg.when(!isScala3)("-P:acyclic:force").toSeq
def scalacPluginIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.6")

object test extends ScalaTests with TestModule.Utest{
def ivyDeps = Agg(
ivy"com.lihaoyi::utest::0.8.1",
ivy"com.lihaoyi::requests::0.8.0"
)
}
def moduleDeps = Seq(cask.util.jvm(crossScalaVersion))
}

object cask extends Cross[CaskMainModule](scalaVersions) {
object util extends Module {
trait UtilModule extends CaskModule with PlatformScalaModule{
def ivyDeps = Agg(
ivy"com.lihaoyi::sourcecode:0.3.0",
ivy"com.lihaoyi::pprint:0.8.1",
ivy"com.lihaoyi::geny:1.0.0"
)
}

object jvm extends Cross[UtilJvmModule](scalaVersions)
trait UtilJvmModule extends UtilModule {
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.lihaoyi::castor::0.3.0",
ivy"org.java-websocket:Java-WebSocket:1.5.3"
)
}

object js extends Cross[UtilJsModule](scala213)
trait UtilJsModule extends UtilModule with ScalaJSModule {
def scalaJSVersion = scalaJS
def ivyDeps = super.ivyDeps() ++ Agg(
ivy"com.lihaoyi::castor::0.3.0",
ivy"org.scala-js::scalajs-dom::2.4.0"
)
}
}
}

trait LocalModule extends CrossScalaModule{
override def millSourcePath = super.millSourcePath / "app"
def moduleDeps = Seq(cask(crossScalaVersion))
}



def zippedExamples = T {
val vcsState = VcsVersion.vcsState()

val releaseTag = vcsState.lastTag.getOrElse("")
val label = vcsState.format()

val examples = Seq(
build.example.compress.millSourcePath,
build.example.compress2.millSourcePath,
build.example.compress3.millSourcePath,
build.example.cookies.millSourcePath,
build.example.decorated.millSourcePath,
build.example.decorated2.millSourcePath,
build.example.endpoints.millSourcePath,
build.example.formJsonPost.millSourcePath,
build.example.httpMethods.millSourcePath,
build.example.minimalApplication.millSourcePath,
build.example.minimalApplication2.millSourcePath,
build.example.redirectAbort.millSourcePath,
build.example.scalatags.millSourcePath,
build.example.staticFiles.millSourcePath,
build.example.staticFiles2.millSourcePath,
build.example.todo.millSourcePath,
build.example.todoApi.millSourcePath,
build.example.todoDb.millSourcePath,
build.example.twirl.millSourcePath,
build.example.variableRoutes.millSourcePath,
build.example.queryParams.millSourcePath,
build.example.websockets.millSourcePath,
build.example.websockets2.millSourcePath,
build.example.websockets3.millSourcePath,
build.example.websockets4.millSourcePath,
)

for (example <- examples) yield {
val f = T.ctx().dest
val last = example.last + "-" + label
os.copy(example, f / last)
os.copy(T.workspace / ".mill-version", f / last / ".mill-version")
os.write.over(f / last / "mill", os.read(T.workspace / "mill"))
os.proc("chmod", "+x", f / last / "mill").call(f / last)
os.move(f / last / "package.mill", f / last / "build.mill")
os.write.over(
f / last / "build.mill",
os.read(f / last / "build.mill")
.replaceAll("package build.*", "package build")
.replaceAll("def moduleDeps =.*", "")
.replaceAll("app =>", "")
.replaceFirst(
"object app extends.*\ntrait AppModule extends CrossScalaModule(.*)\\{",
s"object app extends ScalaModule $$1\\{\n def scalaVersion = \"${scala213}\"")
.replaceFirst(
"def ivyDeps = Agg\\[Dep\\]\\(",
"def ivyDeps = Agg(\n ivy\"com.lihaoyi::cask:" + releaseTag + "\","
)
)

os.zip(f / s"$last.zip", Seq(f / last))
PathRef(f / s"$last.zip")
}
}

def testExamples() = T.command{

for(example <- zippedExamples()){
println("Testing " + example.path.last)
val base = T.dest / example.path.baseName
os.unzip(example.path, base)
os.perms.set(base / "mill", "rwxrwxrwx")
os.write.over(
base / "build.mill",
os.read(base / "build.mill").replaceAll(
"ivy\"com.lihaoyi::cask:.*\"",
s"""ivy"com.lihaoyi::cask:${VcsVersion.vcsState().format()}""""
)
)
os.proc("./mill", "app.test").call(cwd = base, stdout = os.Inherit)
}
}

def uploadToGithub() = T.command{
val vcsState = VcsVersion.vcsState()

val authKey = T.env.apply("AMMONITE_BOT_AUTH_TOKEN")
val releaseTag = vcsState.lastTag.getOrElse("")
val label = vcsState.format()
if (releaseTag == label) {
requests.post(
"https://api.github.com/repos/com-lihaoyi/cask/releases",
data = ujson.write(
ujson.Obj(
"tag_name" -> releaseTag,
"name" -> releaseTag
)
),
headers = Seq("Authorization" -> s"token $authKey")
)
}

for(example <- zippedExamples()){

upload.apply(example.path, releaseTag, example.path.last, authKey)
}
}
Loading
Loading