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

Detect latest versions using maven-metadata instead of parsing HTML index #282

Merged
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
8 changes: 5 additions & 3 deletions scripts/lastVersionNightly.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env -S scala-cli shebang
val regex = raw"""(?<=title=")(.+-bin-\d{8}-\w{7}-NIGHTLY)(?=/")""".r
val html = io.Source.fromURL("https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/")
val last = regex.findAllIn(html.mkString).toList.last
val regex = raw"<version>(.+-bin-\d{8}-\w{7}-NIGHTLY)</version>".r
val xml = io.Source.fromURL(
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
)
val last = regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toList.last
println(last)
8 changes: 5 additions & 3 deletions scripts/lastVersionRC.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env -S scala-cli shebang
val regex = raw"""(?<=title=")(3\.\d+\.\d+-RC\d+)(?=/")""".r
val html = io.Source.fromURL("https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/")
val last = regex.findAllIn(html.mkString).toList.last
val regex = raw"<version>(3\.\d+\.\d+-RC\d+)</version>".r
val xml = io.Source.fromURL(
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
)
val last = regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toList.last
println(last)
8 changes: 5 additions & 3 deletions scripts/lastVersionStable.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env -S scala-cli shebang
val regex = raw"""(?<=title=")(3\.\d+\.\d+)(?=/")""".r
val html = io.Source.fromURL("https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/")
val last = regex.findAllIn(html.mkString).toList.last
val regex = raw"<version>(3\.\d+\.\d+)</version>".r
val xml = io.Source.fromURL(
"https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/maven-metadata.xml"
)
val last = regex.findAllMatchIn(xml.mkString).map(_.group(1)).filter(_ != null).toList.last
println(last)
30 changes: 21 additions & 9 deletions scripts/raport-regressions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,33 @@ lazy val esClient = {
}

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

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

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