Skip to content

chore(ci): Run unit tests for GraalVM as well during build. #2047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
72d67c8
chore(ci): Run unit tests for GraalVM as well during build.
phipag Aug 14, 2025
18975ca
Test GraalVM unit tests on Mockito 5.16.0.
phipag Aug 14, 2025
ac48107
Fix native tests in powertools-serialization. Remove mockito dependen…
phipag Aug 15, 2025
be3177d
Remove mockito from powertools-common.
phipag Aug 15, 2025
fdd52a0
Remove mockito from powertools-metrics and re-use TestLamdaContext fr…
phipag Aug 15, 2025
d2e4ef5
Remove mockito from powertools-serialization.
phipag Aug 15, 2025
93537b6
Remove mockito from powertools-logging.
phipag Aug 15, 2025
96021e4
Remove mockito from powertools-logging-log4j.
phipag Aug 15, 2025
e544677
Add --initialize-at-build-time=org.junit.platform.launcher.core.Disco…
phipag Aug 15, 2025
4bca6e3
Remove mockito from powertools-logging-logback.
phipag Aug 15, 2025
5684000
Remove mockito from powertools-tracing.
phipag Aug 15, 2025
a38441d
Build project first to make sure test-jar dependencies are available …
phipag Aug 15, 2025
bc01dbc
Enable maven quite mode and search recursively for graalvm profiles t…
phipag Aug 15, 2025
f223db8
Add back Mockito to powertools-common.
phipag Aug 18, 2025
2c8100c
Simplify graalvm config for logback and log4j modules.
phipag Aug 18, 2025
0347dca
Simplify graalvm config in powertools-logging.
phipag Aug 18, 2025
9d720e7
Cleanup GRM files for logback module.
phipag Aug 18, 2025
a5e8d0b
Simplify GraalVM config for powertools-metrics, powertools-serializat…
phipag Aug 18, 2025
d314b1a
Remove <! or newer version --> comment.
phipag Aug 18, 2025
bf7c570
Simplify powertools-parameters-tests GraalVM config and fix issues in…
phipag Aug 18, 2025
19b4555
Simplify powertools-parameters-ssm GraalVM config and fix issues in u…
phipag Aug 18, 2025
b06bd64
Simplify powertools-parameters-secrets GraalVM config and fix issues …
phipag Aug 18, 2025
d08699e
Simplify powertools-parameters-dynamodb GraalVM config and fix issues…
phipag Aug 18, 2025
0c37061
Simplify powertools-parameters-appconfig GraalVM config and fix issue…
phipag Aug 18, 2025
bbf0c54
Fix SonarCube finding.
phipag Aug 18, 2025
d4e19b1
Allowlist UPL-1.0 license.
phipag Aug 19, 2025
07dac3a
Add TT ID to UPL license.
phipag Aug 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/dependency-review-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ allow-licenses:
- 'BSD-3-Clause-No-Nuclear-License-2014'
- 'BSD-3-Clause-No-Nuclear-Warranty'
- 'BSD-3-Clause-Open-MPI'
comment-summary-in-pr: on-failure
# TT: D290816995
- 'UPL-1.0'
comment-summary-in-pr: on-failure
65 changes: 36 additions & 29 deletions .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
#
# Description:
# Runs the build for every java version we support
#
#
# Triggers:
# - pull_request: when a PR is sent to us
# - push: when code is pushed to a specified branch
#
# Notes:
# The matrix build for this workflow is unusual, we need to make it dyanmic since
# we need to change java versions we build for depending on the branch.

# Builds against Java 11, 17, and 21 which are the supported versions.

on:
workflow_dispatch:
Expand Down Expand Up @@ -38,7 +36,7 @@ on:
push:
branches:
- main
paths: # add other modules when there are under e2e tests
paths:
- 'powertools-batch/**'
- 'powertools-core/**'
- 'powertools-cloudformation/**'
Expand All @@ -63,31 +61,11 @@ name: Build
run-name: Build - ${{ github.event_name }}

jobs:
setup:
runs-on: ubuntu-latest
outputs:
build_matrix: ${{ format('{0}{1}', steps.build_matrix_v1.outputs.build_matrix, steps.build_matrix_v1.outputs.build_matrix) }}
steps:
- id: base
name: Base
run: |
echo build_version=$(test ${{ github.ref }} == "v2" && echo "v2" || echo "v1") >> $GITHUB_OUTPUT
- id: build_matrix_v1
name: Build matrix (v1)
if: ${{ steps.base.outputs.build_version == 'v1' }}
run: |
echo build_matrix='["8", "11", "17", "21"]' >> "$GITHUB_OUTPUT"
- id: build_matrix_v2
name: Build matrix (v2)
if: ${{ steps.base.outputs.build_version == 'v2' }}
run: |
echo build_matrix='["11", "17", "21"]'>> "$GITHUB_OUTPUT"
build:
java-build:
runs-on: ubuntu-latest
strategy:
matrix:
java:
- 8
- 11
- 17
- 21
Expand All @@ -96,13 +74,42 @@ jobs:
name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: corretto
java-version: ${{ matrix.java }}
cache: maven
- id: build-maven
name: Build (Maven)
if: ${{ matrix.java != '8' }}
run: |
mvn -B install --file pom.xml
mvn -B -q install --file pom.xml

