Skip to content

Commit

Permalink
chore(java): Full java 17 (#684)
Browse files Browse the repository at this point in the history
* chore(test): Adds swabbie integration tests for docker builds

* fix(test): Fix integration test port

* chore(gha): Update GHA to use image and additional JVM flags

* fix(gha): Add tests to PR as well

* fix(config): Use kork-config to set the standard properties for spinnaker services

* chore(java): Full Java 17 support only

* chore(java): Full Java 17 support only

* chore(java): Full Java 17 support only

* chore(java): Full Java 17 support only

* chore(java): Full Java 17 support only

* chore(java): Full Java 17 support only

* chore(java): Full Java 17 support only

* chore(java): Full Java 17 support only
  • Loading branch information
jasonmcintosh authored Nov 16, 2024
1 parent 08594ad commit ee8cf50
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 102 deletions.
39 changes: 9 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
with:
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Prepare build variables
Expand All @@ -48,10 +47,10 @@ jobs:
platforms: local
tags: |
"${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated"
- name: Test local slim container image
env:
FULL_DOCKER_IMAGE_NAME: "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated"
run: ./gradlew ${{ steps.build_variables.outputs.REPO }}-integration:test
# - name: Test local slim container image
# env:
# FULL_DOCKER_IMAGE_NAME: "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated"
# run: ./gradlew ${{ steps.build_variables.outputs.REPO }}-integration:test
- name: Login to GAR
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
Expand Down Expand Up @@ -87,28 +86,8 @@ 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"
# - name: Test local slim container image
# env:
# FULL_DOCKER_IMAGE_NAME: "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}"
# run: ./gradlew ${{ steps.build_variables.outputs.REPO }}-integration:test
25 changes: 4 additions & 21 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
with:
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Prepare build variables
Expand Down Expand Up @@ -53,26 +52,6 @@ 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"
- name: Build local slim container image for testing
uses: docker/build-push-action@v5
with:
Expand All @@ -83,3 +62,7 @@ jobs:
tags: |
"${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}"
# - name: Test local slim container image
# env:
# FULL_DOCKER_IMAGE_NAME: "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}"
# run: ./gradlew ${{ steps.build_variables.outputs.REPO }}-integration:test
27 changes: 1 addition & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
with:
java-version: |
17
11
distribution: 'zulu'
cache: 'gradle'
- name: Assemble release info
Expand Down Expand Up @@ -121,31 +120,6 @@ 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@v2
Expand All @@ -159,6 +133,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Pause before dependency bump
run: sleep 900

- name: Trigger dependency bump workflow
uses: peter-evans/repository-dispatch@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.compile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:jammy
RUN apt-get update && apt-get install -y \
openjdk-11-jdk \
openjdk-17-jdk \
&& rm -rf /var/lib/apt/lists/*
LABEL maintainer="[email protected]"
ENV GRADLE_USER_HOME /workspace/.gradle
Expand Down
10 changes: 0 additions & 10 deletions Dockerfile.java11.slim

This file was deleted.

9 changes: 0 additions & 9 deletions Dockerfile.java11.ubuntu

This file was deleted.

4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ korkVersion=7.244.0
kotlinVersion=1.6.21
org.gradle.parallel=true
spinnakerGradleVersion=8.32.1
targetJava11=true
targetJava17=true

org.gradle.jvmargs=-Xmx2g
# To enable a composite reference to a project, set the
# project property `'<projectName>Composite=true'`.
#
Expand Down
2 changes: 1 addition & 1 deletion gradle/dokka.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: "org.jetbrains.dokka"
dokkaHtml {
dokkaSourceSets {
configureEach {
jdkVersion.set(11)
jdkVersion.set(17)
}
}
}
4 changes: 2 additions & 2 deletions gradle/kotlin.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ apply plugin: "io.gitlab.arturbosch.detekt"
compileKotlin {
kotlinOptions {
languageVersion = "1.6"
jvmTarget = "11"
jvmTarget = "17"
}
}

compileTestKotlin {
kotlinOptions {
languageVersion = "1.6"
jvmTarget = "11"
jvmTarget = "17"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import java.time.Instant
import java.time.LocalDateTime
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.time.ZoneId
import java.time.format.DateTimeFormatter

object AmazonTagExclusionPolicyTest {
private val clock = MutableClock()
Expand Down Expand Up @@ -118,6 +120,40 @@ object AmazonTagExclusionPolicyTest {

clock.incrementBy(Duration.ofDays(10))

resources.filter {
subject.apply(it, emptyList()) == null
}.let { filteredResources ->
filteredResources.size shouldMatch equalTo(1)
filteredResources.first().resourceId shouldMatch equalTo("2")
}
}
//TODO: This is a duplicate of the above but with a VERY specific very precise time zone
@Test
fun `should handle high precision date times`() {
val now = LocalDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_INSTANT.parse("2024-11-15T23:42:18.592945345Z")), ZoneId.of("America/Chicago"))
val resources = listOf(
AwsTestResource(
id = "1",
creationDate = now.toString()
).withDetail(
name = "tags",
value = listOf(
mapOf("expiration_time" to "10d")
)
),
AwsTestResource(
id = "2",
creationDate = now.toString()
).withDetail(
name = "tags",
value = listOf(
mapOf("expiration_time" to "9d")
)
)
)

clock.incrementBy(Duration.ofDays(10))

resources.filter {
subject.apply(it, emptyList()) == null
}.let { filteredResources ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeFormatterBuilder



class Dates {
companion object {
Expand All @@ -30,6 +33,7 @@ class Dates {
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ"),
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS"),
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS"),
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS"),
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm"),
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSZ"),
Expand All @@ -39,7 +43,8 @@ class Dates {
DateTimeFormatter.ofPattern("MM/dd/yyyy"),
DateTimeFormatter.ofPattern("MMMM d, yyyy h:mm a"),
DateTimeFormatter.ofPattern("MMMM d, yyyy"),
DateTimeFormatter.ofPattern("MMMM d, yyyy")
DateTimeFormatter.ofPattern("MMMM d, yyyy"),
DateTimeFormatter.ISO_INSTANT,
)

fun toLocalDateTime(date: String): LocalDateTime {
Expand All @@ -48,9 +53,11 @@ class Dates {
try {
return LocalDateTime.parse(date, format)
} catch (e: Exception) {
System.err.println("Failed to process with format $format")
exception = e
}
}
System.err.println("Failed to process date $date")

throw exception!!
}
Expand Down
1 change: 1 addition & 0 deletions swabbie-web/swabbie-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-data-rest"
implementation "io.spinnaker.kork:kork-web"

implementation project(":swabbie-aws")
implementation project(":swabbie-clouddriver")
implementation project(":swabbie-core")
Expand Down

0 comments on commit ee8cf50

Please sign in to comment.