Skip to content

Commit

Permalink
Merge pull request #1308 from alexarchambault/develop
Browse files Browse the repository at this point in the history
Various minor things
  • Loading branch information
alexarchambault committed Feb 15, 2024
2 parents 92fef56 + fca49f4 commit ab45c1e
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 89 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r examples/requirements.txt --no-dependencies
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 8
Expand Down Expand Up @@ -67,7 +66,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: ${{ matrix.JDK }}
Expand All @@ -83,8 +81,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Using ubuntu-20.04 here, see https://github.com/actions/runner-images/issues/6709
OS: ["ubuntu-20.04", macos-latest, windows-latest]
OS: ["ubuntu-22.04", macos-latest, windows-latest]
steps:
- name: Don't convert LF to CRLF during checkout
if: runner.os == 'Windows'
Expand All @@ -95,7 +92,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 8
Expand All @@ -115,7 +111,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 8
Expand All @@ -129,7 +124,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 17
Expand All @@ -148,7 +142,7 @@ jobs:
- uses: coursier/setup-action@v1.3
with:
jvm: "temurin:17"
apps: scalafmt:3.0.0
apps: scalafmt
- run: scalafmt --check

publishLocal:
Expand All @@ -158,7 +152,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 8
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 8
Expand Down Expand Up @@ -48,7 +47,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 8
Expand All @@ -67,7 +65,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 8
Expand All @@ -85,7 +82,6 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1.3
with:
jvm: 17
Expand Down
14 changes: 7 additions & 7 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ class ScalaKernel(val crossScalaVersion: String) extends AlmondModule with Exter
import java.util.jar.Attributes.Name
val ver = publishVersion()
super.manifest().add(
Name.IMPLEMENTATION_TITLE.toString -> "scala-kernel",
Name.IMPLEMENTATION_VERSION.toString -> ver,
Name.SPECIFICATION_VENDOR.toString -> "sh.almond",
Name.SPECIFICATION_TITLE.toString -> "scala-kernel",
Name.IMPLEMENTATION_VENDOR_ID.toString -> "sh.almond",
Name.SPECIFICATION_VERSION.toString -> ver,
Name.IMPLEMENTATION_VENDOR.toString -> "sh.almond"
Name.IMPLEMENTATION_TITLE.toString -> "scala-kernel",
Name.IMPLEMENTATION_VERSION.toString -> ver,
Name.SPECIFICATION_VENDOR.toString -> "sh.almond",
Name.SPECIFICATION_TITLE.toString -> "scala-kernel",
"Implementation-Vendor-Id" -> "sh.almond",
"Specification-Version" -> ver,
Name.IMPLEMENTATION_VENDOR.toString -> "sh.almond"
)
}
def mainClass = Some("almond.ScalaKernel")
Expand Down
7 changes: 7 additions & 0 deletions modules/echo/src/main/scala/almond/echo/Options.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package almond.echo

import almond.kernel.install.{Options => InstallOptions}
import caseapp.{HelpMessage, Recurse}
import caseapp.core.help.Help
import caseapp.core.parser.Parser

