Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
15e7beb
#2697: .travis.yml, add coveralls
jeff1evesque Jan 15, 2017
26c039a
#2697: .travis.yml, add 'after_success' for coveralls
jeff1evesque Jan 15, 2017
63e0aad
#2697: app.py, attempt to add coveralls argument
jeff1evesque Jan 15, 2017
30d1a2d
#2697: .travis.yml, add 'pytest-cov'
jeff1evesque Jan 15, 2017
6418556
#2697: app.py, add 'my_pkg' to 'pytest.main'
jeff1evesque Jan 15, 2017
b9df1c2
#2697: default.dockerfile, install 'pytest-cov==2.4.0'
jeff1evesque Jan 15, 2017
d7a8746
#2697: .travis.yml, 'pip install coveralls==1.1.'
jeff1evesque Jan 15, 2017
bdf8cdc
#2697: default.dockerfile, install 'python-pip'
jeff1evesque Jan 15, 2017
4bf7d0f
#2697: app.py, remove 'my_pkg'
jeff1evesque Jan 15, 2017
700bffa
#2697: __init__.py, add file
jeff1evesque Jan 15, 2017
7f9348f
#2697: __init__.py, add file
jeff1evesque Jan 15, 2017
fbf89c8
#2697: __init__.py, add file
jeff1evesque Jan 15, 2017
dcd54c1
#2697: app.py, test current directory
jeff1evesque Jan 15, 2017
0b40076
#2697: __init__.py, remove file
jeff1evesque Jan 15, 2017
9f9170c
#2697: __init__.py, remove file
jeff1evesque Jan 15, 2017
41c1846
#2697: __init__.py, remove file
jeff1evesque Jan 15, 2017
1c7714c
#2697: app.py, redirect output to 'coverage.json'
jeff1evesque Jan 15, 2017
6ba0b66
#2697: .travis.yml, 'cat coverage.json'
jeff1evesque Jan 15, 2017
93147b9
#2697: .travis.yml, install 'coveralls' via npm
jeff1evesque Jan 15, 2017
6369a68
#2697: .travis.yml, remove newline
jeff1evesque Jan 15, 2017
4114186
#2697: app.py, change 'coverage.json' to 'coverage.xml'
jeff1evesque Jan 15, 2017
dd9740f
#2697: .travis.yml, change 'coverage.json' to 'coverage.xml'
jeff1evesque Jan 15, 2017
ad82c28
#2697: .travis.yml, fix npm syntax
jeff1evesque Jan 15, 2017
ac034dd
#2697: .travis.yml, properly reference 'coverage.xml'
jeff1evesque Jan 15, 2017
21c5123
#2697: .travis.yml, replace 'coveralls' with 'python-coveralls'
jeff1evesque Jan 15, 2017
00fce3b
#2697: app.py, adjust '--cov-report' path
jeff1evesque Jan 15, 2017
f68c2ac
#2697: .travis.yml, copy 'coverage.yml' from container to travis
jeff1evesque Jan 16, 2017
2ecae0c
#2697: app.py, change xml file to '.coverage'
jeff1evesque Jan 16, 2017
f2d0916
#2697: .travis.yml, replace 'coverage.xml' with '.coverage'
jeff1evesque Jan 16, 2017
d53db58
#2697: app.py, remove '--cov-report'
jeff1evesque Jan 16, 2017
ef010b4
#2697: .travis.yml, add 'pwd' for debugging
jeff1evesque Jan 16, 2017
def7bc2
#2697: .gitignore, do not ignore '.coveragerc'
jeff1evesque Jan 16, 2017
7b1eefe
#2697: app.py, define '--config_file'
jeff1evesque Jan 16, 2017
e9d894a
#2697: .coveragerc, add file
jeff1evesque Jan 16, 2017
8e35347
#2697: .travis.yml, remove 'pwd'
jeff1evesque Jan 16, 2017
70733fd
#2697: app.py, remove '--config_file'
jeff1evesque Jan 16, 2017
5f7da8e
#2697: .travis.yml, add '--config_file'
jeff1evesque Jan 16, 2017
ec23e2b
#2697: .travis.yml, implement 'coverage combine'
jeff1evesque Jan 16, 2017
dc72d6c
#2697: .coveragerc, adjust source paths
jeff1evesque Jan 16, 2017
28c1645
#2697: .travis.yml, move 'coverage' into 'after_success'
jeff1evesque Jan 16, 2017
2c3365c
#2697: .coveragerc, remove file
jeff1evesque Jan 16, 2017
f64a0a7
#2697: .gitignore, remove '.coveragerc'
jeff1evesque Jan 16, 2017
9210d71
#2697: .travis.yml, add 'coverage help' for debugging
jeff1evesque Jan 16, 2017
671ce32
#2697: .travis.yml, remove 'coverage help', '--append'
jeff1evesque Jan 16, 2017
383b546
#2697: .travis.yml, add 'coverage report' for debugging
jeff1evesque Jan 16, 2017
d995dab
#2697: coveragerc, add file
jeff1evesque Jan 16, 2017
c9b2a35
#2697: .gitignore, add '.coveragerc'
jeff1evesque Jan 16, 2017
4c84cb7
#2697: .travis.yml, add suffix to '.coverage' as '.coverage.docker'
jeff1evesque Jan 16, 2017
16eb824
#2697: .travis.yml, remove unnecessary 'cat coverage'
jeff1evesque Jan 16, 2017
7650193
#2697: .travis.yml, adjust comment, remove 'coverage report'
jeff1evesque Jan 16, 2017
5bc395d
#2697: .travis.yml, add additional comments
jeff1evesque Jan 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[paths]
source =
.
/var/machine-learning
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
!/test
!/log/
!*.dockerfile
!.coveragerc

