From e815a19462639533334ea1ebe517425f833e5f5c Mon Sep 17 00:00:00 2001 From: Tom Robinson <tlrobinson@gmail.com> Date: Tue, 7 Aug 2018 14:17:59 -0700 Subject: [PATCH] Integrate translation builds into ./bin/build --- Dockerfile | 5 +++-- bin/build | 16 +++++++++++++++- docs/developers-guide.md | 7 +++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index ef867480cfb..c9762cb48ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # STAGE 1: builder ################### -FROM java:openjdk-8-jre-alpine as builder +FROM java:openjdk-8-jdk-alpine as builder WORKDIR /app/source @@ -14,7 +14,8 @@ ENV LC_CTYPE en_US.UTF-8 # git: ./bin/version # nodejs: frontend building # make: backend building -RUN apk add --update bash nodejs git wget make +# gettext: translations +RUN apk add --update bash nodejs git wget make gettext # yarn: frontend dependencies RUN npm install -g yarn diff --git a/bin/build b/bin/build index aa4388776d2..b16fc136b90 100755 --- a/bin/build +++ b/bin/build @@ -20,15 +20,25 @@ frontend-deps() { } frontend() { + frontend-deps echo "Running 'webpack' with NODE_ENV=production assemble and minify frontend assets..." && NODE_ENV=production ./node_modules/.bin/webpack --bail } frontend-fast() { + frontend-deps echo "Running 'webpack' with NODE_ENV=development to assemble frontend assets..." && NODE_ENV=development ./node_modules/.bin/webpack --bail --devtool eval } +translations() { + echo "Running './bin/i18n/build-translation-resources' to build translation resources..." + if ! ./bin/i18n/build-translation-resources; then + echo "Building translation resources failed, please install 'gettext', or build without translations by running './bin/build no-translations'." + exit 1 + fi +} + sample-dataset() { if [ -f resources/sample-dataset.db.mv.db ]; then echo "Sample Dataset already generated." @@ -44,7 +54,11 @@ uberjar() { } all() { - version && frontend-deps && frontend && sample-dataset && uberjar + version && translations && frontend && sample-dataset && uberjar +} + +no-translations() { + version && frontend && sample-dataset && uberjar } # Default to running all but let someone specify one or more sub-tasks to run instead if desired diff --git a/docs/developers-guide.md b/docs/developers-guide.md index 115ee34fa09..c42a3bda79e 100644 --- a/docs/developers-guide.md +++ b/docs/developers-guide.md @@ -111,7 +111,7 @@ $ yarn run build-watch All frontend tests are located in `frontend/test` directory. Run all frontend tests with ``` -./bin/build version uberjar && yarn run test +yarn run test ``` which will first build the backend JAR and then run integration, unit and Karma browser tests in sequence. @@ -123,10 +123,9 @@ Integration tests use an enforced file naming convention `<test-suite-name>.inte Useful commands: ```bash -./bin/build version uberjar # Builds the JAR without frontend assets; run this every time you need to update the backend lein run refresh-integration-test-db-metadata # Scan the sample dataset and re-run sync/classification/field values caching yarn run test-integrated-watch # Watches for file changes and runs the tests that have changed -yarn run test-integrated-watch -- TestFileName # Watches the files in paths that match the given (regex) string +yarn run test-integrated-watch TestFileName # Watches the files in paths that match the given (regex) string ``` The way integration tests are written is a little unconventional so here is an example that hopefully helps in getting up to speed: @@ -266,7 +265,7 @@ Start up an instant cheatsheet for the project + dependencies by running lein instant-cheatsheet ## Internationalization -We are an application with lots of users all over the world. To help them use Metabase in their own language, we mark all of our strings as i18n. +We are an application with lots of users all over the world. To help them use Metabase in their own language, we mark all of our strings as i18n. ### The general workflow for developers is: 1. Tag strings in the frontend using `t` and `jt` ES6 template literals (see more details in https://c-3po.js.org/): -- GitLab