utilize tox to build 76/1876/5
authorMike Marchetti <mmarchetti@sandvine.com>
Thu, 25 May 2017 15:34:25 +0000 (11:34 -0400)
committerMike Marchetti <mmarchetti@sandvine.com>
Mon, 29 May 2017 16:26:43 +0000 (12:26 -0400)
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
Change-Id: I945367246c18b73fff0788b9b285a2fc9a897cc9

.gitignore
Dockerfile
Jenkinsfile
Makefile [deleted file]
README.md
docker_command.sh [new file with mode: 0755]
setup.py
test_requirements.txt [deleted file]
tox.ini [new file with mode: 0644]

index a5abf37..0584915 100644 (file)
@@ -7,3 +7,4 @@ dist/
 .eggs
 *venv/
 *venv3/
+.tox/
index 28b7be9..b7a8a91 100644 (file)
@@ -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
index 729fd56..0264be0 100644 (file)
@@ -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 (file)
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
index 1df94df..b742339 100644 (file)
--- 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 (executable)
index 0000000..52e7824
--- /dev/null
@@ -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 $@
index ad92135..8109b9f 100644 (file)
--- 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 (file)
index a38d080..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-flake8
-mock
-stdeb
-nose
diff --git a/tox.ini b/tox.ini
new file mode 100644 (file)
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