final case class Options(
connectionFile: Option[String] = None,
Expand All @@ -11,3 +13,8 @@ final case class Options(
@Recurse
installOptions: InstallOptions = InstallOptions()
)

object Options {
implicit lazy val parser: Parser[Options] = Parser.derive
implicit lazy val help: Help[Options] = Help.derive
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ final class ScalaInterpreter(
params.autoUpdateVars,
params.useNotebookCoursierLogger,
params.silentImports,
params.initialClassLoader,
logCtx,
jupyterApi.VariableInspector.enabled,
outputDir = params.outputDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ object AmmInterpreter {
autoUpdateVars: Boolean,
useNotebookCoursierLogger: Boolean,
silentImports: Boolean,
initialClassLoader: ClassLoader,
logCtx: LoggerContext,
variableInspectorEnabled: () => Boolean,
outputDir: Either[os.Path, Boolean],
Expand Down Expand Up @@ -118,7 +117,7 @@ object AmmInterpreter {
addToreeApiCompatibilityImport && {
val loader = frames0().head.classloader
val clsOpt =
try Some(loader.loadClass("almond.toree.ToreeCompatibility$"))
try Some[Class[_]](loader.loadClass("almond.toree.ToreeCompatibility$"))
catch {
case _: ClassNotFoundException =>
None
Expand Down Expand Up @@ -312,7 +311,7 @@ object AmmInterpreter {
}
catch {
case t: Throwable =>
log.error(s"Caught exception while initializing interpreter", t)
log.error("Caught exception while initializing interpreter", t)
throw t
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ final case class Options(

object Options {

implicit val help = Help[Options]
implicit lazy val parser: Parser[Options] = Parser.derive
implicit lazy val help: Help[Options] = Help.derive
// not sure why the @ProgName annotation above isn't picked here
.withProgName("almond")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object MessageFile {
Left(e)
}

private val channelCodec: JsonValueCodec[Channel] =
private implicit val channelCodec: JsonValueCodec[Channel] =
new JsonValueCodec[Channel] {
val stringCodec: JsonValueCodec[String] = JsonCodecMaker.make
def nullValue = Channel.Requests
Expand Down
16 changes: 9 additions & 7 deletions project/settings.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ import scala.concurrent.duration._

lazy val latestTaggedVersion = os.proc("git", "describe", "--abbrev=0", "--tags", "--match", "v*")
.call().out
.trim
.trim()
lazy val buildVersion = {
val gitHead = os.proc("git", "rev-parse", "HEAD").call().out.trim
val gitHead = os.proc("git", "rev-parse", "HEAD").call().out.trim()
val maybeExactTag = scala.util.Try {
os.proc("git", "describe", "--exact-match", "--tags", "--always", gitHead)
.call().out
.trim
.trim()
.stripPrefix("v")
}
maybeExactTag.toOption.getOrElse {
val commitsSinceTaggedVersion =
os.proc('git, "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
.call().out.trim
os.proc("git", "rev-list", gitHead, "--not", latestTaggedVersion, "--count")
.call().out.trim()
.toInt
val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim
val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim()
s"${latestTaggedVersion.stripPrefix("v")}-$commitsSinceTaggedVersion-$gitHash-SNAPSHOT"
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ trait TransitiveSources extends SbtModule {
case mod => mod.sourceJar.map(Seq(_))
}().flatten
}
def transitiveSources: define.Sources = T.sources {
def transitiveSources: T[Seq[PathRef]] = T.sources {
sources() ++ T.traverse(moduleDeps) {
case mod: TransitiveSources => mod.transitiveSources
case mod => mod.sources
Expand Down Expand Up @@ -667,6 +667,8 @@ def publishSonatype(
readTimeout = timeout.toMillis.toInt,
connectTimeout = timeout.toMillis.toInt,
log = log,
workspace = os.pwd,
env = sys.env,
awaitTimeout = timeout.toMillis.toInt,
stagingRelease = isRelease
)
Expand Down
57 changes: 1 addition & 56 deletions scripts/website0/Website.sc
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,6 @@ import java.nio.file.Files

import scala.annotation.tailrec

final case class Mdoc(
inputDir: File,
outputDir: File,
scalaVersion: String,
dependencies: Seq[String] = Nil,
mdocVersion: String = "1.2.7",
mdocProps: Map[String, String] = Map()
) {

private def run0(watch: Boolean = false): Unit = {
val cmd = Seq(
"cs",
"launch",
"--scala-version",
scalaVersion,
s"org.scalameta::mdoc:$mdocVersion"
) ++ dependencies ++ Seq(
"--",
"--in",
inputDir.getAbsolutePath,
"--out",
outputDir.getAbsolutePath
) ++ mdocProps.flatMap {
case (k, v) =>
Seq(s"--site.$k", v)
} ++ {
if (watch)
Seq("--watch")
else
Seq()
}

Util.runCmd(cmd)
}

def run(yarnRunBuildIn: Option[File] = None): Unit = {
run0()
for (d <- yarnRunBuildIn)
Util.runCmd(Seq("yarn", "run", "build"), dir = d)
}
def watch(yarnRunStartIn: Option[File] = None): Unit =
yarnRunStartIn match {
case Some(d) =>
Util.withBgProcess(
Seq("yarn", "run", "start"),
dir = d,
waitFor = () => Util.waitForDir(outputDir)
) {
run0(true)
}
case None =>
run0(true)
}
}

object Util {
def waitForDir(dir: File): Unit = {

Expand Down Expand Up @@ -181,7 +126,7 @@ object Relativize {
import org.jsoup.Jsoup
import org.jsoup.nodes.Element

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

def relativize(site: Path): Unit =
Files.walkFileTree(
Expand Down

0 comments on commit ab45c1e

Please sign in to comment.