Skip to content

Commit

Permalink
Add github workflow test for native image
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-bygrave committed Oct 17, 2023
1 parent ee173a5 commit 9e288bd
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 39 additions & 0 deletions .github/workflows/native-image.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"resources": [
{
"pattern": "application.properties"
},
{
"pattern": "application.yaml"
},
{
"pattern": "application.yml"
}
]
}
19 changes: 16 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,31 @@
<parent>
<groupId>org.avaje</groupId>
<artifactId>java11-oss</artifactId>
<version>3.10</version>
<version>3.12</version>
<relativePath/>
</parent>

<groupId>io.avaje</groupId>
<artifactId>avaje-config-reactor</artifactId>
<artifactId>tests-config-reactor</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>avaje config reactor</name>

<modules>
<module>avaje-config</module>
<!-- <module>tests</module>-->
</modules>

<!-- <profiles>-->
<!-- <profile>-->
<!-- <id>central</id>-->
<!-- </profile>-->
<!-- <profile>-->
<!-- <id>native</id>-->
<!-- <modules>-->
<!-- <module>tests</module>-->
<!-- </modules>-->
<!-- </profile>-->
<!-- </profiles>-->

</project>

18 changes: 18 additions & 0 deletions tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.avaje</groupId>
<artifactId>java11-oss</artifactId>
<version>3.12</version>
<relativePath/>
</parent>

<artifactId>tests</artifactId>
<packaging>pom</packaging>

<modules>
<module>test-native-image</module>
</modules>

</project>
56 changes: 56 additions & 0 deletions tests/test-native-image/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>test-native</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.plugin.nativeimage>0.9.27</version.plugin.nativeimage>
<mainClass>org.example.Main</mainClass>
</properties>

<dependencies>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>3.9-SNAPSHOT</version>
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${version.plugin.nativeimage}</version>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
<configuration>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>--allow-incomplete-classpath</buildArg>
</buildArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
11 changes: 11 additions & 0 deletions tests/test-native-image/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello.world=Rob

0 comments on commit 9e288bd

Please sign in to comment.