├── requirements.txt ├── AUTHORS.rst ├── dev-requirements.txt ├── CHANGES.rst ├── .noserc ├── test-requirements.txt ├── tests ├── conftest.py └── test_skeleton.py ├── .coveragerc ├── .gitignore ├── setup.py ├── LICENSE.txt ├── python_jenkinsfile_testing └── __init__.py ├── README.rst ├── setup.cfg ├── pre-commit.sh ├── Makefile └── Jenkinsfile /requirements.txt: -------------------------------------------------------------------------------- 1 | # Add your requirements here like: 2 | # numpy 3 | # scipy>=0.9 4 | 5 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | Developers 3 | ========== 4 | 5 | * Dave Thelen 6 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | check-manifest 2 | coverage 3 | flake8 4 | nose 5 | pdoc 6 | pylint 7 | pytest 8 | setuptools>=35 9 | testtools 10 | unittest2 11 | -------------------------------------------------------------------------------- /CHANGES.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Changelog 3 | ========= 4 | 5 | Version 0.1 6 | =========== 7 | 8 | - Feature A added 9 | - FIX: nasty bug #1729 fixed 10 | - add your changes here! 11 | -------------------------------------------------------------------------------- /.noserc: -------------------------------------------------------------------------------- 1 | [nosetests] 2 | all-modules 3 | traverse-namespace 4 | with-xunit 5 | xunit-file=report/nosetests.xml 6 | with-coverage 7 | cover-inclusive 8 | cover-html 9 | cover-html-dir=report/coverage 10 | cover-xml 11 | cover-xml-file=report/coverage.xml 12 | -------------------------------------------------------------------------------- /test-requirements.txt: -------------------------------------------------------------------------------- 1 | # Add requirements only needed for your unittests and during development here. 2 | # They will be installed automatically when running `python setup.py test`. 3 | # ATTENTION: Don't remove pytest-cov and pytest as they are needed. 4 | pytest-cov 5 | pytest 6 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Dummy conftest.py for scaffold_test. 5 | 6 | If you don't know what this is for, just leave it empty. 7 | Read more about conftest.py under: 8 | https://pytest.org/latest/plugins.html 9 | """ 10 | from __future__ import print_function, absolute_import, division 11 | 12 | import pytest 13 | -------------------------------------------------------------------------------- /tests/test_skeleton.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import pytest 5 | from scaffold_test.skeleton import fib 6 | 7 | __author__ = "Dave Thelen" 8 | __copyright__ = "Dave Thelen" 9 | __license__ = "none" 10 | 11 | 12 | def test_fib(): 13 | assert fib(1) == 1 14 | assert fib(2) == 1 15 | assert fib(7) == 13 16 | with pytest.raises(AssertionError): 17 | fib(-10) 18 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | # .coveragerc to control coverage.py 2 | [run] 3 | branch = True 4 | source = scaffold_test 5 | # omit = bad_file.py 6 | 7 | [report] 8 | # Regexes for lines to exclude from consideration 9 | exclude_lines = 10 | # Have to re-enable the standard pragma 11 | pragma: no cover 12 | 13 | # Don't complain about missing debug-only code: 14 | def __repr__ 15 | if self\.debug 16 | 17 | # Don't complain if tests don't hit defensive assertion code: 18 | raise AssertionError 19 | raise NotImplementedError 20 | 21 | # Don't complain if non-runnable code isn't run: 22 | if 0: 23 | if __name__ == .__main__.: 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Temporary and binary files 2 | *~ 3 | *.py[cod] 4 | *.so 5 | *.cfg 6 | !setup.cfg 7 | *.orig 8 | *.log 9 | *.pot 10 | __pycache__/* 11 | .cache/* 12 | .*.swp 13 | */.ipynb_checkpoints/* 14 | 15 | # Project files 16 | .ropeproject 17 | .project 18 | .pydevproject 19 | .settings 20 | .idea 21 | 22 | # Package files 23 | *.egg 24 | *.eggs/ 25 | .installed.cfg 26 | *.egg-info 27 | rpmbuild 28 | 29 | # Unittest and coverage 30 | htmlcov/* 31 | .coverage 32 | .tox 33 | junit.xml 34 | nosetests.xml 35 | coverage.xml 36 | 37 | # Build and docs folder/files 38 | build/* 39 | dist/* 40 | sdist/* 41 | docs/api/* 42 | docs/_build/* 43 | cover/* 44 | report/* 45 | MANIFEST 46 | venv 47 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Setup file for scaffold_test. 5 | 6 | This file was generated with PyScaffold 2.5.7, a tool that easily 7 | puts up a scaffold for your new Python project. Learn more under: 8 | http://pyscaffold.readthedocs.org/ 9 | """ 10 | 11 | import sys 12 | from setuptools import setup 13 | 14 | 15 | def setup_package(): 16 | needs_sphinx = {'build_sphinx', 'upload_docs'}.intersection(sys.argv) 17 | sphinx = ['sphinx'] if needs_sphinx else [] 18 | setup(setup_requires=['six', 'pyscaffold>=2.5a0,<2.6a0'] + sphinx, 19 | use_pyscaffold=True) 20 | 21 | 22 | if __name__ == "__main__": 23 | setup_package() 24 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2017, Arista Networks EOS+ 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | * Neither the name of the Arista nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /python_jenkinsfile_testing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Arista Networks, Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # 11 | # Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # Neither the name of Arista Networks nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARISTA NETWORKS 23 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 26 | # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 28 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 29 | # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | # 31 | 32 | """ 33 | File: __init__.py 34 | Author: Steve Francia 35 | Email: 0 36 | Github: 0 37 | Description: <`0`> 38 | """ 39 | __version__ = '0.1.develop' 40 | __author__ = 'Arista EOS+' 41 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Project 3 | ============= 4 | 5 | 6 | Add a short description here! 7 | 8 | 9 | Description 10 | =========== 11 | 12 | A longer description of your project goes here... 13 | 14 | Installation 15 | ============ 16 | 17 | Let user know how to install 18 | 19 | 20 | Contributing 21 | ============ 22 | 23 | Contributing pull requests are gladly welcomed for this repository. 24 | Please note that all contributions that modify the library behavior 25 | require corresponding test cases otherwise the pull request will be 26 | rejected. 27 | 28 | 29 | License 30 | ======= 31 | Copyright (c) 2017, Arista Networks EOS+ 32 | All rights reserved. 33 | 34 | Redistribution and use in source and binary forms, with or without 35 | modification, are permitted provided that the following conditions are met: 36 | 37 | * Redistributions of source code must retain the above copyright notice, this 38 | list of conditions and the following disclaimer. 39 | 40 | * Redistributions in binary form must reproduce the above copyright notice, 41 | this list of conditions and the following disclaimer in the documentation 42 | and/or other materials provided with the distribution. 43 | 44 | * Neither the name of the Arista nor the names of its 45 | contributors may be used to endorse or promote products derived from 46 | this software without specific prior written permission. 47 | 48 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 49 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 50 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 51 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 52 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 54 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 56 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 57 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = python_jenkinsfile_testing 3 | summary = Add a short description here! 4 | author = Jere Julian 5 | author-email = jere@arista.com 6 | license = LICENSE 7 | home-page = https://github.com/jerearista/python-jenkinsfile-testing 8 | description-file = README.rst 9 | # Add here all kinds of additional classifiers as defined under 10 | # https://pypi.python.org/pypi?%3Aaction=list_classifiers 11 | classifier = 12 | Development Status :: 4 - Beta 13 | Programming Language :: Python 14 | 15 | [entry_points] 16 | # Add here console scripts like: 17 | # console_scripts = 18 | # script_name = scaffold_test.module:function 19 | # For example: 20 | # console_scripts = 21 | # fibonacci = scaffold_test.skeleton:run 22 | # as well as other entry_points. 23 | 24 | 25 | [files] 26 | # Add here 'data_files', 'packages' or 'namespace_packages'. 27 | # Additional data files are defined as key value pairs of target directory 28 | # and source location from the root of the repository: 29 | packages = 30 | scaffold_test 31 | # data_files = 32 | # share/scaffold_test_docs = docs/* 33 | 34 | [extras] 35 | # Add here additional requirements for extra features, like: 36 | # PDF = 37 | # ReportLab>=1.2 38 | # RXP 39 | 40 | [test] 41 | # py.test options when running `python setup.py test` 42 | addopts = tests 43 | 44 | [tool:pytest] 45 | # Options for py.test: 46 | # Specify command line options as you would do when invoking py.test directly. 47 | # e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml 48 | # in order to write a coverage file that can be read by Jenkins. 49 | addopts = 50 | --cov scaffold_test --cov-report term-missing 51 | --junitxml report/junit.xml 52 | --verbose 53 | 54 | [aliases] 55 | docs = build_sphinx 56 | 57 | [bdist_wheel] 58 | # Use this option if your package is pure-python 59 | universal = 1 60 | 61 | [build_sphinx] 62 | source_dir = docs 63 | build_dir = docs/_build 64 | 65 | [pbr] 66 | # Let pbr run sphinx-apidoc 67 | autodoc_tree_index_modules = True 68 | # autodoc_tree_excludes = ... 69 | # Let pbr itself generate the apidoc 70 | # autodoc_index_modules = True 71 | # autodoc_exclude_modules = ... 72 | # Convert warnings to errors 73 | # warnerrors = True 74 | 75 | [devpi:upload] 76 | # Options for the devpi: PyPI server and packaging tool 77 | # VCS export must be deactivated since we are using setuptools-scm 78 | no-vcs = 1 79 | formats = bdist_wheel 80 | -------------------------------------------------------------------------------- /pre-commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Called by "git commit". The hook will run several checks on the 4 | # source-code. If it exits with a non-zero status, the commit will 5 | # be halted. 6 | # 7 | # --------------------------------------------------------------------------- 8 | # To enable this hook, link this file to ".git/hooks/pre-commit": 9 | # ln -s ../../pre-commit.sh .git/hooks/pre-commit 10 | # --------------------------------------------------------------------------- 11 | # 12 | RED='\033[1;31m' 13 | GREEN='\033[1;32m' 14 | NC='\033[0m' 15 | 16 | if git rev-parse --verify HEAD >/dev/null 2>&1 17 | then 18 | against=HEAD 19 | else 20 | # Initial commit: diff against an empty tree object 21 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 22 | fi 23 | 24 | # If you want to allow non-ASCII filenames set this variable to true. 25 | allownonascii=$(git config --bool hooks.allownonascii) 26 | 27 | # Redirect output to stderr. 28 | exec 1>&2 29 | 30 | # Cross platform projects tend to avoid non-ASCII filenames; prevent 31 | # them from being added to the repository. We exploit the fact that the 32 | # printable range starts at the space character and ends with tilde. 33 | if [ "$allownonascii" != "true" ] && 34 | # Note that the use of brackets around a tr range is ok here, (it's 35 | # even required, for portability to Solaris 10's /usr/bin/tr), since 36 | # the square bracket bytes happen to fall in the designated range. 37 | test $(git diff --cached --name-only --diff-filter=A -z ${against} | 38 | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 39 | then 40 | cat <<\EOF 41 | Error: Attempt to add a non-ASCII file name. 42 | 43 | This can cause problems if you want to work with people on other platforms. 44 | 45 | To be portable it is advisable to rename the file. 46 | 47 | If you know what you are doing you can disable this check using: 48 | 49 | git config hooks.allownonascii true 50 | EOF 51 | exit 1 52 | fi 53 | 54 | # If there are whitespace errors, print the offending file names and fail. 55 | git diff-index --check --cached $against -- 56 | 57 | err=0 58 | msg='' 59 | 60 | run(){ 61 | tmp=$(mktemp -t cv-precommit) 62 | echo -n "Running '${*}': " 63 | "$@" >"$tmp" 2>&1 64 | ret=$? 65 | if [ $ret != 0 ]; then 66 | let "err = $err + $ret" 67 | msg="${msg}\n\t'${*}' failed" 68 | echo -e "${RED}FAILED${NC}" 69 | echo "Tried: ${*}" 70 | cat "$tmp" 71 | rm -f "$tmp" 72 | else 73 | echo -e "${GREEN}PASSED${NC}" 74 | fi 75 | return $ret 76 | } 77 | 78 | START_TIME=$SECONDS 79 | run make check 80 | run make flake8 81 | run make pylint 82 | run make tests 83 | 84 | DURATION=$((SECONDS - START_TIME)) 85 | echo "pre-commit checks took ${DURATION} seconds." 86 | echo 87 | 88 | if [ ${err} != 0 ]; then 89 | echo -e "${RED}ERROR: Some checks failed. Commit halted. [${err}]${NC}" 90 | echo -e "${RED}Failed Tests: ${msg}${NC}" 91 | fi 92 | exit ${err} 93 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make 2 | # WARN: gmake syntax 3 | ######################################################## 4 | # Makefile for $(NAME) 5 | # 6 | # useful targets: 7 | # make check -- manifest checks 8 | # make clean -- clean distutils 9 | # make coverage_report -- code coverage report 10 | # make flake8 -- flake8 checks 11 | # make pylint -- source code checks 12 | # make rpm -- build RPM package 13 | # make sdist -- build python source distribution 14 | # make systest -- runs the system tests 15 | # make tests -- run all of the tests 16 | # make unittest -- runs the unit tests 17 | # 18 | # Notes: 19 | # 1) flake8 is a wrapper around pep8, pyflakes, and McCabe. 20 | ######################################################## 21 | # variable section 22 | 23 | NAME = "python_jenkinsfile_testing" 24 | 25 | PYTHON=python 26 | COVERAGE=coverage 27 | NOSE_OPTS = --with-coverage --cover-package=$(NAME) 28 | SITELIB = $(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print get_python_lib()") 29 | 30 | VERSION := $(shell awk '/__version__/{print $$NF}' $(NAME)/__init__.py | sed "s/'//g") 31 | 32 | RPMSPECDIR = . 33 | RPMSPEC = $(RPMSPECDIR)/$(NAME).spec 34 | RPMRELEASE = 1 35 | RPMNVR = "$(NAME)-$(VERSION)-$(RPMRELEASE)" 36 | 37 | FLAKE8_IGNORE = E302,E203,E261 38 | 39 | ######################################################## 40 | 41 | all: clean check flake8 pylint tests 42 | 43 | flake8: 44 | flake8 --ignore=$(FLAKE8_IGNORE) $(NAME)/ 45 | flake8 --ignore=$(FLAKE8_IGNORE),E402 tests/ 46 | 47 | pylint: 48 | find ./$(NAME) ./tests -name \*.py | xargs pylint --rcfile .pylintrc 49 | 50 | check: 51 | @echo "Check-manifest disabled pending https://github.com/mgedmin/check-manifest/issues/68" 52 | #check-manifest 53 | 54 | clean: 55 | @echo "Cleaning up distutils stuff" 56 | rm -rf build 57 | rm -rf dist 58 | rm -rf MANIFEST 59 | rm -rf *.egg-info 60 | @echo "Cleaning up byte compiled python stuff" 61 | find . -type f -regex ".*\.py[co]$$" -delete 62 | @echo "Cleaning up doc builds" 63 | rm -rf docs/_build 64 | rm -rf docs/api_modules 65 | rm -rf docs/client_modules 66 | @echo "Cleaning up test reports" 67 | rm -rf report/* 68 | 69 | rpmcommon: sdist 70 | @mkdir -p rpmbuild 71 | @cp dist/*.gz rpmbuild/ 72 | @cp -R conf/* rpmbuild/ 73 | @sed -e 's#^Version:.*#Version: $(VERSION)#' -e 's#^Release:.*#Release: $(RPMRELEASE)#' $(RPMSPEC) >rpmbuild/$(NAME).spec 74 | 75 | rpm: rpmcommon 76 | @rpmbuild --define "_topdir %(pwd)/rpmbuild" \ 77 | --define "_builddir %{_topdir}" \ 78 | --define "_rpmdir %{_topdir}" \ 79 | --define "_srcrpmdir %{_topdir}" \ 80 | --define "_specdir $(RPMSPECDIR)" \ 81 | --define "_sourcedir %{_topdir}" \ 82 | --define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \ 83 | --define "__python /usr/bin/python" \ 84 | -ba rpmbuild/$(NAME).spec 85 | @rm -f rpmbuild/$(NAME).spec 86 | 87 | sdist: clean 88 | $(PYTHON) setup.py sdist 89 | 90 | tests: unittest systest coverage_report 91 | 92 | unittest: clean 93 | nosetests $(NOSE_OPTS) tests/unit/* 94 | 95 | systest: clean 96 | nosetests $(NOSE_OPTS) tests/system/* 97 | 98 | coverage_report: 99 | $(COVERAGE) report --rcfile=".coveragerc" 100 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env groovy 2 | 3 | /** 4 | * Jenkinsfile 5 | */ 6 | pipeline { 7 | agent any 8 | options { 9 | buildDiscarder( 10 | // Only keep the 10 most recent builds 11 | logRotator(numToKeepStr:'10')) 12 | } 13 | environment { 14 | projectName = 'ProjectTemplate' 15 | emailTo = 'jere@arista.com' 16 | emailFrom = 'eosplus-dev+jenkins@arista.com' 17 | VIRTUAL_ENV = "${env.WORKSPACE}/venv" 18 | } 19 | 20 | stages { 21 | 22 | /* 23 | stage ('Checkout') { 24 | steps { 25 | checkout scm 26 | } 27 | } 28 | */ 29 | 30 | stage ('Install_Requirements') { 31 | steps { 32 | sh """ 33 | echo ${SHELL} 34 | [ -d venv ] && rm -rf venv 35 | #virtualenv --python=python2.7 venv 36 | virtualenv venv 37 | #. venv/bin/activate 38 | export PATH=${VIRTUAL_ENV}/bin:${PATH} 39 | pip install --upgrade pip 40 | pip install -r requirements.txt -r dev-requirements.txt 41 | make clean 42 | """ 43 | } 44 | } 45 | 46 | stage ('Check_style') { 47 | steps { 48 | sh """ 49 | #. venv/bin/activate 50 | [ -d report ] || mkdir report 51 | export PATH=${VIRTUAL_ENV}/bin:${PATH} 52 | make check || true 53 | """ 54 | sh """ 55 | export PATH=${VIRTUAL_ENV}/bin:${PATH} 56 | make flake8 | tee report/flake8.log || true 57 | """ 58 | sh """ 59 | export PATH=${VIRTUAL_ENV}/bin:${PATH} 60 | make pylint | tee report/pylint.log || true 61 | """ 62 | step([$class: 'WarningsPublisher', 63 | parserConfigurations: [[ 64 | parserName: 'Pep8', 65 | pattern: 'report/flake8.log' 66 | ], 67 | [ 68 | parserName: 'pylint', 69 | pattern: 'report/pylint.log' 70 | ]], 71 | unstableTotalAll: '0', 72 | usePreviousBuildAsReference: true 73 | ]) 74 | } 75 | } 76 | 77 | stage ('Unit Tests') { 78 | steps { 79 | sh """ 80 | #. venv/bin/activate 81 | export PATH=${VIRTUAL_ENV}/bin:${PATH} 82 | make unittest || true 83 | """ 84 | } 85 | 86 | post { 87 | always { 88 | junit keepLongStdio: true, testResults: 'report/nosetests.xml' 89 | publishHTML target: [ 90 | reportDir: 'report/coverage', 91 | reportFiles: 'index.html', 92 | reportName: 'Coverage Report - Unit Test' 93 | ] 94 | } 95 | } 96 | } 97 | 98 | stage ('System Tests') { 99 | steps { 100 | sh """ 101 | #. venv/bin/activate 102 | export PATH=${VIRTUAL_ENV}/bin:${PATH} 103 | // Write file containing test node connection information if needed. 104 | // writeFile file: "test/fixtures/nodes.yaml", text: "---\n- node: \n" 105 | make systest || true 106 | """ 107 | } 108 | 109 | post { 110 | always { 111 | junit keepLongStdio: true, testResults: 'report/nosetests.xml' 112 | publishHTML target: [ 113 | reportDir: 'report/coverage', 114 | reportFiles: 'index.html', 115 | reportName: 'Coverage Report - System Test' 116 | ] 117 | } 118 | } 119 | } 120 | 121 | stage ('Docs') { 122 | steps { 123 | sh """ 124 | #. venv/bin/activate 125 | export PATH=${VIRTUAL_ENV}/bin:${PATH} 126 | PYTHONPATH=. pdoc --html --html-dir docs --overwrite env.projectName 127 | """ 128 | } 129 | 130 | post { 131 | always { 132 | publishHTML target: [ 133 | reportDir: 'docs/*', 134 | reportFiles: 'index.html', 135 | reportName: 'Module Documentation' 136 | ] 137 | } 138 | } 139 | } 140 | 141 | stage ('Cleanup') { 142 | steps { 143 | sh 'rm -rf venv' 144 | } 145 | } 146 | } 147 | 148 | post { 149 | failure { 150 | mail body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build error " + 151 | "is here: ${env.BUILD_URL}\nStarted by ${env.BUILD_CAUSE}" , 152 | from: env.emailFrom, 153 | //replyTo: env.emailFrom, 154 | subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build failed", 155 | to: env.emailTo 156 | } 157 | success { 158 | mail body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build successful\n" + 159 | "Started by ${env.BUILD_CAUSE}", 160 | from: env.emailFrom, 161 | //replyTo: env.emailFrom, 162 | subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build successful", 163 | to: env.emailTo 164 | } 165 | } 166 | } 167 | --------------------------------------------------------------------------------