disable translations for Jenkins build
refs DE-517 Disable locales on pre-merge Jenkins build in order to save ~25s on builds that require webpack to recompile. This also lets us clean up the code that builds the js-runner image. Pre-merge builds will still verify the i18n tasks in the Linters job, and post-merge builds will continue to build / run all tests using locales. [build-registry-path=jenkins/canvas-lms/de-517] [change-merged] Change-Id: I8ded5d675b72d713738307403502f459adc79a73 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/258197 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Andrea Cirulli <andrea.cirulli@instructure.com> Reviewed-by: James Butters <jbutters@instructure.com> QA-Review: Aaron Ogata <aogata@instructure.com> Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
parent
70a0336523
commit
7d73da5f3f
|
@ -1,9 +1,14 @@
|
|||
# syntax=docker/dockerfile:experimental
|
||||
|
||||
ARG PATCHSET_TAG
|
||||
FROM $PATCHSET_TAG AS patchset
|
||||
|
||||
FROM local/karma-builder
|
||||
|
||||
USER docker
|
||||
RUN --mount=type=bind,target=/tmp/src,source=/usr/src/app,from=patchset \
|
||||
cp -rf /tmp/src/. /usr/src/app
|
||||
COPY --chown=docker:docker . /usr/src/app
|
||||
RUN cp -v docker-compose/config/redis.yml config && \
|
||||
cp -v docker-compose/config/selenium.yml config/ && \
|
||||
cp -vR docker-compose/config/new-jenkins/* config/ && \
|
||||
cp -v config/delayed_jobs.yml.example config/delayed_jobs.yml && \
|
||||
cp -v config/domain.yml.example config/domain.yml && \
|
||||
cp -v config/external_migration.yml.example config/external_migration.yml && \
|
||||
cp -v config/outgoing_mail.yml.example config/outgoing_mail.yml
|
||||
|
||||
ARG RAILS_LOAD_ALL_LOCALES=0
|
||||
RUN bash -c "if [[ "$RAILS_LOAD_ALL_LOCALES" == "1" ]]; then bundle exec rails i18n:generate_js; fi"
|
||||
|
|
|
@ -2,7 +2,8 @@ FROM local/webpack-builder AS webpack-runner
|
|||
COPY --chown=docker:docker --from=local/cache-helper-collect-webpack /tmp/dst ${APP_HOME}
|
||||
|
||||
ARG JS_BUILD_NO_UGLIFY=0
|
||||
RUN COMPILE_ASSETS_API_DOCS=0 COMPILE_ASSETS_NPM_INSTALL=0 COMPILE_ASSETS_STYLEGUIDE=0 JS_BUILD_NO_UGLIFY="$JS_BUILD_NO_UGLIFY" bundle exec rails canvas:compile_assets
|
||||
ARG RAILS_LOAD_ALL_LOCALES=0
|
||||
RUN COMPILE_ASSETS_API_DOCS=0 COMPILE_ASSETS_NPM_INSTALL=0 COMPILE_ASSETS_STYLEGUIDE=0 JS_BUILD_NO_UGLIFY="$JS_BUILD_NO_UGLIFY" RAILS_LOAD_ALL_LOCALES="$RAILS_LOAD_ALL_LOCALES" bundle exec rails canvas:compile_assets
|
||||
|
||||
FROM local/ruby-runner AS webpack-cache
|
||||
COPY --chown=docker:docker --from=webpack-runner /usr/src/app/public ${APP_HOME}/public
|
||||
|
|
|
@ -476,6 +476,7 @@ pipeline {
|
|||
"CACHE_UNIQUE_SCOPE=${env.IMAGE_CACHE_UNIQUE_SCOPE}",
|
||||
"COMPILE_ADDITIONAL_ASSETS=${configuration.isChangeMerged() ? 1 : 0}",
|
||||
"JS_BUILD_NO_UGLIFY=${configuration.isChangeMerged() ? 0 : 1}",
|
||||
"RAILS_LOAD_ALL_LOCALES=${configuration.isChangeMerged() ? 1 : 0}",
|
||||
"RUBY_RUNNER_PREFIX=${env.RUBY_RUNNER_PREFIX}",
|
||||
"WEBPACK_BUILDER_PREFIX=${env.WEBPACK_BUILDER_PREFIX}",
|
||||
"WEBPACK_CACHE_PREFIX=${env.WEBPACK_CACHE_PREFIX}",
|
||||
|
@ -564,6 +565,7 @@ pipeline {
|
|||
"CACHE_SAVE_SCOPE=${env.IMAGE_CACHE_MERGE_SCOPE}",
|
||||
"COMPILE_ADDITIONAL_ASSETS=0",
|
||||
"JS_BUILD_NO_UGLIFY=1",
|
||||
"RAILS_LOAD_ALL_LOCALES=0",
|
||||
"RUBY_RUNNER_PREFIX=${env.RUBY_RUNNER_PREFIX}",
|
||||
"WEBPACK_BUILDER_PREFIX=${env.WEBPACK_BUILDER_PREFIX}",
|
||||
"WEBPACK_CACHE_PREFIX=${env.WEBPACK_CACHE_PREFIX}",
|
||||
|
@ -630,6 +632,7 @@ pipeline {
|
|||
"CACHE_SAVE_SCOPE=${cacheScope}",
|
||||
"KARMA_BUILDER_PREFIX=${env.KARMA_BUILDER_PREFIX}",
|
||||
"PATCHSET_TAG=${env.PATCHSET_TAG}",
|
||||
"RAILS_LOAD_ALL_LOCALES=${configuration.isChangeMerged() ? 1 : 0}",
|
||||
"WEBPACK_BUILDER_IMAGE=${env.WEBPACK_BUILDER_IMAGE}",
|
||||
]) {
|
||||
sh "./build/new-jenkins/js/docker-build.sh $KARMA_RUNNER_IMAGE"
|
||||
|
|
|
@ -62,6 +62,10 @@ def cleanupFn() {
|
|||
}
|
||||
}
|
||||
|
||||
def getLoadAllLocales() {
|
||||
return configuration.isChangeMerged() ? 1 : 0
|
||||
}
|
||||
|
||||
pipeline {
|
||||
agent none
|
||||
options {
|
||||
|
@ -76,6 +80,7 @@ pipeline {
|
|||
DOCKER_BUILDKIT=1
|
||||
FORCE_FAILURE = configuration.forceFailureJS()
|
||||
PROGRESS_NO_TRUNC=1
|
||||
RAILS_LOAD_ALL_LOCALES = getLoadAllLocales()
|
||||
SENTRY_URL="https://sentry.insops.net"
|
||||
SENTRY_ORG="instructure"
|
||||
SENTRY_PROJECT="master-javascript-build"
|
||||
|
|
|
@ -65,6 +65,7 @@ RUBY_RUNNER_BUILD_ARGS=(
|
|||
)
|
||||
WEBPACK_CACHE_BUILD_ARGS=(
|
||||
--build-arg JS_BUILD_NO_UGLIFY="$JS_BUILD_NO_UGLIFY"
|
||||
--build-arg RAILS_LOAD_ALL_LOCALES="$RAILS_LOAD_ALL_LOCALES"
|
||||
)
|
||||
RUBY_RUNNER_PARTS=(
|
||||
$BASE_IMAGE_ID
|
||||
|
|
|
@ -40,10 +40,12 @@ tag_many $KARMA_BUILDER_SELECTED_TAG local/karma-builder ${KARMA_BUILDER_TAGS[SA
|
|||
|
||||
DOCKER_BUILDKIT=1 docker build \
|
||||
--build-arg PATCHSET_TAG="$PATCHSET_TAG" \
|
||||
--build-arg RAILS_LOAD_ALL_LOCALES="$RAILS_LOAD_ALL_LOCALES" \
|
||||
--file Dockerfile.jenkins.karma-runner \
|
||||
--label "KARMA_BUILDER_SELECTED_TAG=$KARMA_BUILDER_SELECTED_TAG" \
|
||||
--label "PATCHSET_TAG=$PATCHSET_TAG" \
|
||||
--label "WEBPACK_BUILDER_IMAGE=$WEBPACK_BUILDER_IMAGE" \
|
||||
--tag "$1" \
|
||||
- < Dockerfile.jenkins.karma-runner
|
||||
"$WORKSPACE"
|
||||
|
||||
add_log "built $1"
|
||||
|
|
|
@ -8,4 +8,4 @@ if [[ "${COVERAGE:-}" == "1" ]]; then
|
|||
sentry="-e SENTRY_URL -e SENTRY_DSN -e SENTRY_ORG -e SENTRY_PROJECT -e SENTRY_AUTH_TOKEN -e DEPRECATION_SENTRY_DSN"
|
||||
fi
|
||||
|
||||
docker-compose --project-name $CONTAINER_NAME run -e CI_NODE_INDEX -e CI_NODE_TOTAL -e COVERAGE -e FORCE_FAILURE $sentry canvas yarn test:karma:headless
|
||||
docker-compose --project-name $CONTAINER_NAME run -e CI_NODE_INDEX -e CI_NODE_TOTAL -e COVERAGE -e FORCE_FAILURE -e RAILS_LOAD_ALL_LOCALES $sentry canvas yarn test:karma:headless
|
||||
|
|
|
@ -2,6 +2,7 @@ version: "2.3"
|
|||
services:
|
||||
canvas:
|
||||
environment:
|
||||
- JSPEC_GROUP
|
||||
JSPEC_GROUP: $JSPEC_GROUP
|
||||
RAILS_LOAD_ALL_LOCALES: $RAILS_LOAD_ALL_LOCALES
|
||||
image: $KARMA_RUNNER_IMAGE
|
||||
init: true
|
||||
|
|
|
@ -46,10 +46,16 @@ module.exports.pitch = function(remainingRequest, precedingRequest, data) {
|
|||
|
||||
// in development, we can save bandwidth and build time by not bothering
|
||||
// to include translation artifacts during the build.
|
||||
const shouldTranslate =
|
||||
process.env.RAILS_LOAD_ALL_LOCALES ||
|
||||
process.env.RAILS_ENV == 'production' ||
|
||||
process.env.NODE_ENV == 'production'
|
||||
// RAILS_LOAD_ALL_LOCALES: '1' or 'true' to enable
|
||||
// RAILS_LOAD_ALL_LOCALES: '0' to disable in production mode
|
||||
const shouldTranslate = (
|
||||
process.env.RAILS_LOAD_ALL_LOCALES === '1' ||
|
||||
process.env.RAILS_LOAD_ALL_LOCALES === 'true' ||
|
||||
process.env.RAILS_LOAD_ALL_LOCALES !== '0' && (
|
||||
process.env.RAILS_ENV == 'production' ||
|
||||
process.env.NODE_ENV == 'production'
|
||||
)
|
||||
)
|
||||
const translationDependency = shouldTranslate
|
||||
? `
|
||||
import 'translations/${scopeName}';
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace :canvas do
|
|||
build_api_docs = ENV["COMPILE_ASSETS_API_DOCS"] != "0"
|
||||
build_css = ENV["COMPILE_ASSETS_CSS"] != "0"
|
||||
build_styleguide = ENV["COMPILE_ASSETS_STYLEGUIDE"] != "0"
|
||||
build_i18n = ENV["RAILS_LOAD_ALL_LOCALES"] != "0"
|
||||
build_js = ENV["COMPILE_ASSETS_BUILD_JS"] != "0"
|
||||
build_prod_js = ENV['RAILS_ENV'] == 'production' || ENV['USE_OPTIMIZED_JS'] == 'true' || ENV['USE_OPTIMIZED_JS'] == 'True'
|
||||
# build dev bundles even in prod mode so you can debug with ?optimized_js=0
|
||||
|
@ -50,18 +51,18 @@ namespace :canvas do
|
|||
|
||||
task 'i18n:generate_js' => [
|
||||
('js:yarn_install' if npm_install)
|
||||
].compact if build_js
|
||||
].compact if build_i18n && build_js
|
||||
|
||||
task 'js:webpack_development' => [
|
||||
# public/dist/brandable_css/brandable_css_bundles_with_deps.json needs
|
||||
# to exist before we run handlebars stuff, so we have to do this first
|
||||
'css:compile',
|
||||
'i18n:generate_js',
|
||||
('i18n:generate_js' if build_i18n),
|
||||
] if build_js && build_dev_js
|
||||
|
||||
task 'js:webpack_production' => [
|
||||
'css:compile',
|
||||
'i18n:generate_js',
|
||||
('i18n:generate_js' if build_i18n),
|
||||
] if build_js && build_prod_js
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue