Skip to content

Commit 45df6bf

Browse files
committed
Local testing with docker
1 parent 19c5277 commit 45df6bf

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"changelog": "lerna-changelog",
66
"create-react-app": "tasks/cra.sh",
77
"e2e": "tasks/e2e-simple.sh",
8+
"e2e:docker": "tasks/local-test.sh",
89
"postinstall": "lerna bootstrap && cd packages/react-error-overlay/ && npm run build:prod",
910
"publish": "tasks/release.sh",
1011
"start": "node packages/react-scripts/scripts/start.js",

tasks/local-test.sh

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env bash
2+
3+
function print_help {
4+
echo "Usage: ${0} [OPTIONS]"
5+
echo ""
6+
echo "OPTIONS:"
7+
echo " --node-version <version> the node version to use while testing [6]"
8+
echo " --git-branch <branch> the git branch to checkout for testing [the current one]"
9+
echo " --test-suite <suite> which test suite to use ('simple', installs', 'kitchensink', 'all') ['all']"
10+
echo " --yarn if present, use yarn as the package manager"
11+
echo " --help print this message and exit"
12+
echo ""
13+
}
14+
15+
cd $(dirname $0)
16+
17+
node_version=6
18+
git_branch=`git rev-parse --abbrev-ref HEAD`
19+
use_yarn=no
20+
test_suite=all
21+
22+
while [ "$1" != "" ]; do
23+
case $1 in
24+
"--node-version")
25+
shift
26+
node_version=$1
27+
;;
28+
"--git-branch")
29+
shift
30+
git_branch=$1
31+
;;
32+
"--yarn")
33+
use_yarn=yes
34+
;;
35+
"--test-suite")
36+
shift
37+
test_suite=$1
38+
;;
39+
"--help")
40+
print_help
41+
exit 0
42+
;;
43+
esac
44+
shift
45+
done
46+
47+
test_command="./tasks/e2e-simple.sh && ./tasks/e2e-kitchensink.sh && ./tasks/e2e-installs.sh"
48+
case ${test_suite} in
49+
"all")
50+
;;
51+
"simple")
52+
test_command="./tasks/e2e-simple.sh"
53+
;;
54+
"kitchensink")
55+
test_command="./tasks/e2e-kitchensink.sh"
56+
;;
57+
"installs")
58+
test_command="./tasks/e2e-installs.sh"
59+
;;
60+
*)
61+
;;
62+
esac
63+
64+
read -r -d '' command <<- CMD
65+
echo "prefix=~/.npm" > ~/.npmrc
66+
mkdir ~/.npm
67+
export PATH=\$PATH:~/.npm/bin
68+
set -x
69+
git clone /var/create-react-app create-react-app --branch ${git_branch}
70+
cd create-react-app
71+
node --version
72+
npm --version
73+
npm install
74+
set +x
75+
${test_command} && echo -e "\n\e[1;32m✔ Job passed\e[0m" || echo -e "\n\e[1;31m✘ Job failes\e[0m"
76+
CMD
77+
78+
docker run \
79+
--env CI=true \
80+
--env NPM_CONFIG_QUIET=true \
81+
--env USE_YARN=${use_yarn} \
82+
--tty \
83+
--user node \
84+
--volume ${PWD}/..:/var/create-react-app \
85+
--workdir /home/node \
86+
node:${node_version} \
87+
bash -c "${command}"

0 commit comments

Comments
 (0)