33# Gets called when the user doesn't provide any args
44function HELP {
55 echo -e " \nusage: source_file.py --key API_KEY [--url ALT_URL]"
6- echo " API_KEY - Rosette API key (required)"
7- echo " FILENAME - Python source file (optional)"
8- echo " ALT_URL - Alternate service URL (optional)"
9- echo " Compiles and runs the source file(s) using the published rosette-api"
6+ echo " API_KEY - Rosette API key (required)"
7+ echo " FILENAME - Python source file (optional)"
8+ echo " ALT_URL - Alternate service URL (optional)"
9+ echo " GIT_USERNAME - Git username where you would like to push regenerated gh-pages (optional)"
10+ echo " VERSION - Build version (optional)"
11+ echo " Compiles and runs the source file(s) using the local development source."
1012 exit 1
1113}
1214
1315# Gets API_KEY, FILENAME and ALT_URL if present
14- while getopts " :API_KEY:FILENAME:ALT_URL" arg; do
16+ while getopts " :API_KEY:FILENAME:ALT_URL:GIT_USERNAME:VERSION " arg; do
1517 case " ${arg} " in
1618 API_KEY)
1719 API_KEY=${OPTARG}
@@ -25,6 +27,14 @@ while getopts ":API_KEY:FILENAME:ALT_URL" arg; do
2527 FILENAME=${OPTARG}
2628 usage
2729 ;;
30+ GIT_USERNAME)
31+ GIT_USERNAME=${OPTARG}
32+ usage
33+ ;;
34+ VERSION)
35+ VERSION={OPTARG}
36+ usage
37+ ;;
2838 esac
2939done
3040
@@ -38,25 +48,46 @@ function checkAPI {
3848}
3949
4050# Copy the mounted content in /source to current WORKDIR
41- cp -r /source/* .
51+ cp -r -n /source/* .
4252
4353# Run the examples
4454if [ ! -z ${API_KEY} ]; then
4555 checkAPI
4656 # Prerequisite
47- python /python/setup.py install
48- cd examples
57+ python /python-dev /setup.py install
58+ cd /python-dev/ examples
4959 if [ ! -z ${FILENAME} ]; then
5060 if [ ! -z ${ALT_URL} ]; then
51- python ${FILENAME} --key ${API_KEY} --url ${ALT_URL}
52- else
53- python ${FILENAME} --key ${API_KEY}
54- fi
61+ python ${FILENAME} --key ${API_KEY} --url ${ALT_URL}
62+ else
63+ python ${FILENAME} --key ${API_KEY}
64+ fi
5565 elif [ ! -z ${ALT_URL} ]; then
56- find -maxdepth 1 -name ' *.py' -print -exec python {} --key ${API_KEY} --url ${ALT_URL} \;
66+ find -maxdepth 1 -name ' *.py' -print -exec python {} --key ${API_KEY} --url ${ALT_URL} \;
5767 else
58- find -maxdepth 1 -name ' *.py' -print -exec python {} --key ${API_KEY} \;
68+ find -maxdepth 1 -name ' *.py' -print -exec python {} --key ${API_KEY} \;
5969 fi
6070else
6171 HELP
6272fi
73+
74+ # Run unit tests
75+ cd /python-dev
76+ tox
77+
78+ # Generate gh-pages and push them to git account (if git username is provided)
79+ if [ ! -z ${GIT_USERNAME} ] && [ ! -z ${VERSION} ]; then
80+ # clone python git repo
81+ cd /
82+ git clone
[email protected] :
${GIT_USERNAME} /python.git
83+ cd python
84+ git checkout origin/gh-pages -b gh-pages
85+ git branch -d develop
86+ # generate gh-pages and set ouput dir to git repo (gh-pages branch)
87+ cd /python-dev
88+ .tox/py27/bin/epydoc -v --no-private --no-frames --css epydoc.css -o /python rosette/* .py
89+ cd /python
90+ git add .
91+ git commit -a -m " publish python apidocs ${VERSION} "
92+ git push
93+ fi
0 commit comments