diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfed6c53..625804b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 }} diff --git a/build.sbt b/build.sbt index 59bbf601..7cbd6e22 100644 --- a/build.sbt +++ b/build.sbt @@ -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 +} diff --git a/project/GetScala3Next.scala b/project/GetScala3Next.scala new file mode 100644 index 00000000..2f39430d --- /dev/null +++ b/project/GetScala3Next.scala @@ -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() + } +}