Skip to content

Commit

Permalink
feat(java17): use JRE17, run tests on JRE17, compile with JDK11 (#4604)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgogerly committed Nov 24, 2023
1 parent 7a95d5a commit 6118137
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 26 deletions.
29 changes: 28 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
uses: docker/setup-buildx-action@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Prepare build variables
Expand Down Expand Up @@ -72,3 +74,28 @@ jobs:
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated-ubuntu"
- name: Build and publish slim JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.java11.slim
platforms: linux/amd64,linux/arm64
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated-slim"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-slim"
- name: Build and publish ubuntu JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.java11.ubuntu
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-java11-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-ubuntu"
24 changes: 23 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ jobs:
uses: docker/setup-buildx-action@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Prepare build variables
Expand Down Expand Up @@ -51,3 +53,23 @@ jobs:
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-ubuntu"
- name: Build slim JRE 11 container image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.java11.slim
platforms: linux/amd64,linux/arm64
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11-slim"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-slim"
- name: Build ubuntu JRE 11 container image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.java11.ubuntu
platforms: linux/amd64,linux/arm64
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-java11-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-java11-ubuntu"
29 changes: 28 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ jobs:
uses: docker/setup-buildx-action@v3
- uses: actions/setup-java@v3
with:
java-version: 11
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Assemble release info
Expand Down Expand Up @@ -128,6 +130,31 @@ jobs:
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-unvalidated-ubuntu"
- name: Build and publish slim JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.java11.slim
platforms: linux/amd64,linux/arm64
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated-slim"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-slim"
- name: Build and publish ubuntu JRE 11 container image
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.java11.ubuntu
platforms: linux/amd64,linux/arm64
push: true
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-java11-unvalidated-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-java11-unvalidated-ubuntu"
- name: Create release
if: steps.release_info.outputs.SKIP_RELEASE == 'false'
uses: softprops/action-gh-release@v1
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.java11.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM alpine:3.16
LABEL maintainer="[email protected]"
RUN apk --no-cache add --update bash openjdk11-jre
RUN addgroup -S -g 10111 spinnaker
RUN adduser -S -G spinnaker -u 10111 spinnaker
COPY orca-web/build/install/orca /opt/orca
RUN mkdir -p /opt/orca/plugins && chown -R spinnaker:nogroup /opt/orca/plugins
USER spinnaker
CMD ["/opt/orca/bin/orca"]
8 changes: 8 additions & 0 deletions Dockerfile.java11.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:bionic
LABEL maintainer="[email protected]"
RUN apt-get update && apt-get -y install openjdk-11-jre-headless wget
RUN adduser --system --uid 10111 --group spinnaker
COPY orca-web/build/install/orca /opt/orca
RUN mkdir -p /opt/orca/plugins && chown -R spinnaker:nogroup /opt/orca/plugins
USER spinnaker
CMD ["/opt/orca/bin/orca"]
2 changes: 1 addition & 1 deletion Dockerfile.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:3.16
LABEL maintainer="[email protected]"
RUN apk --no-cache add --update bash openjdk11-jre
RUN apk --no-cache add --update bash openjdk17-jre
RUN addgroup -S -g 10111 spinnaker
RUN adduser -S -G spinnaker -u 10111 spinnaker
COPY orca-web/build/install/orca /opt/orca
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:bionic
LABEL maintainer="[email protected]"
RUN apt-get update && apt-get -y install openjdk-11-jre-headless wget
RUN apt-get update && apt-get -y install openjdk-17-jre-headless wget
RUN adduser --system --uid 10111 --group spinnaker
COPY orca-web/build/install/orca /opt/orca
RUN mkdir -p /opt/orca/plugins && chown -R spinnaker:nogroup /opt/orca/plugins
Expand Down
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ allprojects {

group = "io.spinnaker.orca"

tasks.withType(JavaCompile).configureEach {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(11)
}
}
tasks.withType(Test).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}

