Skip to content

Setup CI to test on Scala 3.next #199

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

Merged
merged 1 commit into from
Oct 29, 2021
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
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: test
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
pull_request:
jobs:
test:
test: &test
strategy:
fail-fast: false
matrix:
java: [8, 11, 17]
scala: [2.13.6, 3.0.2]
runs-on: ubuntu-latest
if: ${{ github.event_name != schedule }}
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -22,4 +25,13 @@ jobs:
distribution: temurin
java-version: ${{matrix.java}}
- name: Test
run: sbt ++${{matrix.scala}} test core/headerCheck package
run: sbt "setScalaVersion ${{matrix.scala}}" test core/headerCheck package

test-rc:
<<: *test
strategy:
fail-fast: false
matrix:
java: [8]
scala: [3.next]
if: ${{ github.event_name == schedule }}
8 changes: 8 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ lazy val testmacros = project.in(file("testmacros"))
}),
publish / skip := true,
)

commands += Command.single("setScalaVersion") { (state, arg0) =>
val arg = arg0 match {
case "3.next" => GetScala3Next.get()
case _ => arg0
}
s"++$arg" :: state
}
31 changes: 31 additions & 0 deletions project/GetScala3Next.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.nio.ByteBuffer

import scala.concurrent._, duration._

import gigahorse._, support.okhttp.Gigahorse

import sjsonnew.shaded.scalajson.ast.unsafe._
import sjsonnew.support.scalajson.unsafe.{ Converter, Parser }

object GetScala3Next {
val asJson = (r: FullResponse) => Parser.parseFromByteBuffer(r.bodyAsByteBuffer).get

def get(): String = {
val req = Gigahorse.url("https://api.github.com/repos/lampepfl/dotty/releases")
.get.addQueryString("per_page" -> "1")

val http = Gigahorse.http(Gigahorse.config)

try {
val f = http.run(req, asJson)

val f2 = f.collect {
case JArray(Array(JObject(fields))) => fields.collectFirst {
case JField("tag_name", JString(version)) => version
}
}.map(_.getOrElse(sys.error(s"Expected an array of 1 string, got $j")))

Await.result(f2, 120.seconds)
} finally http.close()
}
}