Skip to content

Commit fb50fed

Browse files
chore(ci): Run unit tests for GraalVM as well during build. (#2047)
* chore(ci): Run unit tests for GraalVM as well during build. * Test GraalVM unit tests on Mockito 5.16.0. * Fix native tests in powertools-serialization. Remove mockito dependency there. * Remove mockito from powertools-common. * Remove mockito from powertools-metrics and re-use TestLamdaContext from powertools-common. * Remove mockito from powertools-serialization. * Remove mockito from powertools-logging. * Remove mockito from powertools-logging-log4j. * Add --initialize-at-build-time=org.junit.platform.launcher.core.DiscoveryIssueNotifier * Remove mockito from powertools-logging-logback. * Remove mockito from powertools-tracing. * Build project first to make sure test-jar dependencies are available for graalvm unit tests. * Enable maven quite mode and search recursively for graalvm profiles to make sure sub-sub-modules are also covered. * Add back Mockito to powertools-common. * Simplify graalvm config for logback and log4j modules. * Simplify graalvm config in powertools-logging. * Cleanup GRM files for logback module. * Simplify GraalVM config for powertools-metrics, powertools-serialization, powertools-tracing. * Remove <! or newer version --> comment. * Simplify powertools-parameters-tests GraalVM config and fix issues in unit tests. * Simplify powertools-parameters-ssm GraalVM config and fix issues in unit tests. * Simplify powertools-parameters-secrets GraalVM config and fix issues in unit tests. * Simplify powertools-parameters-dynamodb GraalVM config and fix issues in unit tests. * Simplify powertools-parameters-appconfig GraalVM config and fix issues in unit tests. * Fix SonarCube finding. * Allowlist UPL-1.0 license. * Add TT ID to UPL license. * Enable Maven Central snapshot repo temporarily. * Potential fix for code scanning alert no. 54: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Disable verbose resource registration logs. --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 91d1a57 commit fb50fed

File tree

15 files changed

+64
-106
lines changed

15 files changed

+64
-106
lines changed

.github/workflows/check-build.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ on:
5858
- '.github/workflows/**'
5959

6060
name: Build
61+
permissions:
62+
contents: read
6163
run-name: Build - ${{ github.event_name }}
6264

6365
jobs:
@@ -82,7 +84,7 @@ jobs:
8284
- id: build-maven
8385
name: Build (Maven)
8486
run: |
85-
mvn -B install --file pom.xml
87+
mvn -B -q install --file pom.xml
8688
8789
graalvm-build:
8890
runs-on: ubuntu-latest
@@ -99,14 +101,17 @@ jobs:
99101
- id: graalvm-native-test
100102
name: GraalVM Native Test
101103
run: |
102-
# Find modules with graalvm-native profile and run tests.
104+
# Build the entire project first to ensure test-jar dependencies are available
105+
mvn -B -q install -DskipTests
106+
107+
# Find modules with graalvm-native profile and run tests recursively.
103108
# This will make sure to discover new GraalVM supported modules automatically in the future.
104-
for module in powertools-*/pom.xml; do
109+
find . -name "pom.xml" -path "./powertools-*" | while read module; do
105110
if grep -q "<id>graalvm-native</id>" "$module"; then
106111
module_dir=$(dirname "$module")
107112
echo "Regenerating GraalVM metadata for $module_dir"
108-
mvn -B -f "$module" -Pgenerate-graalvm-files clean test
113+
mvn -B -q -f "$module" -Pgenerate-graalvm-files clean test
109114
echo "Running GraalVM native tests for $module_dir"
110-
mvn -B -f "$module" -Pgraalvm-native test
115+
mvn -B -q -f "$module" -Pgraalvm-native test
111116
fi
112117
done

pom.xml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@
114114
<aws.sdk.v1.version>1.12.781</aws.sdk.v1.version>
115115
<versions-maven-plugin.version>2.18.0</versions-maven-plugin.version>
116116
<elastic.version>1.7.0</elastic.version>
117-
<mockito.version>5.16.0</mockito.version>
118-
<mockito-junit-jupiter.version>5.16.0</mockito-junit-jupiter.version>
117+
<mockito.version>5.19.1-SNAPSHOT</mockito.version>
118+
<mockito-junit-jupiter.version>5.19.1-SNAPSHOT</mockito-junit-jupiter.version>
119119
<junit-pioneer.version>2.3.0</junit-pioneer.version>
120120
<crac.version>1.5.0</crac.version>
121121

@@ -131,6 +131,21 @@
131131
</snapshotRepository>
132132
</distributionManagement>
133133

134+
<!-- https://central.sonatype.org/publish/publish-portal-snapshots/#consuming-via-maven -->
135+
<repositories>
136+
<repository>
137+
<name>Central Portal Snapshots</name>
138+
<id>central-portal-snapshots</id>
139+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
140+
<releases>
141+
<enabled>false</enabled>
142+
</releases>
143+
<snapshots>
144+
<enabled>true</enabled>
145+
</snapshots>
146+
</repository>
147+
</repositories>
148+
134149
<dependencyManagement>
135150
<dependencies>
136151
<dependency>

powertools-common/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@
149149
<buildArg>--verbose</buildArg>
150150
<buildArg>--native-image-info</buildArg>
151151
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
152-
<buildArg>-H:Log=registerResource:5</buildArg>
153152
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
154153
</buildArgs>
155154
</configuration>

powertools-logging/pom.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,6 @@
118118
<profiles>
119119
<profile>
120120
<id>generate-graalvm-files</id>
121-
<dependencies>
122-
<dependency>
123-
<groupId>org.mockito</groupId>
124-
<artifactId>mockito-subclass</artifactId>
125-
<scope>test</scope>
126-
</dependency>
127-
</dependencies>
128121
<build>
129122
<plugins>
130123
<plugin>
@@ -145,13 +138,6 @@
145138
</profile>
146139
<profile>
147140
<id>graalvm-native</id>
148-
<dependencies>
149-
<dependency>
150-
<groupId>org.mockito</groupId>
151-
<artifactId>mockito-subclass</artifactId>
152-
<scope>test</scope>
153-
</dependency>
154-
</dependencies>
155141
<build>
156142
<plugins>
157143
<plugin>
@@ -177,7 +163,6 @@
177163
<buildArg>--verbose</buildArg>
178164
<buildArg>--native-image-info</buildArg>
179165
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
180-
<buildArg>-H:Log=registerResource:5</buildArg>
181166
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
182167
</buildArgs>
183168
</configuration>

powertools-logging/powertools-logging-log4j/pom.xml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

77
<parent>
@@ -97,13 +97,6 @@
9797
<profiles>
9898
<profile>
9999
<id>generate-graalvm-files</id>
100-
<dependencies>
101-
<dependency>
102-
<groupId>org.mockito</groupId>
103-
<artifactId>mockito-subclass</artifactId>
104-
<scope>test</scope>
105-
</dependency>
106-
</dependencies>
107100
<build>
108101
<plugins>
109102
<plugin>
@@ -124,13 +117,6 @@
124117
</profile>
125118
<profile>
126119
<id>graalvm-native</id>
127-
<dependencies>
128-
<dependency>
129-
<groupId>org.mockito</groupId>
130-
<artifactId>mockito-subclass</artifactId>
131-
<scope>test</scope>
132-
</dependency>
133-
</dependencies>
134120
<build>
135121
<plugins>
136122
<plugin>
@@ -159,7 +145,6 @@
159145
<buildArg>--verbose</buildArg>
160146
<buildArg>--native-image-info</buildArg>
161147
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
162-
<buildArg>-H:Log=registerResource:5</buildArg>
163148
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
164149
</buildArgs>
165150
</configuration>

powertools-logging/powertools-logging-logback/pom.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@
9090
<profiles>
9191
<profile>
9292
<id>generate-graalvm-files</id>
93-
<dependencies>
94-
<dependency>
95-
<groupId>org.mockito</groupId>
96-
<artifactId>mockito-subclass</artifactId>
97-
<scope>test</scope>
98-
</dependency>
99-
</dependencies>
10093
<build>
10194
<plugins>
10295
<plugin>
@@ -117,13 +110,6 @@
117110
</profile>
118111
<profile>
119112
<id>graalvm-native</id>
120-
<dependencies>
121-
<dependency>
122-
<groupId>org.mockito</groupId>
123-
<artifactId>mockito-subclass</artifactId>
124-
<scope>test</scope>
125-
</dependency>
126-
</dependencies>
127113
<build>
128114
<plugins>
129115
<plugin>
@@ -152,7 +138,6 @@
152138
<buildArg>--verbose</buildArg>
153139
<buildArg>--native-image-info</buildArg>
154140
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
155-
<buildArg>-H:Log=registerResource:5</buildArg>
156141
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
157142
</buildArgs>
158143
</configuration>

powertools-metrics/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@
179179
<buildArg>--verbose</buildArg>
180180
<buildArg>--native-image-info</buildArg>
181181
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
182-
<buildArg>-H:Log=registerResource:5</buildArg>
183182
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
184183
</buildArgs>
185184
</configuration>

powertools-parameters/pom.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@
9393
<profiles>
9494
<profile>
9595
<id>generate-graalvm-files</id>
96-
<dependencies>
97-
<dependency>
98-
<groupId>org.mockito</groupId>
99-
<artifactId>mockito-subclass</artifactId>
100-
<scope>test</scope>
101-
</dependency>
102-
</dependencies>
10396
<build>
10497
<plugins>
10598
<plugin>
@@ -120,13 +113,6 @@
120113
</profile>
121114
<profile>
122115
<id>graalvm-native</id>
123-
<dependencies>
124-
<dependency>
125-
<groupId>org.mockito</groupId>
126-
<artifactId>mockito-subclass</artifactId>
127-
<scope>test</scope>
128-
</dependency>
129-
</dependencies>
130116
<build>
131117
<plugins>
132118
<plugin>
@@ -152,7 +138,6 @@
152138
<buildArg>--verbose</buildArg>
153139
<buildArg>--native-image-info</buildArg>
154140
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
155-
<buildArg>-H:Log=registerResource:5</buildArg>
156141
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
157142
</buildArgs>
158143
</configuration>

powertools-parameters/powertools-parameters-appconfig/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@
120120
<artifactId>mockito-subclass</artifactId>
121121
<scope>test</scope>
122122
</dependency>
123+
124+
<!-- Required explicitly for @Captor ArgumentCaptor -->
125+
<dependency>
126+
<groupId>org.junit.jupiter</groupId>
127+
<artifactId>junit-jupiter-params</artifactId>
128+
<scope>test</scope>
129+
</dependency>
123130
</dependencies>
124131
<build>
125132
<plugins>
@@ -146,7 +153,6 @@
146153
<buildArg>--verbose</buildArg>
147154
<buildArg>--native-image-info</buildArg>
148155
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
149-
<buildArg>-H:Log=registerResource:5</buildArg>
150156
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
151157
</buildArgs>
152158
</configuration>

powertools-parameters/powertools-parameters-dynamodb/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@
121121
<artifactId>mockito-subclass</artifactId>
122122
<scope>test</scope>
123123
</dependency>
124+
125+
<!-- Required explicitly for @Captor ArgumentCaptor -->
126+
<dependency>
127+
<groupId>org.junit.jupiter</groupId>
128+
<artifactId>junit-jupiter-params</artifactId>
129+
<scope>test</scope>
130+
</dependency>
124131
</dependencies>
125132
<build>
126133
<plugins>
@@ -147,7 +154,6 @@
147154
<buildArg>--verbose</buildArg>
148155
<buildArg>--native-image-info</buildArg>
149156
<buildArg>-H:+UnlockExperimentalVMOptions</buildArg>
150-
<buildArg>-H:Log=registerResource:5</buildArg>
151157
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
152158
</buildArgs>
153159
</configuration>

0 commit comments

Comments
 (0)