diff --git a/config/presubmits.py b/config/presubmits.py index 5ab7e4aeb..ca733456f 100644 --- a/config/presubmits.py +++ b/config/presubmits.py @@ -25,7 +25,7 @@ import textwrap import re # We should never analyze any generated files -UNIVERSALLY_SKIPPED_PATTERNS = {"/build/", "cloudbuild-caches", "/out/", ".git/", ".gradle/", "/dist/", "karma.conf.js", "polyfills.ts", "test.ts", "/docs/console-endpoints/"} +UNIVERSALLY_SKIPPED_PATTERNS = {"/build/", "cloudbuild-caches", "/out/", ".git/", ".gradle/", "/dist/", "/console-alpha/", "/console-crash/", "/console-qa", "/console-sandbox", "/console-production", "karma.conf.js", "polyfills.ts", "test.ts", "/docs/console-endpoints/"} # We can't rely on CI to have the Enum package installed so we do this instead. FORBIDDEN = 1 REQUIRED = 2 diff --git a/console-webapp/.gitignore b/console-webapp/.gitignore index 51a72ba1a..ecc2f26bf 100644 --- a/console-webapp/.gitignore +++ b/console-webapp/.gitignore @@ -44,3 +44,4 @@ Thumbs.db # Build artifact /staged/dist +/staged/console-* diff --git a/console-webapp/angular.json b/console-webapp/angular.json index 2f9f98141..87b807ad4 100644 --- a/console-webapp/angular.json +++ b/console-webapp/angular.json @@ -96,11 +96,17 @@ "sourceMap": true, "namedChunks": true }, - "development": { + "qa": { "optimization": false, "extractLicenses": false, "sourceMap": true, "namedChunks": true + }, + "development": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true, } }, "defaultConfiguration": "production" @@ -120,6 +126,9 @@ "sandbox": { "buildTarget": "console-webapp:build:sandbox" }, + "qa": { + "buildTarget": "console-webapp:build:qa" + }, "development": { "buildTarget": "console-webapp:build:development" } diff --git a/console-webapp/build.gradle b/console-webapp/build.gradle index 37f0f05a2..f0c04c988 100644 --- a/console-webapp/build.gradle +++ b/console-webapp/build.gradle @@ -47,6 +47,48 @@ task buildConsoleWebapp(type: Exec) { } } +task buildConsoleForAll() {} + +def createConsoleTask = { env -> + project.tasks.register("buildConsoleFor${env.capitalize()}", Exec) { + workingDir "${consoleDir}/" + executable 'npm' + args 'run', 'build', "--configuration=${env}" + doFirst { + println "Building console for environment: ${env}" + } + doLast { + copy { + from "${consoleDir}/staged/dist/" + into "${consoleDir}/staged/console-${env}" + } + delete "${consoleDir}/staged/dist" + } + dependsOn(tasks.npmInstallDeps) + } + project.tasks.register("deleteConsoleFor${env.capitalize()}", Delete) { + delete "${consoleDir}/staged/console-${env}" + } + tasks.named('clean') { + dependsOn(tasks.named("deleteConsoleFor${env.capitalize()}")) + } + tasks.named('buildConsoleForAll') { + dependsOn(tasks.named("buildConsoleFor${env.capitalize()}")) + } +} + +['alpha', 'crash', 'qa', 'sandbox', 'production'].forEach {env -> + createConsoleTask(env) +} + +// Force an order so we don't run these tasks in parallel. +tasks.buildConsoleForCrash.mustRunAfter(tasks.buildConsoleForAlpha) +tasks.buildConsoleForQa.mustRunAfter(tasks.buildConsoleForCrash) +tasks.buildConsoleForSandbox.mustRunAfter(tasks.buildConsoleForQa) +tasks.buildConsoleForProduction.mustRunAfter(tasks.buildConsoleForSandbox) +// This task must run last, otherwise the previous tasks will have deleted the "dist" folder. +tasks.buildConsoleWebapp.mustRunAfter(tasks.buildConsoleForProduction) + task applyFormatting(type: Exec) { workingDir "${consoleDir}/" executable 'npm' diff --git a/core/build.gradle b/core/build.gradle index 8205bb3d8..2d5e78f3e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -687,6 +687,7 @@ artifacts { task runTestServer(type: JavaExec) { main = 'google.registry.server.RegistryTestServerMain' classpath = sourceSets.test.runtimeClasspath + dependsOn(rootProject.project('console-webapp').tasks.named('buildConsoleWebapp')) } /** diff --git a/jetty/build.gradle b/jetty/build.gradle index 3f8d216c6..9af6f8cc6 100644 --- a/jetty/build.gradle +++ b/jetty/build.gradle @@ -37,11 +37,11 @@ dependencies { } tasks.register('copyConsole', Copy) { - from("${rootDir}/console-webapp/staged/dist") { - include "**/*" + from("${rootDir}/console-webapp/staged/") { + include "console-*/*" } - into layout.buildDirectory.dir('jetty-base/webapps/console') - dependsOn(':console-webapp:buildConsoleWebapp') + into layout.buildDirectory.dir('jetty-base/webapps/') + dependsOn(':console-webapp:buildConsoleForAll') } tasks.register('stage') { diff --git a/jetty/start.sh b/jetty/start.sh index a2c0be1e7..79c1dc848 100755 --- a/jetty/start.sh +++ b/jetty/start.sh @@ -13,8 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -environment=$1 +env=${1:-"alpha"} cd /jetty-base -java -Dgoogle.registry.environment=${environment:-"alpha"} \ +cp -rf webapps/console-${env} webapps/console +echo "Running ${env}" +java -Dgoogle.registry.environment=${env} \ -Djava.util.logging.config.file=/logging.properties \ -jar /usr/local/jetty/start.jar