Skip to content

Commit

Permalink
Graalvm support with CI (#791)
Browse files Browse the repository at this point in the history
Co-authored-by: Maximilian Schellhorn <[email protected]>
  • Loading branch information
TingDaoK and maschnetwork authored Jun 11, 2024
1 parent ec236e3 commit daaea57
Show file tree
Hide file tree
Showing 16 changed files with 2,337 additions and 88 deletions.
31 changes: 20 additions & 11 deletions .builder/actions/aws_crt_java_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def _run_java_tests(self, *extra_args):
os.remove('log.txt')

profiles = 'continuous-integration'
if os.getenv("AWS_GRAALVM_CI") is not None:
profiles = 'graalvm-native'

cmd_args = [
"mvn", "-B",
Expand All @@ -20,7 +22,7 @@ def _run_java_tests(self, *extra_args):
"-Daws.crt.memory.tracing=2",
"-Daws.crt.debugnative=true",
"-Daws.crt.aws_trace_log_per_test",
"-Daws.crt.ci=true",
"-Daws.crt.ci=true"
]
cmd_args.extend(extra_args)
cmd_args.append("test")
Expand All @@ -40,18 +42,25 @@ def start_maven_tests(self, env):

self._run_java_tests("-DrerunFailingTestsCount=5")

# run the ShutdownTest by itself
env.shell.setenv('AWS_CRT_SHUTDOWN_TESTING', '1')
self._run_java_tests("-Dtest=ShutdownTest")
if os.getenv("AWS_GRAALVM_CI") is None:
# not running separate test for GraalVM, because GraalVM needs
# rebuild to have separate test to run and rebuild will fail the MQTT tests.
# because currently builder will pull the MQTT related cert/private to the
# `cmake-build` directory and it will be removed after rebuild :)
# also those tests mostly for JVM, which is not very meaning for GraalVM, skip them.

# run the InitTest by itself. This creates an environment where the test itself is the one that
# causes the CRT to be loaded and initialized.
self._run_java_tests("-Dtest=InitTest")
# run the ShutdownTest by itself
env.shell.setenv('AWS_CRT_SHUTDOWN_TESTING', '1')
self._run_java_tests("-Dtest=ShutdownTest")

# run the elasticurl integration tests
python = sys.executable
env.shell.exec(python, 'crt/aws-c-http/integration-testing/http_client_test.py',
python, 'integration-testing/java_elasticurl_runner.py', check=True)
# run the InitTest by itself. This creates an environment where the test itself is the one that
# causes the CRT to be loaded and initialized.
self._run_java_tests("-Dtest=InitTest")

# run the elasticurl integration tests
python = sys.executable
env.shell.exec(python, 'crt/aws-c-http/integration-testing/http_client_test.py',
python, 'integration-testing/java_elasticurl_runner.py', check=True)

def run(self, env):
self.env = env
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,27 @@ jobs:
Start-Process -NoNewWindow python .\non_tls_server.py
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz localhost-test -p ${{ env.PACKAGE_NAME }} downstream
GraalVM:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
java-version: ['22', '21', '17']
steps:
- name: Checkout Sources
uses: actions/checkout@v2
with:
submodules: true
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: ${{ matrix.java-version }}
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }} --variant=graalvm downstream
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Vagrantfile
doxygen/html/
doxygen/latex/


#cmake artifacts
dependencies
_build
Expand Down Expand Up @@ -96,3 +95,5 @@ log.txt
# docs are updated automatically by .github/workflows/docs.yml
docs/

# graalvm manually generated config files
graalvm-configuration
11 changes: 11 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,16 @@
"mvn -B test -DrerunFailingTestsCount=5"
]
}
},
"variants":{
"graalvm": {
"!packages": [],
"!imports": [
],
"!test_env": {
"AWS_GRAALVM_CI": true
},
"!build_env": {}
}
}
}
52 changes: 50 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<cmake.osx_arch>-DOSX_ARCH_DUMMY=1</cmake.osx_arch>
<cmake.min_osx_version>-DOSX_DEPLOYMENT_TARGET_DUMMY=1</cmake.min_osx_version>
<cmake.crt_fips>OFF</cmake.crt_fips>
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
</properties>

<profiles>
Expand Down Expand Up @@ -214,6 +215,42 @@
</plugins>
</build>
</profile>
<profile>
<id>graalvm-native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.10.2</version> <!-- or newer version -->
<extensions>true</extensions>
<executions>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
<configuration>
<agent>
<enabled>true</enabled>
</agent>
<imageName>aws-crt-java</imageName>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>--initialize-at-build-time=org.junit.Ignore,java.lang.annotation.Annotation,org.junit.runners.model.FrameworkField</buildArg>
<buildArg>--verbose</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven-surefire-plugin.version>3.2.3</maven-surefire-plugin.version>
</properties>
</profile>
<profile>
<id>release</id>
<distributionManagement>
Expand Down Expand Up @@ -292,7 +329,14 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!-- https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#testing-support -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -320,6 +364,10 @@
<exclude>**/*.a</exclude> <!-- ignore any libraries from building -->
</excludes>
</resource>
<!-- GraalVM Native Image Configuration Files -->
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
Expand Down Expand Up @@ -410,7 +458,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<crt.classifier>${crt.classifier}</crt.classifier>
Expand Down
Loading

0 comments on commit daaea57

Please sign in to comment.