Skip to content

Commit

Permalink
Merge branch 'main' into bump-scala-3.3.2-3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou authored Mar 5, 2024
2 parents e5b28d4 + 95b58dc commit 030750f
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 102 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
44 changes: 35 additions & 9 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
name: Tests
name: CI
on:
push:
branches:
- main
- 2.x
pull_request:
branches:
- main
- 2.x

# cancel older runs of a pull request;
# this will not cancel anything for normal git pushes
concurrency:
group: cancel-old-pr-runs-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
strategy:
fail-fast: false
matrix:
java-version: [8, 11]
java-version: [8, 11, 17]
scala-binary-version: [2.12, 2.13, 3]
runs-on: ubuntu-latest
steps:
Expand All @@ -23,7 +27,8 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
- run: ./mill -i unitTest "${{ matrix.scala-binary-version }}"
- run: ./mill -i -k unitTest "${{ matrix.scala-binary-version }}"

itest:
strategy:
fail-fast: false
Expand All @@ -38,12 +43,13 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
- run: ./mill -i integrationTest ${{ matrix.scala-version }}
- run: ./mill -i -k integrationTest ${{ matrix.scala-version }}

publishLocal:
strategy:
fail-fast: false
matrix:
scala-version: [2.12.18, 2.13.12, 3.2.2]
scala-version: [2.12.19, 2.13.13, 3.3.3]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -52,4 +58,24 @@ jobs:
- uses: actions/setup-java@v1
with:
java-version: 8
- run: ./mill -i __[${{ matrix.scala-version }}].__.publishLocal
- run: ./mill -i -k __[${{ matrix.scala-version }}].__.publishLocal

release:
if: github.repository == 'com-lihaoyi/Ammonite' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.x')
needs: [ test, itest, publishLocal ]
uses: ./.github/workflows/release.yml
secrets: inherit

publishDosc:
if: github.repository == 'com-lihaoyi/Ammonite' && github.ref == 'refs/heads/main'
needs: [ test, itest ]
uses: ./.github/workflows/publishDocs.yml
secrets:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

publishExecutable:
if: github.repository == 'com-lihaoyi/Ammonite' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.x')
needs: [ test, itest ]
uses: ./.github/workflows/publishExecutable.yml
secrets:
AMMONITE_BOT_AUTH_TOKEN: ${{ secrets.AMMONITE_BOT_AUTH_TOKEN }}
11 changes: 8 additions & 3 deletions .github/workflows/publishDocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Publish Docs
on:
push:
branches:
- main
# push:
# branches:
# - main
workflow_call:
secrets:
DEPLOY_KEY:
required: true

jobs:
publishDocs:
runs-on: ubuntu-latest
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/publishExecutable.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Publish Executable
on:
push:
branches:
- main
- 2.x
# push:
# branches:
# - main
# - 2.x
workflow_call:
secrets:
AMMONITE_BOT_AUTH_TOKEN:
required: true

jobs:
publishExecutable:
runs-on: ubuntu-latest
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
name: Release
on:
push:
branches:
- main
- 2.x
# push:
# branches:
# - main
# - 2.x
workflow_call:
secrets:
SONATYPE_PGP_SECRET:
required: true
SONATYPE_DEPLOY_USER:
required: true
SONATYPE_DEPLOY_PASSWORD:
required: true
SONATYPE_PGP_PASSWORD:
required: true

jobs:
release:
strategy:
matrix:
shard: [1, 2, 3, 4, 5]
shard: [ 1, 2, 3, 4, 5 ]
fail-fast: false
runs-on: ubuntu-latest
env:
Expand Down
24 changes: 24 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Newer versions won't work with Java 8!
version = "3.7.15"

align.openParenCallSite = false
align.preset = none
align.stripMargin = true

assumeStandardLibraryStripMargin = true

continuationIndent.callSite = 2
continuationIndent.defnSite = 4

