From a1f42dad29f042a31e89270bbd386946847c3196 Mon Sep 17 00:00:00 2001 From: mattgogerly Date: Tue, 26 Sep 2023 18:32:53 +0100 Subject: [PATCH] feat(java17): build JRE 17 images, run tests with JRE 17 --- .github/workflows/build.yml | 29 ++++++++++++++++++- .github/workflows/pr.yml | 24 ++++++++++++++- .github/workflows/release.yml | 29 ++++++++++++++++++- Dockerfile.java11.slim | 8 +++++ Dockerfile.java11.ubuntu | 8 +++++ Dockerfile.slim | 2 +- Dockerfile.ubuntu | 2 +- build.gradle | 13 ++++++++- ...SlackInteractiveNotificationService.groovy | 2 +- .../ManualJudgmentTemplateTest.groovy | 6 ++-- .../echo/slack/SlackServiceSpec.groovy | 2 +- echo-web/config/echo.yml | 5 ++++ 12 files changed, 119 insertions(+), 11 deletions(-) create mode 100644 Dockerfile.java11.slim create mode 100644 Dockerfile.java11.ubuntu diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b30b3a666..9e57d1bd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,9 @@ jobs: uses: docker/setup-buildx-action@v2 - uses: actions/setup-java@v3 with: - java-version: 11 + java-version: | + 17 + 11 distribution: 'zulu' cache: 'gradle' - name: Prepare build variables @@ -71,3 +73,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@v4 + 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@v4 + 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" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e17a1903a..c10a1b585 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,7 +19,9 @@ jobs: uses: docker/setup-buildx-action@v2 - uses: actions/setup-java@v3 with: - java-version: 11 + java-version: | + 17 + 11 distribution: 'zulu' cache: 'gradle' - name: Prepare build variables @@ -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@v4 + 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@v4 + 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" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88bd689cb..0b2a1b70a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,9 @@ jobs: uses: docker/setup-buildx-action@v2 - uses: actions/setup-java@v3 with: - java-version: 11 + java-version: | + 17 + 11 distribution: 'zulu' cache: 'gradle' - name: Assemble release info @@ -108,6 +110,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@v4 + 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@v4 + 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 diff --git a/Dockerfile.java11.slim b/Dockerfile.java11.slim new file mode 100644 index 000000000..d5c7e4530 --- /dev/null +++ b/Dockerfile.java11.slim @@ -0,0 +1,8 @@ +# Not using the alpine image because it lacks a package gRPC needed to establish pub/sub listeners. +FROM openjdk:11 +LABEL maintainer="sig-platform@spinnaker.io" +RUN adduser --system --uid 10111 --group spinnaker +COPY echo-web/build/install/echo /opt/echo +RUN mkdir -p /opt/echo/plugins && chown -R spinnaker:nogroup /opt/echo/plugins +USER spinnaker +CMD ["/opt/echo/bin/echo"] diff --git a/Dockerfile.java11.ubuntu b/Dockerfile.java11.ubuntu new file mode 100644 index 000000000..a75c0b55a --- /dev/null +++ b/Dockerfile.java11.ubuntu @@ -0,0 +1,8 @@ +FROM ubuntu:bionic +LABEL maintainer="sig-platform@spinnaker.io" +RUN apt-get update && apt-get -y install openjdk-11-jre-headless wget +RUN adduser --system --uid 10111 --group spinnaker +COPY echo-web/build/install/echo /opt/echo +RUN mkdir -p /opt/echo/plugins && chown -R spinnaker:nogroup /opt/echo/plugins +USER spinnaker +CMD ["/opt/echo/bin/echo"] diff --git a/Dockerfile.slim b/Dockerfile.slim index d5c7e4530..9a7c78829 100644 --- a/Dockerfile.slim +++ b/Dockerfile.slim @@ -1,5 +1,5 @@ # Not using the alpine image because it lacks a package gRPC needed to establish pub/sub listeners. -FROM openjdk:11 +FROM openjdk:17 LABEL maintainer="sig-platform@spinnaker.io" RUN adduser --system --uid 10111 --group spinnaker COPY echo-web/build/install/echo /opt/echo diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index a75c0b55a..76920158a 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -1,6 +1,6 @@ FROM ubuntu:bionic LABEL maintainer="sig-platform@spinnaker.io" -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 echo-web/build/install/echo /opt/echo RUN mkdir -p /opt/echo/plugins && chown -R spinnaker:nogroup /opt/echo/plugins diff --git a/build.gradle b/build.gradle index 34d99a96e..f46e3e71f 100644 --- a/build.gradle +++ b/build.gradle @@ -48,6 +48,17 @@ subprojects { } } + 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=8189' @@ -57,7 +68,7 @@ subprojects { if (name != "echo-bom" && name != "echo-api") { jacoco { - toolVersion = '0.8.3' + toolVersion = '0.8.7' } dependencies { diff --git a/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/slack/SlackInteractiveNotificationService.groovy b/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/slack/SlackInteractiveNotificationService.groovy index 05a92e296..87a71b636 100644 --- a/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/slack/SlackInteractiveNotificationService.groovy +++ b/echo-notifications/src/main/groovy/com/netflix/spinnaker/echo/slack/SlackInteractiveNotificationService.groovy @@ -105,7 +105,7 @@ class SlackInteractiveNotificationService extends SlackNotificationService imple Map payload = parseSlackPayload(request.getBody()) log.debug("Received callback event from Slack of type ${payload.type}") - if (payload.actions.size > 1) { + if (payload.actions.size() > 1) { log.warn("Expected a single selected action from Slack, but received ${payload.actions.size}") } diff --git a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/ManualJudgmentTemplateTest.groovy b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/ManualJudgmentTemplateTest.groovy index e72c3780a..5d80f887d 100644 --- a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/ManualJudgmentTemplateTest.groovy +++ b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/ManualJudgmentTemplateTest.groovy @@ -161,14 +161,14 @@ class ManualJudgmentTemplateTest extends Specification { where: // Note, there's a whitespace after each new line of the `instructions` because of `Jsoup.parse(...)`. - // This is because the field is HTML parsed to plaintext. Which also can contain Slack's psudo-markdown flavor. + // This is because the field is HTML parsed to plaintext. Which also can contain Slack's pseudo-markdown flavor. expected = '''\ Stage for *testapp*'s *exe-name* pipeline build #*12345* is awaiting manual judgment. *Instructions:* - This is an example message from spinnaker that's more than 80 characters to make sure that we won't wrap it. Note the extra whitespace at the end here: + This is an example message from spinnaker that's more than 80 characters to make sure that we won't wrap it. Note the extra whitespace at the end here: - ``` This test was added was because code blocks in Slack would word wrap at 80 characters and inject newlines in codeblocks. Note the extra whitespaces after each original newline. ``` + ``` This test was added was because code blocks in Slack would word wrap at 80 characters and inject newlines in codeblocks. Note the extra whitespaces after each original newline. ``` '''.stripIndent() } } diff --git a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/slack/SlackServiceSpec.groovy b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/slack/SlackServiceSpec.groovy index a8bb3ecbd..9318cf522 100644 --- a/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/slack/SlackServiceSpec.groovy +++ b/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/slack/SlackServiceSpec.groovy @@ -141,7 +141,7 @@ class SlackServiceSpec extends Specification { attachmentsJson[0]["fallback"] == "the text" attachmentsJson[0]["footer"] == "Spinnaker" attachmentsJson[0]["mrkdwn_in"] == ["text"] - attachmentsJson[0]["actions"].size == 1 + attachmentsJson[0]["actions"].size() == 1 attachmentsJson[0]["actions"][0] == [ type: "button", name: "choice", diff --git a/echo-web/config/echo.yml b/echo-web/config/echo.yml index 5f53fe236..2c7efb89c 100644 --- a/echo-web/config/echo.yml +++ b/echo-web/config/echo.yml @@ -10,6 +10,11 @@ spinnaker: front50: baseUrl: ${services.front50.baseUrl:http://localhost:8080} +services: + fiat: + enabled: ${services.fiat.enabled:false} + baseUrl: ${services.fiat.baseUrl:http://localhost:8089} + igor: enabled: ${services.igor.enabled:false} baseUrl: ${services.igor.baseUrl:http://localhost:8088}