# Ignore and don't commit the following directories
*.sass-cache/
Expand Down
55 changes: 37 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ before_install:
- sudo /opt/puppetlabs/bin/puppet -V

## install packages for linting
#
# @trusty-backports, allows additional packages (i.e. shellcheck) to be installed
#
# Note: unit testing is performed within the docker container, which is
# defined from the Dockerfile.
##
## @trusty-backports, allows additional packages (i.e. shellcheck) to be installed
##
## Note: unit testing is performed within the docker container, which is
## defined from the Dockerfile.
install:
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-backports restricted main universe"
- pip install flake8==2.5.4
Expand All @@ -60,21 +60,22 @@ install:
- gem install yaml-lint -v 0.0.7
- npm install -g dockerlint@0.2.0
- pip install restructuredtext_lint==0.17.2
- pip install python-coveralls==2.9.0

## implement linting / unit tests
#
# @puppet-lint, the following issue needs to be checked if it has been
# resolved, so the '--no-ensure_first_param-check' abusive flag
# implementation (below) can be removed:
#
# - https://github.com/rodjek/puppet-lint/issues/410
#
# @docker run:
# -d, run container in background and print container ID
# -t, allocate pseudo-tty instead of default tty to running container
#
# Note: unit testing is performed within the docker container, which is
# defined from the Dockerfile.
##
## @puppet-lint, the following issue needs to be checked if it has been
## resolved, so the '--no-ensure_first_param-check' abusive flag
## implementation (below) can be removed:
##
## - https://github.com/rodjek/puppet-lint/issues/410
##
## @docker run:
## -d, run container in background and print container ID
## -t, allocate pseudo-tty instead of default tty to running container
##
## Note: unit testing is performed within the docker container, which is
## defined from the Dockerfile.
script:
# lint codebase
- flake8 .
Expand Down Expand Up @@ -113,10 +114,28 @@ script:
- cat pytest.log
- (! grep -qE '= FAILURES =|= ERRORS =|= no tests ran in 0.00 seconds =' pytest.log)

## acquire coverage results
##
## Note: more information regarding the '.coverage.docker' naming convention:
##
## https://github.com/pytest-dev/pytest-cov/issues/146#issuecomment-272971136
##
- docker cp webserver-pytest:/var/machine-learning/.coverage .coverage.docker

# check exit code: 'docker exec' will fail if the container has an exit code
- docker exec -it webserver echo "'docker exec' only works on an active running container"
- docker exec -it database echo "'docker exec' only works on an active running container"
- docker exec -it redis echo "'docker exec' only works on an active running container"

# list all containers
- docker ps -a

## post build: the following commands are run after a successful build.
##
## Note: more information regarding the coverage-coverall implementation:
##
## https://github.com/pytest-dev/pytest-cov/issues/146
##
after_success:
- coverage combine
- coveralls
5 changes: 4 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
# run unit test
if len(sys.argv) > 1:
if sys.argv[1] == 'test':
pytest.main(['test/live_server'])
pytest.main([
'--cov', '.',
'test/live_server'
])
elif sys.argv[1] == 'run':
args = {
'prefix': 'test',
Expand Down
6 changes: 5 additions & 1 deletion default.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ ENV ENVIRONMENT_DIR $ROOT_PROJECT/puppet/environment/$ENVIRONMENT
RUN mkdir /var/machine-learning
COPY . /var/machine-learning

## install git, and wget
## install git, wget, pip
#
# Note: r10k requires 'git' installed
RUN apt-get -y update
RUN apt-get -y install git=1:1.9.1-1ubuntu0.3
RUN apt-get -y install wget=1.15-1ubuntu1.14.04.2
RUN apt-get -y install python-pip=1.5.4-1ubuntu4

## install puppet
RUN wget https://apt.puppetlabs.com/puppetlabs-release-pc1-trusty.deb
Expand All @@ -26,6 +27,9 @@ RUN apt-get -y install puppet-agent
RUN apt-get -y install rubygems-integration=1.5
RUN gem install r10k -v 2.2.0

## install pytest-cov
RUN pip install pytest-cov==2.4.0

## install puppet modules using puppetfile with r10k
RUN mkdir -p $ENVIRONMENT_DIR/modules_contrib/
RUN PUPPETFILE=$ENVIRONMENT_DIR/Puppetfile PUPPETFILE_DIR=$ENVIRONMENT_DIR/modules_contrib/ r10k puppetfile install
Expand Down