docstrings.oneline = keep
docstrings.style = Asterisk
docstrings.wrap = no

maxColumn = 100

newlines.source = keep

project.git = true

runner.dialect = scala213

Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class Compiler(
"java.lang.Object.finalize"
)

blacklist(s.showFullName) ||
blacklist(s.fullName.toString) ||
s.isOneOf(Flags.GivenOrImplicit) ||
// Cache objects, which you should probably never need to
// access directly, and apart from that have annoyingly long names
Expand Down
4 changes: 2 additions & 2 deletions amm/repl/src/test/scala/ammonite/session/AdvancedTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ object AdvancedTests extends TestSuite{
check.session("""
@ // Compiler plugins imported without `.$plugin` are not loaded
@ import $ivy.`org.typelevel:::kind-projector:0.13.2`
@ import $ivy.`org.typelevel:::kind-projector:0.13.3`
@ trait TC0[F[_]]
defined trait TC0
Expand All @@ -330,7 +330,7 @@ object AdvancedTests extends TestSuite{
@ // You need to use `import $plugin.$ivy`
@ import $plugin.$ivy.`org.typelevel:::kind-projector:0.13.2`
@ import $plugin.$ivy.`org.typelevel:::kind-projector:0.13.3`
@ trait TC[F[_]]
defined trait TC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package ammonite.interp.script
import java.net.URI
import java.nio.file.Paths
import java.util.concurrent.CompletableFuture

import ch.epfl.scala.bsp4j.{Diagnostic => BDiagnostic, Position => BPosition, _}
import utest._

import scala.collection.JavaConverters._
import scala.compat.java8.FutureConverters
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}
import scala.meta.internal.semanticdb.TextDocument
import scala.util.control.NonFatal

object AmmoniteBuildServerTests extends TestSuite {

Expand Down Expand Up @@ -39,6 +39,15 @@ object AmmoniteBuildServerTests extends TestSuite {
override def utestAfterAll(): Unit =
os.remove.all(wd)

override def utestWrap(path: Seq[String], runBody: => Future[Any])(implicit
ec: ExecutionContext
): Future[Any] = {
val res = runBody
res.recover {
case NonFatal(e) => Future(s"!Test execution failed! Skipping failing BSP test: ${e}")(ec)
}(ec)
}

val tests = Tests {

"simple" - {
Expand Down
69 changes: 45 additions & 24 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import mill._, scalalib._, publish._
import mill._
import scalalib._
import publish._
import mill.contrib.bloop.Bloop
import mill.scalalib.api.ZincWorkerUtil._
import coursier.mavenRepositoryString
import $file.ci.upload

import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION`
import $ivy.`io.get-coursier::coursier-launcher:2.1.0-RC1`
import mill.define.Command
import mill.testrunner.TestRunner
import scala.util.chaining.scalaUtilChainingOps

val ghOrg = "com-lihaoyi"
val ghRepo = "Ammonite"
Expand Down Expand Up @@ -33,10 +38,10 @@ val commitsSinceTaggedVersion = {
.toInt
}

val scala2_12Versions = Seq("2.12.8", "2.12.9", "2.12.10", "2.12.11", "2.12.12", "2.12.13", "2.12.14", "2.12.15", "2.12.16", "2.12.17", "2.12.18")
val scala2_13Versions = Seq("2.13.2", "2.13.3", "2.13.4", "2.13.5", "2.13.6", "2.13.7", "2.13.8", "2.13.9", "2.13.10", "2.13.11", "2.13.12")
val scala2_12Versions = 9.to(19).map(v => s"2.12.${v}")
val scala2_13Versions = 2.to(13).map(v => s"2.13.${v}")
val scala32Versions = Seq("3.2.0", "3.2.1", "3.2.2")
val scala33Versions = Seq("3.3.0", "3.3.1", "3.3.2")
val scala33Versions = Seq("3.3.0", "3.3.1", "3.3.2", "3.3.3")
val scala34Versions = Seq("3.4.0")
val scala3Versions = scala32Versions ++ scala33Versions ++ scala34Versions

Expand Down Expand Up @@ -65,7 +70,7 @@ val (buildVersion, unstable) = scala.util.Try(

val bspVersion = "2.1.0-M5"
val fastparseVersion = "3.0.2"
val scalametaVersion = "4.8.13"
val scalametaVersion = "4.8.15"

object Deps {
val acyclic = ivy"com.lihaoyi:::acyclic:0.3.11"
Expand Down Expand Up @@ -103,8 +108,8 @@ object Deps {
val scalazCore = ivy"org.scalaz::scalaz-core:7.2.34"
val semanticDbScalac = ivy"org.scalameta:::semanticdb-scalac:$scalametaVersion"
val shapeless = ivy"com.chuusai::shapeless:2.3.3"
val slf4jNop = ivy"org.slf4j:slf4j-nop:1.7.12"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.3.0"
val slf4jNop = ivy"org.slf4j:slf4j-nop:1.7.36"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.3.1"
val sshdCore = ivy"org.apache.sshd:sshd-core:1.2.0"
val scalametaCommon = ivy"org.scalameta::common:$scalametaVersion"
val typename = ivy"org.tpolecat::typename:1.1.0"
Expand All @@ -114,7 +119,7 @@ object Deps {
else "3.1.3"
ivy"com.lihaoyi::upickle:$ver"
}
val utest = ivy"com.lihaoyi::utest:0.8.1"
val utest = ivy"com.lihaoyi::utest:0.8.2"
}

trait AmmInternalModule extends CrossSbtModule with Bloop.Module {
Expand Down Expand Up @@ -692,26 +697,42 @@ class SshdModule(val crossScalaVersion: String) extends AmmModule{
}
}

def unitTest(scalaBinaryVersion: String) = {
def cross[T <: AmmInternalModule](module: Cross[T]) =
module
.items
.reverse
.collectFirst {
case (List(key: String), mod) if key.startsWith(scalaBinaryVersion) => mod
}
.getOrElse(sys.error(s"$module doesn't have versions for $scalaBinaryVersion"))
/**
* Selects all cross module instances, that match the given predicate.
* In Mill 0.11, this can be hopefully replaced with a simple filter on the `crossValue`.
*/
def selectCrossPrefix[T <: Module, V](
crossModule: Cross[T],
predicate: String => Boolean
)(accessor: T => V): Seq[V] =
crossModule.items.collect {
case (List(key: String), mod) if predicate(key) => accessor(mod)
}
.tap { mods =>
if (mods.isEmpty) sys.error(s"No matching cross-instances found in ${crossModule}")
}

T.command{
cross(terminal).test.test()()
cross(amm.repl).test.test()()
cross(amm).test.test()()
cross(sshd).test.test()()
def unitTest(scalaBinaryVersion: String = ""): Command[Seq[(String, Seq[TestRunner.Result])]] = {
val pred = (_: String).startsWith(scalaBinaryVersion)
val tests = Seq(
selectCrossPrefix(terminal, pred)(_.test),
selectCrossPrefix(amm.repl, pred)(_.test),
selectCrossPrefix(amm, pred)(_.test),
selectCrossPrefix(sshd, pred)(_.test)
).flatten

val log = T.task { T.log.outputStream.println(s"Testing modules: ${tests.mkString(", ")}") }

T.command {
log()
T.traverse(tests)(_.testCached)()
}
}

def integrationTest(scalaVersion: String) = T.command{
integration(scalaVersion).test.test()()
def integrationTest(scalaVersion: String = "") = T.command {
T.traverse(
selectCrossPrefix(integration, _.startsWith(scalaVersion))(_.test)
)(_.testCached)()
}

def generateConstantsFile(version: String = buildVersion,
Expand Down
Loading

0 comments on commit 030750f

Please sign in to comment.