diff --git a/.gitignore b/.gitignore index 2bcb5340..f7fe9824 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ dist docs/_*/* docs/autodoc/ pyan/ +*.swp +tags +.coverage diff --git a/Jenkinsfile b/Jenkinsfile index 379ce05d..3148d590 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -103,6 +103,23 @@ pipeline { } } + + // stage('Nosetest'){ + // steps{ + // sh ''' + // echo ${SHELL} + // [ -d venv ] && rm -rf venv + // #virtualenv --python=python2.7 venv + // virtualenv venv + // #. venv/bin/activate + // export PATH=${VIRTUAL_ENV}/bin:${PATH} + // python setup.py install + // sudo apt-get install python-mock python-nose python-coverage pylint + + // ''' + // } + // } + // stage('Pylint Checker') { // steps { // sh ''' @@ -137,7 +154,7 @@ pipeline { pip install radon radon raw --json PyBitmessage/ > raw_report.json radon cc --json PyBitmessage/ > cc_report.json - radon mi --json PyBitmessage/ > mi_report.json + radon mi --json PyBitmessage/ > mi_report.json ''' @@ -200,6 +217,23 @@ pipeline { } } } + + stage('Setup Test') { + steps { + sh ''' export PATH=${VIRTUAL_ENV}/bin:${PATH} + pip install pytest + pip install psutil + pip install python-prctl==1.5.0 + python -m pytest --verbose --junit-xml results.xml + ''' + } + post { + always { + // Archive unit tests for the future + junit allowEmptyResults: true, testResults: 'results.xml' + } + } + } // stage('Unit tests') { // steps { // sh ''' source activate ${BUILD_TAG} diff --git a/Jenkinsfile1 b/Jenkinsfile1 deleted file mode 100644 index c4012809..00000000 --- a/Jenkinsfile1 +++ /dev/null @@ -1,40 +0,0 @@ -pipeline { - agent any - - triggers { - pollSCM('*/5 * * * *') - } - - - stages { - - stage('Build environment') { - steps { - sh '''source /home/cis/Desktop/ENV/pybitenv/bin/activate''' - sh '''pip install -r /home/cis/Desktop/Python/PyBitmessage/requirements.txt''' - } - } - stage('Test environment') { - steps { - sh '''source /home/cis/Desktop/ENV/pybitenv/bin/activate - cd /home/cis/Desktop/Python/PyBitmessage - sudo python setup.py install - sudo su - sudo /home/cis/.local/bin/nosetests --with-xunit tests - ''' - } - } - stage('Test Run') { - steps { - sh '''python /home/cis/Desktop/Python/PyBitmessage/src/bitmessagemain.py -t - ''' - } - } - } - - post { - failure { - echo "Send e-mail, when failed" - } - } -} diff --git a/Jenkinsfile2 b/Jenkinsfile2 deleted file mode 100644 index d99b3f09..00000000 --- a/Jenkinsfile2 +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env groovy - -/** - * Jenkinsfile - */ -pipeline { - agent any - options { - buildDiscarder( - // Only keep the 10 most recent builds - logRotator(numToKeepStr:'10')) - } - environment { - projectName = 'BitMessage' - emailTo = 'kuldeep.m@cisinlabs.com' - emailFrom = 'kuldeep.m@cisinlabs.com' - VIRTUAL_ENV = "${env.WORKSPACE}/venv" - } - - stages { - - /* - stage ('Checkout') { - steps { - checkout scm - } - } - */ - - stage ('Install_Requirements') { - steps { - sh """ - echo ${SHELL} - [ -d venv ] && rm -rf venv - #virtualenv --python=python2.7 venv - virtualenv venv - #. venv/bin/activate - export PATH=${VIRTUAL_ENV}/bin:${PATH} - pip install --upgrade pip - pip install -r requirements.txt -r dev-requirements.txt - make clean - """ - } - } - - stage ('Check_style') { - steps { - sh """ - #. venv/bin/activate - [ -d report ] || mkdir report - export PATH=${VIRTUAL_ENV}/bin:${PATH} - make check || true - """ - sh """ - export PATH=${VIRTUAL_ENV}/bin:${PATH} - make flake8 | tee report/flake8.log || true - """ - sh """ - export PATH=${VIRTUAL_ENV}/bin:${PATH} - make pylint | tee report/pylint.log || true - """ - step([$class: 'WarningsPublisher', - parserConfigurations: [[ - parserName: 'Pep8', - pattern: 'report/flake8.log' - ], - [ - parserName: 'pylint', - pattern: 'report/pylint.log' - ]], - unstableTotalAll: '0', - usePreviousBuildAsReference: true - ]) - } - } - - stage ('Unit Tests') { - steps { - sh """ - #. venv/bin/activate - export PATH=${VIRTUAL_ENV}/bin:${PATH} - make unittest || true - """ - } - - post { - always { - junit keepLongStdio: true, testResults: 'report/nosetests.xml' - publishHTML target: [ - reportDir: 'report/coverage', - reportFiles: 'index.html', - reportName: 'Coverage Report - Unit Test' - ] - } - } - } - - stage ('System Tests') { - steps { - sh """ - #. venv/bin/activate - export PATH=${VIRTUAL_ENV}/bin:${PATH} - // Write file containing test node connection information if needed. - // writeFile file: "test/fixtures/nodes.yaml", text: "---\n- node: \n" - make systest || true - """ - } - - post { - always { - junit keepLongStdio: true, testResults: 'report/nosetests.xml' - publishHTML target: [ - reportDir: 'report/coverage', - reportFiles: 'index.html', - reportName: 'Coverage Report - System Test' - ] - } - } - } - - stage ('Docs') { - steps { - sh """ - #. venv/bin/activate - export PATH=${VIRTUAL_ENV}/bin:${PATH} - PYTHONPATH=. pdoc --html --html-dir docs --overwrite env.projectName - """ - } - - post { - always { - publishHTML target: [ - reportDir: 'docs/*', - reportFiles: 'index.html', - reportName: 'Module Documentation' - ] - } - } - } - - stage ('Cleanup') { - steps { - sh 'rm -rf venv' - } - } - } - - post { - failure { - mail body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build error " + - "is here: ${env.BUILD_URL}\nStarted by ${env.BUILD_CAUSE}" , - from: env.emailFrom, - //replyTo: env.emailFrom, - subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build failed", - to: env.emailTo - } - success { - mail body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build successful\n" + - "Started by ${env.BUILD_CAUSE}", - from: env.emailFrom, - //replyTo: env.emailFrom, - subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build successful", - to: env.emailTo - } - } -} \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index 64233a9e..00000000 --- a/index.html +++ /dev/null @@ -1 +0,0 @@ -index.html \ No newline at end of file diff --git a/src/proofofwork.py b/src/proofofwork.py index bb16951c..e5c2a1eb 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-branches,too-many-statements,protected-access + # pylint: disable=too-many-branches,too-many-statements,protected-access """ src/proofofwork.py ==================