Skip to content

Commit 01b0bbb

Browse files
committed
Also run Quarkus native image tests in parallel
1 parent d47bf5a commit 01b0bbb

File tree

1 file changed

+139
-30
lines changed

1 file changed

+139
-30
lines changed

ci/quarkus.Jenkinsfile

Lines changed: 139 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
import groovy.transform.Field
2+
13
@Library('hibernate-jenkins-pipeline-helpers') _
24

5+
@Field final String ORM_JDK_VERSION = '21'
6+
@Field final String QUARKUS_JDK_VERSION = '17'
7+
@Field final String ORM_JDK_TOOL = "OpenJDK ${ORM_JDK_VERSION} Latest"
8+
@Field final String QUARKUS_JDK_TOOL = "OpenJDK ${QUARKUS_JDK_VERSION} Latest"
9+
310
// Avoid running the pipeline on branch indexing
411
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
512
print "INFO: Build skipped due to trigger being Branch Indexing"
@@ -13,12 +20,66 @@ if ( !env.CHANGE_ID ) {
1320
return
1421
}
1522

23+
void runBuildOnNode(String label, Closure body) {
24+
node( label ) {
25+
pruneDockerContainers()
26+
tryFinally(body, {
27+
cleanWs()
28+
pruneDockerContainers()
29+
})
30+
}
31+
}
32+
33+
// try-finally construct that properly suppresses exceptions thrown in the finally block.
34+
def tryFinally(Closure main, Closure ... finallies) {
35+
def mainFailure = null
36+
try {
37+
main()
38+
}
39+
catch (Throwable t) {
40+
mainFailure = t
41+
throw t
42+
}
43+
finally {
44+
finallies.each {it ->
45+
try {
46+
it()
47+
}
48+
catch (Throwable t) {
49+
if ( mainFailure ) {
50+
mainFailure.addSuppressed( t )
51+
}
52+
else {
53+
mainFailure = t
54+
}
55+
}
56+
}
57+
}
58+
if ( mainFailure ) { // We may reach here if only the "finally" failed
59+
throw mainFailure
60+
}
61+
}
62+
63+
class BuildConfiguration {
64+
String name
65+
String projects
66+
boolean nativeProfile = false
67+
}
68+
69+
// See data category from https://github.com/quarkusio/quarkus/blob/main/.github/native-tests.json
70+
def configurations = [
71+
new BuildConfiguration( name: "JVM test", projects: "!integration-tests/kafka-oauth-keycloak,!integration-tests/kafka-sasl-elytron,!integration-tests/hibernate-search-orm-opensearch,!integration-tests/hibernate-search-orm-elasticsearch-outbox-polling,!integration-tests/hibernate-search-orm-elasticsearch-tenancy,!integration-tests/maven,!integration-tests/quartz,!integration-tests/reactive-messaging-kafka,!integration-tests/resteasy-reactive-kotlin/standard,!integration-tests/opentelemetry-reactive-messaging,!integration-tests/virtual-threads/kafka-virtual-threads,!integration-tests/smallrye-jwt-oidc-webapp,!extensions/oidc-db-token-state-manager/deployment,!docs"),
72+
new BuildConfiguration( name: "Data1", nativeProfile: true, projects: "jpa-h2, jpa-h2-embedded, jpa-mariadb, jpa-mssql, jpa-without-entity, hibernate-orm-tenancy/datasource, hibernate-orm-tenancy/connection-resolver, hibernate-orm-tenancy/connection-resolver-legacy-qualifiers"),
73+
new BuildConfiguration( name: "Data2", nativeProfile: true, projects: "jpa, jpa-mapping-xml/legacy-app, jpa-mapping-xml/modern-app, jpa-mysql, jpa-db2, jpa-oracle"),
74+
new BuildConfiguration( name: "Data3", nativeProfile: true, projects: "flyway, hibernate-orm-panache, hibernate-orm-panache-kotlin, hibernate-orm-envers, liquibase, liquibase-mongodb"),
75+
new BuildConfiguration( name: "Data4", nativeProfile: true, projects: "mongodb-client, mongodb-devservices, mongodb-panache, mongodb-rest-data-panache, mongodb-panache-kotlin, redis-client, hibernate-orm-rest-data-panache"),
76+
new BuildConfiguration( name: "Data5", nativeProfile: true, projects: "jpa-postgresql, jpa-postgresql-withxml, narayana-stm, narayana-jta, reactive-pg-client, hibernate-reactive-postgresql, hibernate-orm-tenancy/schema, hibernate-orm-tenancy/schema-mariadb"),
77+
new BuildConfiguration( name: "Data6", nativeProfile: true, projects: "elasticsearch-rest-client, elasticsearch-java-client, hibernate-search-orm-elasticsearch, hibernate-search-orm-elasticsearch-tenancy, hibernate-search-orm-opensearch, hibernate-search-orm-elasticsearch-outbox-polling, hibernate-search-standalone-elasticsearch, hibernate-search-standalone-opensearch"),
78+
new BuildConfiguration( name: "Data7", nativeProfile: true, projects: "reactive-oracle-client, reactive-mysql-client, reactive-db2-client, hibernate-reactive-db2, hibernate-reactive-mariadb, hibernate-reactive-mssql, hibernate-reactive-mysql, hibernate-reactive-mysql-agroal-flyway, hibernate-reactive-panache, hibernate-reactive-panache-kotlin, hibernate-reactive-oracle")
79+
]
80+
1681
pipeline {
1782
agent none
18-
tools {
19-
jdk 'OpenJDK 21 Latest'
20-
maven 'Apache Maven 3.9'
21-
}
2283
options {
2384
buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
2485
disableConcurrentBuilds(abortPrevious: true)
@@ -30,48 +91,96 @@ pipeline {
3091
requireApprovalForPullRequest 'hibernate'
3192
}
3293
}
33-
stage('Build') {
94+
stage('Build Hibernate ORM') {
3495
agent {
3596
label 'LongDuration'
3697
}
98+
tools {
99+
jdk ORM_JDK_TOOL
100+
}
37101
steps {
38102
script {
39103
dir('hibernate') {
40104
checkout scm
41-
sh "./gradlew clean publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace -PmavenMirror=nexus-load-balancer-c4cf05fd92f43ef8.elb.us-east-1.amazonaws.com -Dmaven.repo.local=${env.WORKSPACE}/.m2repository"
105+
sh "./gradlew clean publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace -PmavenMirror=nexus-load-balancer-c4cf05fd92f43ef8.elb.us-east-1.amazonaws.com -Dmaven.repo.local=${env.WORKSPACE_TMP}/.m2repository"
42106
script {
43107
env.HIBERNATE_VERSION = sh (
44108
script: "grep hibernateVersion gradle/version.properties|cut -d'=' -f2",
45109
returnStdout: true
46110
).trim()
47111
}
48112
}
49-
dir('quarkus') {
50-
def quarkusVersionToTest = '3.27'
51-
sh "git clone -b ${quarkusVersionToTest} --single-branch https://github.com/quarkusio/quarkus.git . || git reset --hard && git clean -fx && git pull"
52-
script {
53-
def sedStatus = sh (script: "sed -i 's@<hibernate-orm.version>.*</hibernate-orm.version>@<hibernate-orm.version>${env.HIBERNATE_VERSION}</hibernate-orm.version>@' pom.xml", returnStatus: true)
54-
if ( sedStatus != 0 ) {
55-
throw new IllegalArgumentException( "Unable to replace hibernate version in Quarkus pom. Got exit code $sedStatus" )
56-
}
57-
}
58-
// Need to override the default maven configuration this way, because there is no other way to do it
59-
sh "sed -i 's/-Xmx5g/-Xmx2048m/' ./.mvn/jvm.config"
60-
sh "echo -e '\\n-XX:MaxMetaspaceSize=1024m'>>./.mvn/jvm.config"
61-
withMaven(mavenLocalRepo: env.WORKSPACE + '/.m2repository', publisherStrategy: 'EXPLICIT') {
62-
// to account for script-only maven wrapper use in Quarkus:
63-
withEnv(["MAVEN_ARGS=${env.MAVEN_ARGS?:""} ${env.MAVEN_CONFIG}"]) {
64-
sh "./mvnw -pl !docs -Dquickly install"
65-
// Need to kill the gradle daemons started during the Maven install run
66-
sh "sudo pkill -f '.*GradleDaemon.*' || true"
67-
// Need to override the default maven configuration this way, because there is no other way to do it
68-
sh "sed -i 's/-Xmx2048m/-Xmx1340m/' ./.mvn/jvm.config"
69-
sh "sed -i 's/MaxMetaspaceSize=1024m/MaxMetaspaceSize=512m/' ./.mvn/jvm.config"
70-
def excludes = "'!integration-tests/kafka-oauth-keycloak,!integration-tests/kafka-sasl-elytron,!integration-tests/hibernate-search-orm-opensearch,!integration-tests/hibernate-search-orm-elasticsearch-outbox-polling,!integration-tests/hibernate-search-orm-elasticsearch-tenancy,!integration-tests/maven,!integration-tests/quartz,!integration-tests/reactive-messaging-kafka,!integration-tests/resteasy-reactive-kotlin/standard,!integration-tests/opentelemetry-reactive-messaging,!integration-tests/virtual-threads/kafka-virtual-threads,!integration-tests/smallrye-jwt-oidc-webapp,!extensions/oidc-db-token-state-manager/deployment,!docs'"
71-
sh "TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED=true ./mvnw -Dinsecure.repositories=WARN -pl :quarkus-hibernate-orm -amd -pl ${excludes} verify -Dstart-containers -Dtest-containers -Dskip.gradle.build"
113+
dir(env.WORKSPACE_TMP) {
114+
stash name: 'repository', includes: ".m2repository/"
115+
}
116+
}
117+
}
118+
}
119+
stage('Build Quarkus') {
120+
agent {
121+
label 'LongDuration'
122+
}
123+
tools {
124+
jdk QUARKUS_JDK_TOOL
125+
maven 'Apache Maven 3.9'
126+
}
127+
steps {
128+
script {
129+
Map<String, Closure> executions = [:]
130+
131+
configurations.each { BuildConfiguration configuration ->
132+
executions.put(configuration.name, {
133+
node( 'LongDuration' ) {
134+
dir(env.WORKSPACE_TMP) {
135+
unstash "repository"
136+
}
137+
// Workaround issues when path contains @ character
138+
dir(env.WORKSPACE) {
139+
// Remove previous soft-link if it is around
140+
sh "rm .m2 || true"
141+
sh "ln -s ${env.WORKSPACE_TMP}/.m2repository .m2"
142+
}
143+
dir('quarkus') {
144+
def quarkusVersionToTest = '3.27'
145+
sh "git clone -b ${quarkusVersionToTest} --single-branch https://github.com/quarkusio/quarkus.git . || git reset --hard && git clean -fx && git pull"
146+
script {
147+
def sedStatus = sh (script: "sed -i 's@<hibernate-orm.version>.*</hibernate-orm.version>@<hibernate-orm.version>${env.HIBERNATE_VERSION}</hibernate-orm.version>@' pom.xml", returnStatus: true)
148+
if ( sedStatus != 0 ) {
149+
throw new IllegalArgumentException( "Unable to replace hibernate version in Quarkus pom. Got exit code $sedStatus" )
150+
}
151+
}
152+
// Need to override the default maven configuration this way, because there is no other way to do it
153+
sh "sed -i 's/-Xmx5g/-Xmx2048m/' ./.mvn/jvm.config"
154+
sh "echo -e '\\n-XX:MaxMetaspaceSize=1024m'>>./.mvn/jvm.config"
155+
withMaven(mavenLocalRepo: env.WORKSPACE + '/.m2', publisherStrategy: 'EXPLICIT') {
156+
def javaHome = tool(name: QUARKUS_JDK_TOOL, type: 'jdk')
157+
// to account for script-only maven wrapper use in Quarkus:
158+
withEnv(["JAVA_HOME=${javaHome}", "PATH+JAVA=${javaHome}/bin", "MAVEN_ARGS=${env.MAVEN_ARGS?:""} ${env.MAVEN_CONFIG}"]) {
159+
sh "./mvnw -pl !docs -Dquickly install"
160+
// Need to kill the gradle daemons started during the Maven install run
161+
sh "sudo pkill -f '.*GradleDaemon.*' || true"
162+
// Need to override the default maven configuration this way, because there is no other way to do it
163+
sh "sed -i 's/-Xmx2048m/-Xmx1340m/' ./.mvn/jvm.config"
164+
sh "sed -i 's/MaxMetaspaceSize=1024m/MaxMetaspaceSize=512m/' ./.mvn/jvm.config"
165+
def projects = configuration.projects
166+
def additionalArguments
167+
def additionalOptions
168+
if ( configuration.nativeProfile ) {
169+
additionalArguments = "-f integration-tests"
170+
additionalOptions = "-Dquarkus.native.native-image-xmx=6g -Dnative -Dnative.surefire.skip -Dno-descriptor-tests"
171+
}
172+
else {
173+
additionalArguments = "-pl :quarkus-hibernate-orm -amd"
174+
additionalOptions = ""
175+
}
176+
sh "TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED=true ./mvnw -Dinsecure.repositories=WARN ${additionalArguments} -pl '${projects}' verify -Dstart-containers -Dtest-containers -Dskip.gradle.build ${additionalOptions}"
177+
}
178+
}
179+
}
72180
}
73-
}
181+
})
74182
}
183+
parallel executions
75184
}
76185
}
77186
}

0 commit comments

Comments
 (0)