diff --git a/.github/workflows/native-image.yml b/.github/workflows/native-image.yml index f15c569..3aaed82 100644 --- a/.github/workflows/native-image.yml +++ b/.github/workflows/native-image.yml @@ -36,6 +36,13 @@ jobs: label=$(docker image inspect -f '{{index .Config.Labels "service"}}' "$IMAGE:${{ github.sha }}") echo "service label: '$label'" test "$label" = fullstack-with-spring + - name: Smoke test native image + run: | + docker run -d --name smoke -p 8080:8080 "$IMAGE:${{ github.sha }}" + for i in $(seq 30); do curl -fs localhost:8080/ >/dev/null && break; sleep 1; done + for path in / /tables /forms "/lineChartComponent?name=Sales"; do + curl -fsS -o /dev/null -w "%{http_code} $path\n" "localhost:8080$path" || { docker logs smoke | tail -40; exit 1; } + done - if: github.event_name == 'push' && github.ref == 'refs/heads/master' run: docker save "$IMAGE:${{ github.sha }}" | gzip > image.tar.gz - if: github.event_name == 'push' && github.ref == 'refs/heads/master' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e11132..e311d96 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip -networkTimeout=10000 +networkTimeout=120000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/de/tschuehly/fullstackdemo/common/NativeHints.kt b/src/main/kotlin/de/tschuehly/fullstackdemo/common/NativeHints.kt index c13368d..cdc7b7b 100644 --- a/src/main/kotlin/de/tschuehly/fullstackdemo/common/NativeHints.kt +++ b/src/main/kotlin/de/tschuehly/fullstackdemo/common/NativeHints.kt @@ -3,6 +3,8 @@ package de.tschuehly.fullstackdemo.common import de.tschuehly.fullstackdemo.web.component.person.form.PersonFormViewComponent import de.tschuehly.spring.viewcomponent.thymeleaf.ViewContext import org.springframework.aot.hint.BindingReflectionHintsRegistrar +import org.springframework.aot.hint.MemberCategory +import org.springframework.aot.hint.TypeReference import org.springframework.aot.hint.RuntimeHints import org.springframework.aot.hint.RuntimeHintsRegistrar import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider @@ -27,6 +29,8 @@ class NativeHints : RuntimeHintsRegistrar { } val contexts = scanner.findCandidateComponents("de.tschuehly.fullstackdemo") .map { Class.forName(it.beanClassName, false, classLoader) } + // Kotlin reflection resolves emptyList()'s class when a chart has no data (/lineChartComponent?name=Sales). + hints.reflection().registerType(TypeReference.of("kotlin.collections.EmptyList"), *MemberCategory.entries.toTypedArray()) BindingReflectionHintsRegistrar().registerReflectionHints( hints.reflection(), *(contexts + PersonFormViewComponent.PersonFormDTO::class.java).toTypedArray() )