-
-
Notifications
You must be signed in to change notification settings - Fork 970
ci: run all functional tests against both Hibernate 5.6 and 7.2 #15561
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
base: 8.0.x-hibernate7
Are you sure you want to change the base?
Changes from 3 commits
d7d9e7d
e2336d9
f587be1
fbfe66b
a458c4a
707c33d
a63dcad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,27 @@ rootProject.subprojects | |
| .findAll { !(it.name in testProjects) && !(it.name in docProjects) && !(it.name in cliProjects) } | ||
| .each { project.evaluationDependsOn(it.path) } | ||
|
|
||
| // Determine which Hibernate version to use for general functional tests. | ||
| // Pass -PhibernateVersion=7 to run general functional tests against Hibernate 7 instead of 5. | ||
| def targetHibernateVersion = project.findProperty('hibernateVersion') ?: '5' | ||
| boolean isHibernateSpecificProject = project.name.startsWith('grails-test-examples-hibernate5') || | ||
| project.name.startsWith('grails-test-examples-hibernate7') | ||
| boolean isMongoProject = project.name.startsWith('grails-test-examples-mongodb') | ||
| boolean isGeneralFunctionalTest = !isHibernateSpecificProject && !isMongoProject | ||
|
|
||
| // General functional test projects that use Hibernate 5-specific GORM APIs and cannot run | ||
| // under Hibernate 7 via dependency substitution. These use executeUpdate(String) without | ||
| // parameters (H7 requires a Map parameter), HibernateSpec unit tests (different domain class | ||
| // detection in H7), or ChainedTransactionManager behavior that changed in H7. | ||
| // Their H7-compatible equivalents live in grails-test-examples/hibernate7/. | ||
| List<String> h7IncompatibleProjects = [ | ||
| 'grails-test-examples-app1', | ||
| 'grails-test-examples-datasources', | ||
| 'grails-test-examples-gorm', | ||
| 'grails-test-examples-views-functional-tests', | ||
| 'grails-test-examples-scaffolding-fields', | ||
| ] | ||
|
|
||
| configurations.configureEach { | ||
| resolutionStrategy.dependencySubstitution { | ||
| // Test projects will often include dependencies from local projects. This will ensure any dependencies | ||
|
|
@@ -51,6 +72,22 @@ configurations.configureEach { | |
| } | ||
| } | ||
| } | ||
|
|
||
| // For general (non-hibernate-labeled) functional test projects, redirect Hibernate 5 dependencies | ||
| // to Hibernate 7 projects when -PhibernateVersion=7 is set. These rules are added after the loop | ||
| // so they override the default substitutions for the h5 modules. | ||
| // Projects in h7IncompatibleProjects are excluded since they use H5-specific GORM APIs. | ||
| if (isGeneralFunctionalTest && targetHibernateVersion == '7' && !(project.name in h7IncompatibleProjects)) { | ||
| substitute module('org.apache.grails:grails-data-hibernate5') using project(':grails-data-hibernate7') | ||
| substitute module('org.apache.grails:grails-data-hibernate5-spring-boot') using project(':grails-data-hibernate7-spring-boot') | ||
| } | ||
| } | ||
|
|
||
| // Exclude Hibernate 5-specific runtime dependencies when testing general projects with Hibernate 7. | ||
| // These libraries have no Hibernate 7 equivalent and would cause classpath conflicts. | ||
| if (isGeneralFunctionalTest && targetHibernateVersion == '7' && !(project.name in h7IncompatibleProjects)) { | ||
| exclude group: 'org.hibernate', module: 'hibernate-ehcache' | ||
| exclude group: 'org.jboss.spec.javax.transaction', module: 'jboss-transaction-api_1.3_spec' | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -68,6 +105,11 @@ tasks.withType(Test).configureEach { Test task -> | |
| return false | ||
| } | ||
|
|
||
| // Skip projects with known H7 API incompatibilities when running with hibernateVersion=7 | ||
| if (targetHibernateVersion == '7' && project.name in h7IncompatibleProjects) { | ||
| return false | ||
| } | ||
|
|
||
| if (project.hasProperty('onlyHibernate5Tests')) { | ||
| if (isHibernate5) { | ||
| return false | ||
|
|
@@ -80,6 +122,20 @@ tasks.withType(Test).configureEach { Test task -> | |
| } | ||
| } | ||
|
|
||
| // Skip hibernate5-labeled projects when -PskipHibernate5Tests is set | ||
| if (project.hasProperty('skipHibernate5Tests')) { | ||
| if (!isHibernate5) { | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| // Skip hibernate7-labeled projects when -PskipHibernate7Tests is set | ||
| if (project.hasProperty('skipHibernate7Tests')) { | ||
| if (!isHibernate7) { | ||
| return false | ||
| } | ||
| } | ||
|
Comment on lines
+121
to
+133
|
||
|
|
||
| if (project.hasProperty('onlyMongodbTests')) { | ||
| if (isMongo) { | ||
| return false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| org.grails.datastore.gorm.boot.autoconfigure.HibernateGormAutoConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hibernateVersionis accepted as an arbitrary string and silently falls back to “Hibernate 5 behavior” for any value other than'7'. That can hide typos/misconfiguration (especially for local runs). Consider normalizing + validating the value (e.g., allow only'5'/'7'and throw aGradleExceptionotherwise) so the build fails fast when an unsupported value is provided.