From 45df6bf9c83148c9bddfdc40cc9059b5cb22026c Mon Sep 17 00:00:00 2001 From: Enoah Netzach Date: Wed, 18 Jan 2017 14:31:10 +0100 Subject: [PATCH] Local testing with docker --- package.json | 1 + tasks/local-test.sh | 87 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100755 tasks/local-test.sh diff --git a/package.json b/package.json index e6bd7b0c3c..d5c7a6c8fb 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "changelog": "lerna-changelog", "create-react-app": "tasks/cra.sh", "e2e": "tasks/e2e-simple.sh", + "e2e:docker": "tasks/local-test.sh", "postinstall": "lerna bootstrap && cd packages/react-error-overlay/ && npm run build:prod", "publish": "tasks/release.sh", "start": "node packages/react-scripts/scripts/start.js", diff --git a/tasks/local-test.sh b/tasks/local-test.sh new file mode 100755 index 0000000000..b516e69e55 --- /dev/null +++ b/tasks/local-test.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +function print_help { + echo "Usage: ${0} [OPTIONS]" + echo "" + echo "OPTIONS:" + echo " --node-version the node version to use while testing [6]" + echo " --git-branch the git branch to checkout for testing [the current one]" + echo " --test-suite which test suite to use ('simple', installs', 'kitchensink', 'all') ['all']" + echo " --yarn if present, use yarn as the package manager" + echo " --help print this message and exit" + echo "" +} + +cd $(dirname $0) + +node_version=6 +git_branch=`git rev-parse --abbrev-ref HEAD` +use_yarn=no +test_suite=all + +while [ "$1" != "" ]; do + case $1 in + "--node-version") + shift + node_version=$1 + ;; + "--git-branch") + shift + git_branch=$1 + ;; + "--yarn") + use_yarn=yes + ;; + "--test-suite") + shift + test_suite=$1 + ;; + "--help") + print_help + exit 0 + ;; + esac + shift +done + +test_command="./tasks/e2e-simple.sh && ./tasks/e2e-kitchensink.sh && ./tasks/e2e-installs.sh" +case ${test_suite} in + "all") + ;; + "simple") + test_command="./tasks/e2e-simple.sh" + ;; + "kitchensink") + test_command="./tasks/e2e-kitchensink.sh" + ;; + "installs") + test_command="./tasks/e2e-installs.sh" + ;; + *) + ;; +esac + +read -r -d '' command <<- CMD +echo "prefix=~/.npm" > ~/.npmrc +mkdir ~/.npm +export PATH=\$PATH:~/.npm/bin +set -x +git clone /var/create-react-app create-react-app --branch ${git_branch} +cd create-react-app +node --version +npm --version +npm install +set +x +${test_command} && echo -e "\n\e[1;32m✔ Job passed\e[0m" || echo -e "\n\e[1;31m✘ Job failes\e[0m" +CMD + +docker run \ + --env CI=true \ + --env NPM_CONFIG_QUIET=true \ + --env USE_YARN=${use_yarn} \ + --tty \ + --user node \ + --volume ${PWD}/..:/var/create-react-app \ + --workdir /home/node \ + node:${node_version} \ + bash -c "${command}"