Skip to content

Commit 7daffe1

Browse files
authored
Merge pull request #50 from fhasanaj/RCB-413_full_publish_automation
Updated docker that runs against development source to not generate g…
2 parents 5f00478 + 726624f commit 7daffe1

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ MAINTAINER Sam Hausmann
44
#install necessary packages
55
RUN apt-get -y update && apt-get install -y git && apt-get install -y vim && apt-get install -y curl
66

7+
RUN npm install -g grunt-cli && npm install -g eslint
8+
79
ENV API_KEY api_key
810

911
RUN mkdir /nodejs-dev
@@ -13,5 +15,5 @@ RUN chmod 0755 /nodejs-dev/runAll.sh
1315
#set the working directory
1416
WORKDIR /nodejs-dev
1517

16-
CMD ./runAll.sh $API_KEY $FILENAME $ALT_URL $GIT_USERNAME $GIT_EMAIL $VERSION
18+
CMD ./runAll.sh
1719
VOLUME ["/source"]

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Build the docker image, e.g. `docker build -t basistech/nodejs:1.1 .`
99

1010
Run an example as `docker run -e API_KEY=api-key -v "path-to-local-nodejs-dir:/source" basistech/nodejs:1.1`
1111

12-
To test against a specific source file, add `-e FILENAME=filename` before the `-v`, to test against an alternate url, add `-e ALT_URL=alternate_url`, and optionally if you would like to regenerate gh-pages from the changes made to the development source you can add `-e GIT_USERNAME=git-username -e VERSION=version` before the `-v`. In order to push the gh-pages to git remember to mount .ssh and .gitconfig to the root dir `-v path-to-.ssh-dir:/root/.ssh -v path-to-.gitconfig:/root/.gitconfig`.
12+
To test against a specific source file, add `-e FILENAME=filename` before the `-v`, to test against an alternate url, add `-e ALT_URL=alternate_url`.

docker/runAll.sh

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
ping_url="https://api.rosette.com/rest/v1/"
44
retcode=0
5+
errors=( "Exception" "processingFailure" "badRequest" "ParseError" "ValueError" "SyntaxError" "AttributeError" "ImportError" )
56

67
#------------------- Functions -------------------------------------
78

@@ -11,12 +12,14 @@ function HELP {
1112
echo " API_KEY - Rosette API key (required)"
1213
echo " FILENAME - Python source file (optional)"
1314
echo " ALT_URL - Alternate service URL (optional)"
14-
echo " GIT_USERNAME - Git username where you would like to push regenerated gh-pages (optional)"
15-
echo " VERSION - Build version (optional)"
1615
echo "Compiles and runs the source file(s) using the local development source."
1716
exit 1
1817
}
1918

19+
if [ ! -z ${ALT_URL} ]; then
20+
ping_url=${ALT_URL}
21+
fi
22+
2023
#Checks if Rosette API key is valid
2124
function checkAPI() {
2225
match=$(curl "${ping_url}ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "forbidden")
@@ -56,38 +59,27 @@ function runExample() {
5659
fi
5760
echo "${result}"
5861
echo -e "\n---------- ${1} end -------------"
59-
if [[ $result == *"Exception"* ]]; then
60-
retcode=1
61-
elif [[ $result == *"processingFailure"* ]]; then
62-
retcode=1
63-
fi
62+
for err in "${errors[@]}"; do
63+
if [[ ${result} == *"${err}"* ]]; then
64+
retcode=1
65+
fi
66+
done
6467
}
6568

6669

6770
#------------------- Functions End ----------------------------------
6871

6972
#Gets API_KEY, FILENAME and ALT_URL if present
70-
while getopts ":API_KEY:FILENAME:ALT_URL:GIT_USERNAME:VERSION" arg; do
73+
while getopts ":API_KEY:FILENAME:ALT_URL" arg; do
7174
case "${arg}" in
7275
API_KEY)
7376
API_KEY=${OPTARG}
74-
usage
7577
;;
7678
ALT_URL)
7779
ALT_URL=${OPTARG}
78-
usage
7980
;;
8081
FILENAME)
8182
FILENAME=${OPTARG}
82-
usage
83-
;;
84-
GIT_USERNAME)
85-
GIT_USERNAME=${OPTARG}
86-
usage
87-
;;
88-
VERSION)
89-
VERSION={OPTARG}
90-
usage
9183
;;
9284
esac
9385
done
@@ -100,15 +92,11 @@ validateURL
10092
cp -r -n /source/. .
10193

10294
#Run unit tests
103-
npm install -g grunt-cli
104-
npm install -g eslint
10595
npm install
10696
grunt test
10797
#run eslint
10898
eslint lib/*.js
10999

110-
111-
112100
#Run the examples
113101
if [ ! -z ${API_KEY} ]; then
114102
checkAPI
@@ -117,8 +105,10 @@ if [ ! -z ${API_KEY} ]; then
117105
npm install argparse
118106
npm install temporary
119107
if [ ! -z ${FILENAME} ]; then
108+
echo -e "\nRunning example against: ${ping_url}\n"
120109
runExample ${FILENAME}
121110
else
111+
echo -e "\nRunning examples against: ${ping_url}\n"
122112
for file in *.js; do
123113
runExample $file
124114
done
@@ -128,11 +118,5 @@ else
128118
retcode=1
129119
fi
130120

131-
#Generate gh-pages and push them to git account (if git username is provided)
132-
if [ ! -z ${GIT_USERNAME} ]; then
133-
134-
grunt doc
135-
fi
136-
137121
exit ${retcode}
138122

lib/Api.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ var language = require("./language");
3030
var ping = require("./ping");
3131
var info = require("./info");
3232

33-
/**
34-
* Compatible server version.
35-
*
36-
* @type string
37-
*/
38-
var BINDING_VERSION = "1.1";
39-
4033
/**
4134
* @class
4235
*

0 commit comments

Comments
 (0)