Skip to content

Commit

Permalink
Local testing with docker
Browse files Browse the repository at this point in the history
  • Loading branch information
EnoahNetzach committed May 30, 2017
1 parent 19c5277 commit 45df6bf
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
87 changes: 87 additions & 0 deletions tasks/local-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bash

function print_help {
echo "Usage: ${0} [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " --node-version <version> the node version to use while testing [6]"
echo " --git-branch <branch> the git branch to checkout for testing [the current one]"
echo " --test-suite <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}"

0 comments on commit 45df6bf

Please sign in to comment.