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

Update to Java 17 #4307

Merged
merged 10 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
6 changes: 6 additions & 0 deletions .github/workflows/ci-delta-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
Comment on lines +17 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you necessarily have to do it in this PR, but here is something interesting: https://github.com/marketplace/actions/setup-java-jdk#caching-sbt-dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried it but for some reason it takes ages to recover the cache. Example: https://github.com/BlueBrain/nexus/actions/runs/6318630985/job/17158027837 It takes 2m45 to fetch the cache but doesn't speed up the actual build/tests 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw there is caching added to the release and snapshot pipelines to try it out. My suspicion is that it should work ok on the cloud runners. If it is also slow I will remove it.

- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-delta-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-delta-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-delta-static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-docs-ext-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Checkout
uses: actions/checkout@v3
- name: Review
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci-release-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'sbt'
- name: Set up proxy for docker buildx
run: |
echo http_proxy=${http_proxy} >> $GITHUB_ENV
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci-release-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'sbt'
- name: Publish To Sonatype
run: sbt -Dsbt.color=always -Dsbt.supershell=false ci-release
7 changes: 7 additions & 0 deletions .github/workflows/ci-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
cache: 'sbt'
- name: Set up proxy for docker buildx
run: |
echo http_proxy=${http_proxy} >> $GITHUB_ENV
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
check-latest: true
- name: Checkout
uses: actions/checkout@v3
with:
Expand Down
13 changes: 10 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ lazy val app = project
)
)
},
Test / javaOptions += cglibFix,
Test / fork := true,
Test / test := {
val _ = copyPlugins.value
Expand Down Expand Up @@ -913,7 +914,7 @@ lazy val compilation = {
Seq(
scalaVersion := scalaCompilerVersion,
scalacOptions ~= { options: Seq[String] => options.filterNot(Set("-Wself-implicit", "-Xlint:infer-any", "-Wnonunit-statement")) },
javaSpecificationVersion := "11",
javaSpecificationVersion := "17",
javacOptions ++= Seq(
"-source",
javaSpecificationVersion.value,
Expand Down Expand Up @@ -977,12 +978,15 @@ lazy val servicePackaging = {
else version.value
},
Docker / daemonUser := "nexus",
dockerBaseImage := "eclipse-temurin:11-jre",
dockerBaseImage := "eclipse-temurin:17-jre",
dockerBuildxPlatforms := Seq("linux/arm64/v8", "linux/amd64"),
dockerExposedPorts := Seq(8080),
dockerUsername := Some("bluebrain"),
dockerUpdateLatest := false,
dockerChmodType := DockerChmodType.UserGroupWriteExecute
dockerChmodType := DockerChmodType.UserGroupWriteExecute,
dockerEnvVars := Map(
"JAVA_OPTS" -> cglibFix
)
)
}

Expand Down Expand Up @@ -1066,3 +1070,6 @@ def unitTestsWithCoverageCommandsForModules(modules: List[String]) = {
addCommandAlias("core-unit-tests-with-coverage", unitTestsWithCoverageCommandsForModules(coreModules))
addCommandAlias("app-unit-tests-with-coverage", unitTestsWithCoverageCommandsForModules(List("app")))
addCommandAlias("plugins-unit-tests-with-coverage", unitTestsWithCoverageCommandsForModules(List("plugins")))

// This option allows distage 1.0.10 to run on JDK 17+
val cglibFix = "--add-opens=java.base/java.lang=ALL-UNNAMED"
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.slowqueries

import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.slowqueries.BlazegraphSlowQueryStoreSuite._
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.slowqueries.model.BlazegraphSlowQuery
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri
import ch.epfl.bluebrain.nexus.delta.rdf.query.SparqlQuery
import ch.epfl.bluebrain.nexus.delta.sdk.views.ViewRef
import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Identity, Label, ProjectRef}
import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie
import ch.epfl.bluebrain.nexus.testkit.IOFixedClock
import ch.epfl.bluebrain.nexus.testkit.bio.BioSuite
import ch.epfl.bluebrain.nexus.delta.sourcing.postgres.Doobie
import munit.AnyFixture

import java.time.temporal.ChronoUnit
import java.time.{Duration, Instant}
import scala.concurrent.duration.DurationInt
import BlazegraphSlowQueryStoreSuite._

class BlazegraphSlowQueryStoreSuite
extends BioSuite
Expand All @@ -31,7 +32,7 @@ class BlazegraphSlowQueryStoreSuite
SparqlQuery(""),
failed = true,
1.second,
Instant.now(),
Instant.now().truncatedTo(ChronoUnit.MILLIS),
Copy link
Contributor Author

@olivergrabinski olivergrabinski Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[The clock used by Instant.now()] is based on the best available system clock. This may use System.currentTimeMillis(), or a higher resolution clock if one is available.

https://docs.oracle.com/javase/8/docs/api/java/time/Clock.html#systemUTC--

Based on this perhaps calls to Instant.now() should be made with a specific clock, especially outside of tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in production code we are safe, as we should never be calling Instant.now() directly. In tests it's more annoying to have to use a clock.

One possible solution is to be a bit more relaxed in tests. I know that we use a fixed clock and check exact timestamps, but an alternative approach is to use a normal clock be a little more flexible. That is probably too big a change though

Perhaps there is some sort of typeclass equality that could rescue us..?

Identity.User("Ted Lasso", Label.unsafe("epfl"))
)

Expand Down Expand Up @@ -69,7 +70,7 @@ object BlazegraphSlowQueryStoreSuite {
)
}

private val Now = Instant.now()
private val Now = Instant.now().truncatedTo(ChronoUnit.MILLIS)
private val OneWeekAgo = Now.minus(Duration.ofDays(7))
private val EightDaysAgo = Now.minus(Duration.ofDays(8))
private val RecentQuery = queryAtTime(Now)
Expand Down