Skip to content

Commit 4a38e8a

Browse files
committed
Merge pull request #20 from fhasanaj/RCB_227
Rcb 227 - docker image to run examples, unit tests and generate gh-pages
2 parents 8c20256 + e2d7bfe commit 4a38e8a

File tree

429 files changed

+107
-84507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

429 files changed

+107
-84507
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
0.5.1: first published version.
22
0.5.2: refactored code and tests.
33
0.5.3: change github repo for beta
4+
0.8.0: migration to github, added docker images for testing

docker/Dockerfile

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,52 @@
1-
FROM python:2.7.11
1+
FROM ubuntu:14.04
22
MAINTAINER Fiona Hasanaj
33

4-
# install necessary software
5-
RUN apt-get -y update && apt-get install -y vim && apt-get install -y git
4+
ENV DEBIAN_FRONTEND noninteractive
5+
RUN locale-gen en_US.UTF-8 && /usr/sbin/update-locale LANG=en_US.UTF-8
6+
ENV LANG en_US.UTF-8
67

7-
COPY run_python.sh /python/run_python.sh
8-
RUN chmod 755 /python/run_python.sh
9-
WORKDIR /python
8+
# proper init to handle signal propagation and zombie reaping
9+
ADD https://github.com/krallin/tini/releases/download/v0.8.4/tini /tini
10+
RUN chmod +x /tini
11+
ENTRYPOINT ["/tini", "--"]
12+
13+
RUN apt-get update && \
14+
apt-get -y install \
15+
wget \
16+
libssl-dev \
17+
libffi-dev \
18+
python-pip \
19+
python-software-properties \
20+
software-properties-common && \
21+
add-apt-repository -y ppa:fkrull/deadsnakes && \
22+
apt-get update && \
23+
apt-get -y install \
24+
python2.6 \
25+
python2.7 \
26+
python3.3 \
27+
python3.4 \
28+
python3.5 \
29+
git\
30+
pypy && \
31+
apt-get clean && \
32+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
33+
34+
RUN mkdir /install && \
35+
wget -O /install/pypy3-2.4-linux_x86_64-portable.tar.bz2 \
36+
"https://bitbucket.org/squeaky/portable-pypy/downloads/pypy3-2.4-linux_x86_64-portable.tar.bz2" && \
37+
tar jxf /install/pypy3-*.tar.bz2 -C /install && \
38+
rm /install/pypy3-*.tar.bz2 && \
39+
ln -s /install/pypy3-*/bin/pypy3 /usr/local/bin/pypy3
40+
41+
RUN pip install -U pip && pip install tox
42+
43+
# copy over the necessary files
44+
COPY run_python.sh /python-dev/run_python.sh
45+
RUN chmod 755 /python-dev/run_python.sh
46+
COPY tox.ini /python-dev/tox.ini
47+
WORKDIR /python-dev
1048

1149
# allow interactive bash inside docker container
12-
CMD ./run_python.sh $API_KEY $ALT_URL
50+
CMD ./run_python.sh $API_KEY $FILENAME $ALT_URL $GIT_USERNAME $VERSION
1351

1452
VOLUME ["/source"]

docker/README.md

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

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

12-
To test against a specific source file, add `-e FILENAME=filename` before the `-v`
13-
14-
Also, to test against an alternate url, add `-e ALT_URL=alternate_url` before the `-v`
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`.

docker/run_python.sh

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
#Gets called when the user doesn't provide any args
44
function 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
2939
done
3040

@@ -38,14 +48,14 @@ 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
4454
if [ ! -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
5161
python ${FILENAME} --key ${API_KEY} --url ${ALT_URL}
@@ -60,3 +70,24 @@ if [ ! -z ${API_KEY} ]; then
6070
else
6171
HELP
6272
fi
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

docker/tox.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Tox (http://tox.testrun.org/) is a tool for running tests
2+
# in multiple virtualenvs. This configuration file will run the
3+
# test suite on all supported python versions. To use it, "pip install tox"
4+
# and then run "tox" from this directory.
5+
6+
[tox]
7+
skipsdist = True
8+
envlist = py26, py27, py33, py34
9+
10+
[testenv]
11+
commands =
12+
py.test {toxinidir}/tests
13+
deps =
14+
pytest
15+
pytest-pep8
16+
httpretty==0.8.10
17+
epydoc

rosette/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
limitations under the License.
1717
"""
1818

19-
__version__ = '0.7.4'
19+
__version__ = '0.8.0'

rosette/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from socket import gethostbyname, gaierror
2929
from datetime import datetime
3030

31-
_BINDING_VERSION = "0.7"
31+
_BINDING_VERSION = "0.8"
3232
_GZIP_BYTEARRAY = bytearray([0x1F, 0x8b, 0x08])
3333
N_RETRIES = 3
3434
HTTP_CONNECTION = None

tests/mock-data/request/ara-doc-categories.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/mock-data/request/ara-doc-entities.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/mock-data/request/ara-doc-entities_linked.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)