Skip to content

Commit

Permalink
Use closest previous version when looking for stable Scala versions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed May 23, 2022
1 parent 6bd5d0a commit e701bd5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
1 change: 0 additions & 1 deletion .github/release/release-procedure.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
```bash
git shortlog -sn --no-merges {old-release-tag}...{new-release-tag}
```
- [ ] Create a pull request with supported scala-versions for the new release to this repository: [Virtuslab/scala-cli-scala-versions ](https://github.com/Virtuslab/scala-cli-scala-versions)
- [ ] Update the supported scala versions for the new release in the docs:
- [ ] Scala: [scala-cli-scala-versions.md](https://github.com/VirtusLab/scala-cli/blob/main/website/docs/reference/scala-versions.md)
- [ ] Scala.js: [scala-js.md](https://github.com/VirtusLab/scala-cli/blob/main/website/docs/guides/scala-js.md#supported-scalajs-versions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ class BuildOptionsTests extends munit.FunSuite {
Some("2.13.2") -> "2.13.2"
)

val testVersion = "1.11.3"
val testPrevVersion = "1.11.1"
val testNextVersion = "1.11.5"
val testVersion = "1.11.3"
val testRightAfterVersion = "1.11.4"
val testPrevVersion = "1.11.1"
val testNextVersion = "1.11.5"
val confFile =
s"""[
| {
Expand All @@ -296,8 +297,14 @@ class BuildOptionsTests extends munit.FunSuite {
| }
|]""".stripMargin

for ((prefix, expectedScalaVersion) <- expectedScalaConfVersions)
test(s"use expected scala version from conf file, prefix: ${prefix.getOrElse("empty")}") {
for {
(testVer, testNameSuffix) <-
Seq((testVersion, "exact version"), (testRightAfterVersion, "next version"))
(prefix, expectedScalaVersion) <- expectedScalaConfVersions
}
test(
s"use expected scala version from conf file, prefix: ${prefix.getOrElse("empty")}, $testNameSuffix"
) {
TestInputs.withTmpDir("conf-scala-versions") { dirPath =>

val confFilePath = dirPath / "conf-file.json"
Expand All @@ -310,7 +317,7 @@ class BuildOptionsTests extends munit.FunSuite {
)
)

val scalaParams = options.computeScalaParams(testVersion).orThrow.getOrElse(???)
val scalaParams = options.computeScalaParams(testVer).orThrow.getOrElse(???)
val expectedScalaParams = ScalaParameters(expectedScalaVersion)

expect(scalaParams == expectedScalaParams)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ package scala.build.internal

import com.github.plokhotnyuk.jsoniter_scala.core._
import com.github.plokhotnyuk.jsoniter_scala.macros._
import coursier.core.Version

final case class StableScalaVersion(scalaCliVersion: String, supportedScalaVersions: Seq[String])
final case class StableScalaVersion(
scalaCliVersion: String,
supportedScalaVersions: Seq[String]
) {
lazy val scalaCliVersion0 = Version(scalaCliVersion)
}

object StableScalaVersion {
val seqCodec: JsonValueCodec[Seq[StableScalaVersion]] = JsonCodecMaker.make
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,13 @@ final case class BuildOptions(
// wrapped in an exception so that the current stack trace appears in the exception
throw new Exception(e)
case Right(versions) =>
versions
.find(_.scalaCliVersion == scalaCliVersion)
versions.find(_.scalaCliVersion == scalaCliVersion)
.orElse {
val scalaCliVersion0 = Version(scalaCliVersion)
versions
.filter(_.scalaCliVersion0.compareTo(scalaCliVersion0) <= 0)
.maxByOption(_.scalaCliVersion0)
}
.map(_.supportedScalaVersions)
.getOrElse {
// FIXME Log that: logger.debug(s"Couldn't find Scala CLI version $scalaCliVersion in $versions")
Expand Down

0 comments on commit e701bd5

Please sign in to comment.