From 9e288bd26f4083515e630f46afbf63665e941716 Mon Sep 17 00:00:00 2001 From: "robin.bygrave" Date: Tue, 17 Oct 2023 14:19:16 +1300 Subject: [PATCH] Add github workflow test for native image --- .editorconfig | 4 ++ .github/workflows/native-image.yml | 39 +++++++++++++ .../resource-config.json | 13 +++++ pom.xml | 19 ++++++- tests/pom.xml | 18 ++++++ tests/test-native-image/pom.xml | 56 +++++++++++++++++++ .../src/main/java/org/example/Main.java | 11 ++++ .../src/main/resources/application.properties | 1 + 8 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/native-image.yml create mode 100644 avaje-config/src/main/resources/META-INF/native-image/io.avaje.config.avaje-config/resource-config.json create mode 100644 tests/pom.xml create mode 100644 tests/test-native-image/pom.xml create mode 100644 tests/test-native-image/src/main/java/org/example/Main.java create mode 100644 tests/test-native-image/src/main/resources/application.properties diff --git a/.editorconfig b/.editorconfig index 837d975..7472642 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,7 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true spaces_around_operators = true + +[*.json] +indent_size = 1 +indent_style = space diff --git a/.github/workflows/native-image.yml b/.github/workflows/native-image.yml new file mode 100644 index 0000000..dd980f3 --- /dev/null +++ b/.github/workflows/native-image.yml @@ -0,0 +1,39 @@ +name: avaje-config native image + +on: + workflow_dispatch: + schedule: + - cron: '40 0 1 1 6' + +jobs: + build: + runs-on: ${{ matrix.os }} + permissions: + contents: read + packages: write + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v3 + - uses: graalvm/setup-graalvm@v1 + with: + java-version: '21' + distribution: 'graalvm' + cache: 'maven' + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Versions + run: | + echo "GRAALVM_HOME: $GRAALVM_HOME" + echo "JAVA_HOME: $JAVA_HOME" + java --version + native-image --version + - name: Build with Maven + run: | + mvn clean install -DskipTests + cd tests/test-native-image + mvn clean package -Pnative + ./target/test-native diff --git a/avaje-config/src/main/resources/META-INF/native-image/io.avaje.config.avaje-config/resource-config.json b/avaje-config/src/main/resources/META-INF/native-image/io.avaje.config.avaje-config/resource-config.json new file mode 100644 index 0000000..a08b14e --- /dev/null +++ b/avaje-config/src/main/resources/META-INF/native-image/io.avaje.config.avaje-config/resource-config.json @@ -0,0 +1,13 @@ +{ + "resources": [ + { + "pattern": "application.properties" + }, + { + "pattern": "application.yaml" + }, + { + "pattern": "application.yml" + } + ] +} diff --git a/pom.xml b/pom.xml index af859bc..96e9445 100644 --- a/pom.xml +++ b/pom.xml @@ -4,18 +4,31 @@ org.avaje java11-oss - 3.10 + 3.12 + io.avaje - avaje-config-reactor + tests-config-reactor 1 pom - avaje config reactor avaje-config + + + + + + + + + + + + + diff --git a/tests/pom.xml b/tests/pom.xml new file mode 100644 index 0000000..4fd2adb --- /dev/null +++ b/tests/pom.xml @@ -0,0 +1,18 @@ + + + 4.0.0 + + org.avaje + java11-oss + 3.12 + + + + tests + pom + + + test-native-image + + + diff --git a/tests/test-native-image/pom.xml b/tests/test-native-image/pom.xml new file mode 100644 index 0000000..1b67342 --- /dev/null +++ b/tests/test-native-image/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + org.example + test-native + 1.0-SNAPSHOT + + + 21 + UTF-8 + 0.9.27 + org.example.Main + + + + + io.avaje + avaje-config + 3.9-SNAPSHOT + + + + + + native + + + + org.graalvm.buildtools + native-maven-plugin + ${version.plugin.nativeimage} + + + build-native + + build + + package + + + --no-fallback + --allow-incomplete-classpath + + + + + + + + + + + diff --git a/tests/test-native-image/src/main/java/org/example/Main.java b/tests/test-native-image/src/main/java/org/example/Main.java new file mode 100644 index 0000000..5f1d31c --- /dev/null +++ b/tests/test-native-image/src/main/java/org/example/Main.java @@ -0,0 +1,11 @@ +package org.example; + +import io.avaje.config.Config; + +public class Main { + + public static void main(String[] args) { + String val = Config.get("hello.world", "not-set"); + System.out.println("Hello - " + val); + } +} diff --git a/tests/test-native-image/src/main/resources/application.properties b/tests/test-native-image/src/main/resources/application.properties new file mode 100644 index 0000000..942827f --- /dev/null +++ b/tests/test-native-image/src/main/resources/application.properties @@ -0,0 +1 @@ +hello.world=Rob