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.
153 lines
5.4 KiB
Groovy
153 lines
5.4 KiB
Groovy
// Copyright 2024 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.
|
|
|
|
apply plugin: 'war'
|
|
|
|
tasks.register('copyJettyBase', Copy) {
|
|
from(layout.projectDirectory.dir('src/main')) {
|
|
include 'jetty-base/**'
|
|
}
|
|
into layout.buildDirectory
|
|
}
|
|
|
|
war {
|
|
setArchiveBaseName("nomulus")
|
|
setDestinationDirectory(layout.buildDirectory.dir('jetty-base/webapps'))
|
|
dependsOn(tasks.named('copyJettyBase'))
|
|
}
|
|
|
|
tasks.named('compileTestJava') {
|
|
// Gradle insists on this execution dependency.
|
|
dependsOn(tasks.named('copyJettyBase'))
|
|
}
|
|
|
|
jar {
|
|
dependsOn(tasks.named('copyJettyBase'))
|
|
from(project(':core').tasks.named('jar'))
|
|
}
|
|
|
|
tasks.withType(tasks.shadowJar.class).configureEach {
|
|
dependsOn(tasks.named('copyJettyBase'))
|
|
}
|
|
|
|
dependencies {
|
|
implementation project(':core')
|
|
}
|
|
|
|
tasks.register('copyConsole', Copy) {
|
|
from("${rootDir}/console-webapp/staged/") {
|
|
include "console-*/", "console-*/**"
|
|
}
|
|
into layout.buildDirectory.dir('jetty-base/webapps/')
|
|
dependsOn(':console-webapp:buildConsoleForAll')
|
|
}
|
|
|
|
tasks.register('stage') {
|
|
dependsOn(tasks.named('war'))
|
|
dependsOn(tasks.named('copyConsole'))
|
|
}
|
|
|
|
tasks.register('buildNomulusImage', Exec) {
|
|
commandLine 'docker', 'build', '-t', 'nomulus', '.', '--pull'
|
|
dependsOn(tasks.named('stage'))
|
|
}
|
|
|
|
tasks.register('tagNomulusImage', Exec) {
|
|
commandLine 'docker', 'tag', 'nomulus', "gcr.io/${rootProject.gcpProject}/nomulus"
|
|
dependsOn(tasks.named('buildNomulusImage'))
|
|
}
|
|
|
|
tasks.register('pushNomulusImage', Exec) {
|
|
configure verifyDeploymentConfig
|
|
commandLine 'docker', 'push', "gcr.io/${rootProject.gcpProject}/nomulus"
|
|
dependsOn(tasks.named('tagNomulusImage'))
|
|
}
|
|
|
|
tasks.register('run', JavaExec) {
|
|
// We do the check when the task actually runs, not when we define it.
|
|
// This way if one doesn't set the value, one can still run other tasks.
|
|
doFirst {
|
|
def jetty_home = System.getenv('JETTY_HOME')
|
|
if (jetty_home == null) {
|
|
throw new GradleException('JETTY_HOME is not set.')
|
|
}
|
|
}
|
|
def jetty_home = System.getenv('JETTY_HOME')
|
|
def environment = rootProject.environment
|
|
jvmArgs "--sun-misc-unsafe-memory-access=allow", "--enable-native-access=ALL-UNNAMED"
|
|
workingDir(layout.buildDirectory.dir('jetty-base'))
|
|
classpath = files(jetty_home + '/start.jar')
|
|
systemProperty('google.registry.environment', environment)
|
|
systemProperty('java.util.logging.config.file', "${projectDir}/logging.properties")
|
|
dependsOn(tasks.named('stage'))
|
|
}
|
|
|
|
tasks.register('buildDeployer', Exec) {
|
|
workingDir("${rootDir}/release/builder/")
|
|
commandLine 'go', 'build', '-o', "${buildDir}/deployer", 'deployCloudSchedulerAndQueue.go'
|
|
}
|
|
|
|
// Once GKE is the only option, we can use the same task in the root project instead.
|
|
tasks.register('deployCloudSchedulerAndQueue') {
|
|
configure verifyDeploymentConfig
|
|
dependsOn(tasks.named('deployCloudScheduler'), tasks.named('deployQueue'))
|
|
}
|
|
|
|
tasks.register('deployCloudScheduler', Exec) {
|
|
dependsOn(tasks.named('buildDeployer'))
|
|
workingDir("$buildDir")
|
|
commandLine './deployer',
|
|
"${rootDir}/core/src/main/java/google/registry/config/files/nomulus-config-${rootProject.environment}.yaml",
|
|
"${rootDir}/core/src/main/java/google/registry/config/files/tasks/cloud-scheduler-tasks-${rootProject.environment}.xml",
|
|
rootProject.gcpProject == null ? "gcpProject" : rootProject.gcpProject,
|
|
'--gke'
|
|
// Only deploy the tasks after Nomulus itself is deployed.
|
|
mustRunAfter(tasks.named('deployToGke'))
|
|
}
|
|
|
|
tasks.register('deployQueue', Exec) {
|
|
dependsOn(tasks.named('buildDeployer'))
|
|
workingDir("$buildDir")
|
|
commandLine './deployer',
|
|
"${rootDir}/core/src/main/java/google/registry/config/files/nomulus-config-${rootProject.environment}.yaml",
|
|
"${rootDir}/core/src/main/java/google/registry/config/files/cloud-tasks-queue.xml",
|
|
rootProject.gcpProject == null ? "gcpProject" : rootProject.gcpProject,
|
|
'--gke'
|
|
// Only deploy the queues after Nomulus itself is deployed.
|
|
mustRunAfter(tasks.named('deployToGke'))
|
|
}
|
|
|
|
tasks.register('deployToGke', Exec) {
|
|
dependsOn('pushNomulusImage', ':proxy:pushProxyImage')
|
|
commandLine './deploy-nomulus-for-env.sh', "${rootProject.environment}", "${rootProject.baseDomain}"
|
|
}
|
|
|
|
tasks.register('deployNomulus') {
|
|
dependsOn('deployToGke', 'deployCloudSchedulerAndQueue')
|
|
}
|
|
|
|
tasks.register('getEndpoints', Exec) {
|
|
doFirst {
|
|
if (rootProject.ext.gcpProject == null) {
|
|
def error = 'You must specify -Penvironment={alpha,crash,qa}'
|
|
System.err.println("\033[33;1m${error}\033[0m")
|
|
throw GradleException("Aborting: ${error}")
|
|
}
|
|
}
|
|
commandLine './get-endpoints.py', "${rootProject.gcpProject}"
|
|
}
|
|
|
|
project.build.dependsOn(tasks.named('buildNomulusImage'))
|
|
rootProject.deploy.dependsOn(tasks.named('deployNomulus'))
|