Skip to content

Commit 6bcb085

Browse files
committed
Detect latest versions using maven-metadata instead of parsing index html
1 parent 6f08b06 commit 6bcb085

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

scripts/lastVersionNightly.sc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env -S scala-cli shebang
2-
val regex = raw"""(?<=title=")(.+-bin-\d{8}-\w{7}-NIGHTLY)(?=/")""".r
3-
val html = io.Source.fromURL("https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/")
4-
val last = regex.findAllIn(html.mkString).toList.last
2+
val regex = raw"<version>(.+-bin-\d{8}-\w{7}-NIGHTLY)</version>".r
3+
val xml = io.Source.fromURL(
4+
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
5+
)
6+
val last = regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toList.last
57
println(last)

scripts/lastVersionRC.sc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env -S scala-cli shebang
2-
val regex = raw"""(?<=title=")(3\.\d+\.\d+-RC\d+)(?=/")""".r
3-
val html = io.Source.fromURL("https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/")
4-
val last = regex.findAllIn(html.mkString).toList.last
2+
val regex = raw"<version>(3\.\d+\.\d+-RC\d+)</version>".r
3+
val xml = io.Source.fromURL(
4+
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
5+
)
6+
val last = regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toList.last
57
println(last)

scripts/lastVersionStable.sc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env -S scala-cli shebang
2-
val regex = raw"""(?<=title=")(3\.\d+\.\d+)(?=/")""".r
3-
val html = io.Source.fromURL("https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/")
4-
val last = regex.findAllIn(html.mkString).toList.last
2+
val regex = raw"<version>(3\.\d+\.\d+)</version>".r
3+
val xml = io.Source.fromURL(
4+
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
5+
)
6+
val last = regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toList.last
57
println(last)

scripts/raport-regressions.scala

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,33 @@ lazy val esClient = {
5757
}
5858

5959
lazy val NightlyReleases = {
60-
val re = raw"(?<=title=$")(.+-bin-\d{8}-\w{7}-NIGHTLY)(?=/$")".r
61-
val html = Source.fromURL(
62-
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/"
60+
val regex = raw"<version>(.+-bin-\d{8}-\w{7}-NIGHTLY)</version>".r
61+
val xml = io.Source.fromURL(
62+
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
6363
)
64-
re.findAllIn(html.mkString).toVector
64+
regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toVector
6565
}
6666

6767
lazy val StableScalaVersions = {
68-
val re = raw"(?<=title=$")(\d+\.\d+\.\d+(-RC\d+)?)(?=/$")".r
69-
val html = Source.fromURL(
70-
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/"
68+
val regex = raw"<version>(\d+\.\d+\.\d+(-RC\d+)?)</version>".r
69+
val xml = io.Source.fromURL(
70+
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
7171
)
72-
re.findAllIn(html.mkString).toVector
72+
regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toVector
7373
}
74-
lazy val PreviousScalaReleases = (StableScalaVersions ++ NightlyReleases).sorted
74+
object ScalaVersionOrdering extends Ordering[String] {
75+
object StableVersion {
76+
def unapply(v: String): Option[String] =
77+
if !v.contains('-') && v.split('.').size == 3 then Some(v) else None
78+
}
79+
override def compare(x: String, y: String): Int = (x, y) match {
80+
case (StableVersion(stable), other) if other.startsWith(stable) => 1
81+
case (other, StableVersion(stable)) if other.startsWith(stable) => -1
82+
case _ => Ordering.String.compare(x, y)
83+
}
84+
}
85+
lazy val PreviousScalaReleases =
86+
(StableScalaVersions ++ NightlyReleases).sorted(using ScalaVersionOrdering)
7587

7688
// Report all community build filures for given Scala version
7789
@main def raportForScalaVersion(opts: String*) = try {

0 commit comments

Comments
 (0)