tasks.withType(JavaExec) {
if (System.getProperty('DEBUG', 'false') == 'true') {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8183'
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ fiatVersion=1.42.0
korkVersion=7.204.0
kotlinVersion=1.5.32
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx6g
spinnakerGradleVersion=8.31.0
targetJava11=true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.netflix.spinnaker.orca.kato.tasks
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution
import com.netflix.spinnaker.orca.clouddriver.model.Instance.InstanceInfo
import retrofit.converter.JacksonConverter

import java.util.concurrent.TimeUnit
import java.util.regex.Matcher
Expand Down Expand Up @@ -121,6 +122,7 @@ class JarDiffsTask implements DiffTask {

RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(address)
.setConverter(new JacksonConverter())
.setClient(new OkClient(okHttpClient))
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ import com.netflix.spinnaker.orca.clouddriver.InstanceService
import com.squareup.okhttp.OkHttpClient
import retrofit.RestAdapter
import retrofit.client.OkClient
import retrofit.converter.JacksonConverter

import static retrofit.RestAdapter.LogLevel.BASIC

@Deprecated
abstract class AbstractQuipTask implements Task {
InstanceService createInstanceService(String address) {
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(address)
.setConverter(new JacksonConverter())
.setClient(new OkClient(new OkHttpClient(retryOnConnectionFailure: false)))
.setLogLevel(BASIC)
.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DeployCloudFormationStageTest extends Specification {
cloudFormationStage.taskGraph(stage, builder)

then:
builder.graph.size == graphSize
builder.graph.size() == graphSize

where:
isChangeSet | executeChangeSet || graphSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import retrofit.client.Client
import retrofit.client.Response
import retrofit.converter.ConversionException
import retrofit.converter.GsonConverter
import retrofit.converter.JacksonConverter
import retrofit.mime.TypedString
import spock.lang.Specification
import spock.lang.Subject
Expand Down Expand Up @@ -67,6 +68,7 @@ class TargetServerGroupResolverSpec extends Specification {
new RestAdapter.Builder()
.setEndpoint("clouddriver")
.setClient(client)
.setConverter(new JacksonConverter())
.setErrorHandler(spinnakerRetrofitErrorHandler)
.build()
.create(OortService.class);
Expand Down Expand Up @@ -109,6 +111,7 @@ class TargetServerGroupResolverSpec extends Specification {
new RestAdapter.Builder()
.setEndpoint("clouddriver")
.setClient(client)
.setConverter(new JacksonConverter())
.setErrorHandler(spinnakerRetrofitErrorHandler)
.build()
.create(OortService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class TerminatingInstanceSupportSpec extends Specification {
def results = support.remainingInstances(stage)

then:
getTSGCount * cloudDriverService.getTargetServerGroup("creds", "santa-claus", "north-pole") >> [
getTSGCount * cloudDriverService.getTargetServerGroup("creds", "santa-claus", "north-pole") >> Optional.of([
new TargetServerGroup(instances: returnedInstances)
]
])
results == expected

where:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DetermineHealthProvidersTaskSpec extends Specification {

@Subject
def task = new DetermineHealthProvidersTask(
new Optional<Front50Service>(front50Service),
Optional<Front50Service>.of(front50Service),
[],
[new AmazonServerGroupCreator(), new GoogleServerGroupCreator(), new DcosServerGroupCreator()]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ShrinkClusterTaskSpec extends Specification {
1 * cloudDriverService.maybeCluster('foo', 'test', 'foo-test', 'aws') >> Optional.of(cluster)

(expectedItems ? 1 : 0) * katoService.requestOperations('aws', _) >> { p, ops ->
assert ops.size == expected.size()
assert ops.size() == expected.size()
expected.each { expect ->
assert ops.find { it.destroyServerGroup.serverGroupName == expect.name && it.destroyServerGroup.region == expect.region }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ArtifactUtilsSpec extends Specification {

then:
def artifacts = artifactUtils.getArtifacts(desired)
artifacts.size == 3
artifacts.size() == 3
artifacts.find { it.type == "1" } != null
artifacts.find { it.type == "2" } != null
artifacts.find { it.type == "extra" } != null
Expand Down Expand Up @@ -122,7 +122,7 @@ class ArtifactUtilsSpec extends Specification {

then:
def artifacts = artifactUtils.getArtifacts(desired)
artifacts.size == 1
artifacts.size() == 1
artifacts.find { it.type == "1" } != null

where:
Expand Down Expand Up @@ -168,7 +168,7 @@ class ArtifactUtilsSpec extends Specification {

then:
def artifacts = artifactUtils.getArtifacts(desired)
artifacts.size == 2
artifacts.size() == 2
artifacts.find { it.type == "1" } != null
artifacts.find { it.type == "trigger" } != null
}
Expand All @@ -192,7 +192,7 @@ class ArtifactUtilsSpec extends Specification {

then:
def artifacts = artifactUtils.getArtifacts(desired)
artifacts.size == 0
artifacts.size() == 0
}

def "should find a bound artifact from upstream stages"() {
Expand Down Expand Up @@ -281,7 +281,7 @@ class ArtifactUtilsSpec extends Specification {

then:
def artifacts = artifactUtils.getAllArtifacts(execution)
artifacts.size == 3
artifacts.size() == 3
artifacts*.type == ["2", "1", "trigger"]
}

Expand Down Expand Up @@ -324,7 +324,7 @@ class ArtifactUtilsSpec extends Specification {

then:
def artifacts = artifactUtils.getArtifactsForPipelineId(pipelineId, executionCriteria)
artifacts.size == 3
artifacts.size() == 3
artifacts*.type == ["2", "1", "trigger"]

def emptyArtifacts = artifactUtils.getArtifactsForPipelineId(pipelineId, executionTerminalCriteria)
Expand Down Expand Up @@ -362,7 +362,7 @@ class ArtifactUtilsSpec extends Specification {

then:
def artifacts = artifactUtils.getArtifactsForPipelineIdWithoutStageRef(pipelineId, "2", expectedExecutionCriteria)
artifacts.size == 2
artifacts.size() == 2
artifacts*.type == ["1", "trigger"]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class ContextParameterProcessorSpec extends Specification {
def result = contextParameterProcessor.process(source, contextParameterProcessor.buildExecutionContext(execution), true)

then:
result.deployed.size == 2
result.deployed.size() == 2
result.deployed.serverGroup == ["flex-test-v043", "flex-prestaging-v011"]
result.deployed.region == ["us-east-1", "us-west-1"]
result.deployed.ami == ["ami-06362b6e", "ami-f759b7b3"]
Expand Down Expand Up @@ -601,7 +601,7 @@ class ContextParameterProcessorSpec extends Specification {
def result = contextParameterProcessor.process(source, contextParameterProcessor.buildExecutionContext(execution), true)

then:
result.deployed.size == 2
result.deployed.size() == 2
result.deployed.serverGroup == ["flex-test-v043", "flex-prestaging-v011"]
result.deployed.region == ["us-east-1", "us-west-1"]
result.deployed.ami == ["ami-06362b6e", "ami-f759b7b3"]
Expand All @@ -612,7 +612,7 @@ class ContextParameterProcessorSpec extends Specification {
result = contextParameterProcessor.process(source, contextParameterProcessor.buildExecutionContext(execution), true)

then: 'should only consider the specified stage name/id'
result.deployed.size == 1
result.deployed.size() == 1
result.deployed.serverGroup == ["flex-test-v043"]
result.deployed.region == ["us-east-1"]
result.deployed.ami == ["ami-06362b6e"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MonitorPipelineTaskSpec extends Specification {

then:
result.outputs.containsKey("artifacts")
result.outputs["artifacts"].size == 1
result.outputs["artifacts"].size() == 1
}

def "propagates pipeline exceptions"() {
Expand Down
Loading

0 comments on commit 6118137

Please sign in to comment.