1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 06:15:42 +00:00
Files
nomulus/integration/build.gradle
Weimin Yu fd51035f23 Stop depending on GCS public access for Kokoro (#2907)
We used to publish test artifacts to a Maven repo on GCS, for use by
schema tests. For this to work with Kokoro, the GCS bucket must be
accessible to all users.

To comply with the no-public-user requirement, we store the necessary
jars at at well-known bucket and map them into Kokoro. This strategy
cannot be used on the Maven repo because only a small number of files
with fixed names may be mapped. With the Maven repo, there are too many
files to map.
2025-12-17 20:55:03 +00:00

101 lines
3.4 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'
}
}
// TODO(weiminyu): inherit from FilteringTest (defined in :core).
task sqlIntegrationTest(type: Test) {
// Explicitly choose JUnit 4 for test suites. See :core:sqlIntegrationTest for details.
useJUnit()
testClassesDirs = files(unpackedTestDir)
classpath = configurations.testRuntimeClasspath
include 'google/registry/schema/integration/SqlIntegrationTestSuite.*'
dependsOn extractSqlIntegrationTestSuite
finalizedBy tasks.create('removeUnpackedTests') {
doLast {
delete file(unpackedTestDir)
}
}
// Disable incremental build/test since Gradle cannot detect changes
// in dependencies on its own. Will not fix since this test is typically
// run once (in presubmit or ci tests).
outputs.upToDateWhen { false }
}