mirror of
https://github.com/google/nomulus
synced 2026-06-09 16:33:02 +00:00
75524fd403
This commit reverts changes from5599a0eb3dand most of5286b1a0dc(PR #3068) that stripped essential dependencies (buildConsoleForAll, buildNomulusImage, buildToolImage, fragileTest) from the default './gradlew build' target, which broke downstream deployment pipelines. It restores the default build to correctly generate all necessary production artifacts and Docker images. It introduces a new 'fastBuild' target designed explicitly for local developers and CI checks. This lightweight target disables the execution of heavy Docker image builds, Angular compilations, and fragile tests to provide rapid feedback. Sequential execution constraints for parallel Angular builds are maintained to prevent cache corruption. It updates the ':core:generateSqlSchema' task to execute using the 'unittest' environment instead of 'alpha'. The 'alpha' configuration is a private, internal environment config that is not distributed in the open-source repository, which caused the task to fail for public contributors. By switching to 'unittest', the generator can successfully run using the public test configuration. With this fixed, it also includes the newly generated 'db-schema.sql.generated' file, which now correctly tracks the 'FORBID_INSECURE_ALGORITHMS_RFC_9904' feature flag that was recently added. Finally, it implements a split-runner execution strategy for the 'sqlIntegrationTest' task to permanently resolve 'failed to discover tests' and 'NoSuchMethodError' exceptions on Kokoro. Because Kokoro tests cross-version compatibility against both legacy deployed artifacts (compiled with JUnit 4 @RunWith wrappers) and modern artifacts (compiled with JUnit 5 @Suite annotations), we cannot statically configure a single test runner. We now dynamically run both the legacy 'useJUnit()' and modern 'useJUnitPlatform()' runners sequentially with 'failOnNoDiscoveredTests' disabled, allowing the appropriate engine to discover and execute the suite without causing classpath collisions.
131 lines
5.1 KiB
Groovy
131 lines
5.1 KiB
Groovy
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// This source-less project is used to run cross-release server/SQL integration
|
|
// tests. See the README.md file in this folder for more information.
|
|
|
|
import static com.google.common.base.Preconditions.checkArgument
|
|
import static com.google.common.base.Strings.isNullOrEmpty
|
|
|
|
if (schema_env == '' || nomulus_env == '') {
|
|
return
|
|
}
|
|
|
|
def USE_LOCAL = 'local'
|
|
|
|
if (schema_env != USE_LOCAL || nomulus_env != USE_LOCAL) {
|
|
checkArgument(
|
|
!isNullOrEmpty(schemaTestArtifactsDir),
|
|
'The schemaTestArtifactsDir is required when deployed jars are needed.')
|
|
}
|
|
|
|
def testUberJarName = ''
|
|
|
|
// Might need to add this back if we re-add nebula-lint
|
|
// gradleLint.ignore('unused-dependency') {
|
|
dependencies {
|
|
if (schema_env == USE_LOCAL) {
|
|
testRuntimeOnly project(path: ':db', configuration: 'schema')
|
|
} else {
|
|
testRuntimeOnly files("${project.schemaTestArtifactsDir}/schema.${schema_env}.jar")
|
|
}
|
|
if (nomulus_env == USE_LOCAL) {
|
|
testRuntimeOnly project(path: ':core', configuration: 'nomulus_test')
|
|
testUberJarName = 'nomulus-tests-alldeps.jar'
|
|
} else {
|
|
testRuntimeOnly files("${project.schemaTestArtifactsDir}/nomulus-public.${nomulus_env}.jar")
|
|
testRuntimeOnly files("${project.schemaTestArtifactsDir}/nomulus-tests-alldeps.${nomulus_env}.jar")
|
|
testUberJarName = "nomulus-tests-alldeps.${nomulus_env}.jar"
|
|
}
|
|
}
|
|
// }
|
|
|
|
configurations.testRuntimeOnly.transitive = false
|
|
|
|
def unpackedTestDir = "${projectDir}/build/unpackedTests/${nomulus_env}"
|
|
|
|
// Extracts SqlIntegrationTestSuite.class to a temp folder. Gradle's test
|
|
// runner only looks for runnable tests on a regular file system. However,
|
|
// it can load member classes of test suites from jars.
|
|
task extractSqlIntegrationTestSuite (type: Copy) {
|
|
doFirst {
|
|
file(unpackedTestDir).mkdirs()
|
|
}
|
|
outputs.dir unpackedTestDir
|
|
from zipTree(
|
|
configurations.testRuntimeClasspath
|
|
.filter { it.name == testUberJarName}
|
|
.singleFile).matching {
|
|
include 'google/registry/**/SqlIntegrationTestSuite.class'
|
|
}
|
|
into unpackedTestDir
|
|
includeEmptyDirs = false
|
|
|
|
if (nomulus_env == USE_LOCAL) {
|
|
dependsOn ':core:testUberJar'
|
|
}
|
|
}
|
|
|
|
task removeUnpackedTests {
|
|
doLast {
|
|
delete file(unpackedTestDir)
|
|
}
|
|
}
|
|
|
|
task sqlIntegrationTestLegacy(type: Test) {
|
|
useJUnit()
|
|
testClassesDirs = files(unpackedTestDir)
|
|
classpath = configurations.testRuntimeClasspath
|
|
include 'google/registry/schema/integration/SqlIntegrationTestSuite.*'
|
|
dependsOn extractSqlIntegrationTestSuite
|
|
// Prevent build failures when evaluating newer JUnit 5 artifacts that have no JUnit 4 tests.
|
|
failOnNoDiscoveredTests = false
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
task sqlIntegrationTestModern(type: Test) {
|
|
useJUnitPlatform()
|
|
testClassesDirs = files(unpackedTestDir)
|
|
classpath = configurations.testRuntimeClasspath
|
|
include 'google/registry/schema/integration/SqlIntegrationTestSuite.*'
|
|
dependsOn extractSqlIntegrationTestSuite
|
|
// Prevent build failures when evaluating older JUnit 4 artifacts that have no JUnit 5 tests.
|
|
failOnNoDiscoveredTests = false
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
// TODO(weiminyu): inherit from FilteringTest (defined in :core).
|
|
task sqlIntegrationTest {
|
|
// Kokoro runs cross-version compatibility tests against both older deployed artifacts
|
|
// (which use the legacy JUnit 4 @RunWith wrapper) and newer deployed artifacts (which use
|
|
// the JUnit 5 @Suite annotation). We cannot statically configure the test runner because
|
|
// we do not know which runner the downloaded artifact expects, nor can we inject the
|
|
// modern junit-platform-suite engine dependency without causing a classpath collision
|
|
// with older embedded engine APIs.
|
|
// To solve this, we execute both test runners sequentially and ignore "no tests discovered"
|
|
// errors. The runner compatible with the artifact will discover and execute the tests,
|
|
// while the incompatible runner will safely no-op.
|
|
//
|
|
// TODO: Remove this split fallback once all deployed environments (sandbox, qa, production)
|
|
// are running a Nomulus release built after the JUnit 5 @Suite migration.
|
|
// When that happens:
|
|
// 1. Delete the 'sqlIntegrationTestLegacy' and 'sqlIntegrationTestModern' tasks entirely.
|
|
// 2. Change this task back to: task sqlIntegrationTest(type: Test) { ... }
|
|
// 3. Add 'useJUnitPlatform()' unconditionally inside it.
|
|
// 4. Move the 'testClassesDirs', 'classpath', 'include', and 'outputs.upToDateWhen'
|
|
// configurations back into it.
|
|
dependsOn sqlIntegrationTestLegacy, sqlIntegrationTestModern
|
|
finalizedBy removeUnpackedTests
|
|
}
|