graalvm-build:
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup GraalVM
uses: graalvm/setup-graalvm@7f488cf82a3629ee755e4e97342c01d6bed318fa # v1.3.5
with:
java-version: "21"
distribution: "graalvm"
cache: maven
- id: graalvm-native-test
name: GraalVM Native Test
run: |
# Build the entire project first to ensure test-jar dependencies are available
mvn -B -q install -DskipTests

# Find modules with graalvm-native profile and run tests recursively.
# This will make sure to discover new GraalVM supported modules automatically in the future.
find . -name "pom.xml" -path "./powertools-*" | while read module; do
if grep -q "<id>graalvm-native</id>" "$module"; then
module_dir=$(dirname "$module")
echo "Regenerating GraalVM metadata for $module_dir"
mvn -B -q -f "$module" -Pgenerate-graalvm-files clean test
echo "Running GraalVM native tests for $module_dir"
mvn -B -q -f "$module" -Pgraalvm-native test
fi
done
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-gpg-plugin.version>3.2.1</maven-gpg-plugin.version>
<junit.version>5.10.0</junit.version>
<aspectj-maven-plugin.version>1.14.1</aspectj-maven-plugin.version>
<maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
<jacoco-maven-plugin.version>0.8.13</jacoco-maven-plugin.version>
Expand All @@ -114,8 +113,8 @@
<aws.sdk.v1.version>1.12.781</aws.sdk.v1.version>
<versions-maven-plugin.version>2.18.0</versions-maven-plugin.version>
<elastic.version>1.7.0</elastic.version>
<mockito.version>5.18.0</mockito.version>
<mockito-junit-jupiter.version>5.18.0</mockito-junit-jupiter.version>
<mockito.version>5.19.1-SNAPSHOT</mockito.version>
<mockito-junit-jupiter.version>5.19.1-SNAPSHOT</mockito-junit-jupiter.version>
<junit-pioneer.version>2.3.0</junit-pioneer.version>
<crac.version>1.5.0</crac.version>

Expand Down Expand Up @@ -322,7 +321,7 @@
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>2.0.0</version>
<version>${junit-pioneer.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
57 changes: 24 additions & 33 deletions powertools-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,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">
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>

<artifactId>powertools-common</artifactId>
Expand Down Expand Up @@ -77,13 +77,13 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -94,7 +94,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-subclass</artifactId>
<version>5.18.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -105,7 +104,9 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.3</version>
<configuration>
<argLine>-Dmockito.mock.maker=subclass -Dorg.graalvm.nativeimage.imagecode=agent -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-common,experimental-class-define-support
<argLine>
-Dorg.graalvm.nativeimage.imagecode=agent
-agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image/software.amazon.lambda/powertools-common,experimental-class-define-support
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
</argLine>
Expand All @@ -120,7 +121,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-subclass</artifactId>
<version>5.18.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -129,7 +129,7 @@
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.11.0</version> <!-- or newer version -->
<version>0.11.0</version>
<extensions>true</extensions>
<executions>
<execution>
Expand All @@ -146,33 +146,11 @@
<buildArg>--add-opens java.base/java.util=ALL-UNNAMED</buildArg>
<buildArg>--add-opens java.base/java.lang=ALL-UNNAMED</buildArg>
<buildArg>--no-fallback</buildArg>
<buildArg>-Dorg.graalvm.nativeimage.imagecode=agent</buildArg>
<buildArg>-H:ClassInitialization=net.bytebuddy.ClassFileVersion:rerun</buildArg>
<buildArg>-H:ClassInitialization=net.bytebuddy.utility.dispatcher.JavaDispatcher:rerun</buildArg>
<buildArg>-H:ClassInitialization=net.bytebuddy.utility.Invoker$Dispatcher:rerun</buildArg>
<buildArg>-H:ClassInitialization=net.bytebuddy.utility.GraalImageCode:rerun</buildArg>
<buildArg>--initialize-at-build-time=org.slf4j.simple.SimpleLogger</buildArg>
<buildArg>--initialize-at-build-time=org.slf4j.LoggerFactory</buildArg>
<buildArg>--initialize-at-build-time=org.junit.Ignore</buildArg>
<buildArg>--initialize-at-build-time=java.lang.annotation.Annotation</buildArg>
<buildArg>--initialize-at-build-time=org.junit.runners.model.FrameworkField</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$AbstractBase</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.description.type.TypeDescription$ForLoadedType</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$ForLoadedMethod</buildArg>
<buildArg>--initialize-at-build-time=net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2</buildArg>
<buildArg>
--trace-class-initialization=net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable
</buildArg>
<buildArg>--verbose</buildArg>
<buildArg>--native-image-info</buildArg>
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
<buildArg>-H:Log=registerResource:5</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
</buildArgs>
</configuration>
</plugin>
Expand All @@ -192,5 +170,18 @@
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading