From eeb2c002b1ee84406f22a64e1cea69cc0687d63c Mon Sep 17 00:00:00 2001 From: Mike Marchetti Date: Thu, 25 May 2017 11:34:25 -0400 Subject: [PATCH] utilize tox to build Signed-off-by: Mike Marchetti Change-Id: I945367246c18b73fff0788b9b285a2fc9a897cc9 --- .gitignore | 1 + Dockerfile | 5 ++--- Jenkinsfile | 12 ++++++++--- Makefile | 49 ------------------------------------------- README.md | 1 + docker_command.sh | 7 +++++++ setup.py | 3 ++- test_requirements.txt | 4 ---- tox.ini | 19 +++++++++++++++++ 9 files changed, 41 insertions(+), 60 deletions(-) delete mode 100644 Makefile create mode 100755 docker_command.sh delete mode 100644 test_requirements.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index a5abf37..0584915 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/ .eggs *venv/ *venv3/ +.tox/ diff --git a/Dockerfile b/Dockerfile index 28b7be9..b7a8a91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM ubuntu:16.04 RUN apt-get update && apt-get -y install git make python python3 \ - virtualenv libcurl4-gnutls-dev libgnutls-dev python-pip python3-pip \ - debhelper python-stdeb apt-utils python-nose python3-nose python-flake8 \ - python-mock python3-mock + libcurl4-gnutls-dev libgnutls-dev tox python-dev python3-dev \ + debhelper python-setuptools python-all apt-utils diff --git a/Jenkinsfile b/Jenkinsfile index 729fd56..0264be0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,21 +1,27 @@ pipeline { agent { - dockerfile true + dockerfile { + label 'osm3' + } } stages { stage("Checkout") { steps { checkout scm + sh ''' + groupadd -o -g $(id -g) -r jenkins + useradd -o -u $(id -u) --create-home -r -g jenkins jenkins + ''' } } stage("Test") { steps { - sh 'make test' + sh 'tox' } } stage("Build") { steps { - sh 'make package' + sh 'tox -e build' stash name: "deb-files", includes: "deb_dist/*.deb" } } diff --git a/Makefile b/Makefile deleted file mode 100644 index 7806fcb..0000000 --- a/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2017 Sandvine -# -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -all: build_tools - $(MAKE) test - $(MAKE) package - -BUILD_TOOLS=python python3 virtualenv \ - libcurl4-gnutls-dev python-pip \ - python3-pip libgnutls-dev debhelper - -build_tools: - sudo apt-get -y install $(BUILD_TOOLS) - -package: - python setup.py --command-packages=stdeb.command bdist_deb - -test_flake8: - pip install -Ur test_requirements.txt - python setup.py flake8 - -test_nose: test_requirements.txt - pip install -Ur test_requirements.txt - python setup.py test - -test_nose3: test_requirements.txt - pip3 install -Ur test_requirements.txt - python3 setup.py test - -test: test_flake8 test_nose test_nose3 - -.PHONY: package build_tools test test_flake8 test_nose test_nose3 - -clean: - rm -rf deb_dist dist osmclient.egg-info diff --git a/README.md b/README.md index 1df94df..b742339 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # python-osmclient A python client for osm orchestration + # Installation ## Install dependencies diff --git a/docker_command.sh b/docker_command.sh new file mode 100755 index 0000000..52e7824 --- /dev/null +++ b/docker_command.sh @@ -0,0 +1,7 @@ +#!/bin/sh +#helper routine that creates user/group in docker container +#necessary when using volumes and inputing -user into docker run +groupadd -o -g $(id -g) -r $2 +useradd -o -u $(id -u) --create-home -r -g $2 $1 +shift 2 +exec $@ diff --git a/setup.py b/setup.py index ad92135..8109b9f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='osmclient', - version='0.1', + version_command=('git describe --tags --long --dirty', 'pep440-git'), author='Mike Marchetti', author_email='mmarchetti@sandvine.com', packages=find_packages(), @@ -10,6 +10,7 @@ setup( install_requires=[ 'Click', 'prettytable', 'pyyaml', 'pycurl' ], + setup_requires=['setuptools-version-command'], test_suite='nose.collector', entry_points=''' [console_scripts] diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index a38d080..0000000 --- a/test_requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -flake8 -mock -stdeb -nose diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..280145a --- /dev/null +++ b/tox.ini @@ -0,0 +1,19 @@ +[tox] +envlist = py27,py3,flake8 + +[testenv] +deps=nose + mock +commands=nosetests + +[testenv:flake8] +basepython = python +deps = flake8 +commands = + flake8 setup.py + +[testenv:build] +basepython = python +deps = stdeb + setuptools-version-command +commands = python setup.py --command-packages=stdeb.command bdist_deb -- 2.25.1