From 09216807e35994a16b0da547feefc793ef897afc Mon Sep 17 00:00:00 2001 From: Patrik Dufresne Date: Mon, 26 Feb 2018 14:52:41 -0500 Subject: [PATCH] Add gitlab-ci.yml config --- .gitlab-ci.yml | 53 ++++++++++++++++ Jenkinsfile | 101 ------------------------------ rdiffweb/filter_authentication.py | 2 +- setup.py | 3 +- 4 files changed, 56 insertions(+), 103 deletions(-) create mode 100644 .gitlab-ci.yml delete mode 100644 Jenkinsfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..80720a85 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,53 @@ +image: ikus060/docker-debian-py2-py3:stretch + +stages: +- test +- publish + +# Upgrade python and install dependencies to avoid compiling from sources. +before_script: +- apt-get update && apt-get -qq install python-pysqlite2 libldap2-dev libsasl2-dev rdiff-backup node-less +- pip install pip setuptools --upgrade + +# TODO Split this by python version and OS. +test_py27: + stage: test + script: + - pip install tox nose coverage --upgrade + - python setup.py build + - export TOXENV=`tox --listenvs | grep "^py27" | tr '\n' ','` + - tox --sitepackages + +test_py3: + stage: test + script: + - pip install tox nose coverage --upgrade + - python setup.py build + - export TOXENV=`tox --listenvs | grep "^py3" | tr '\n' ','` + - tox --sitepackages + +# TODO Publish coverage repport +# TODO Publish testcases repport + +publish_nexus: + stage: publish + script: + - pip install wheel twine --upgrade + - python setup.py sdist bdist_wheel + - twine upload dist/* -u $NEXUS_USR -p $NEXUS_PWD --repository-url $NEXUS_PYPI_URL + +publish_pypi: + stage: publish + only: + - master + script: + - pip install wheel twine --upgrade + - python setup.py sdist bdist_wheel + - twine upload dist/* -u $PYPI_USR -p $PYPI_PWD + +github_push: + stage: publish + script: + - git push --force https://${GITHUB_USR}:${GITHUB_PWD}@github.com/ikus060/rdiffweb.git refs/remotes/origin/${CI_COMMIT_REF_NAME}:refs/heads/${CI_COMMIT_REF_NAME} + - git push https://${GITHUB_USR}:${GITHUB_PWD}@github.com/ikus060/rdiffweb.git --tags + diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 7a790d1c..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,101 +0,0 @@ -def axisImages = ['jessie', 'stretch'] -def axisPython = ['py27', 'py3'] -def axisCherrypy = ['cherrypy35','cherrypy4','cherrypy5','cherrypy6','cherrypy7','cherrypy8','cherrypy9','cherrypy10','cherrypy11','cherrypy12','cherrypy13','cherrypy14'] - - -def builders = [:] -for (x in axisImages) { -for (y in axisPython) { -for (z in axisCherrypy) { - // Need to bind the label variable before the closure - can't do 'for (label in labels)' - def image = x - def python = y - def cherrypy = z - def env = "${python}-${cherrypy}" - - // Create a map to pass in to the 'parallel' step so we can fire all the builds at once - builders["${image}-${env}"] = { - node { - /* Requires the Docker Pipeline plugin to be installed */ - docker.image("ikus060/docker-debian-py2-py3:${image}").inside { - stage("${image}-${env}:Initialize") { - // Wipe working directory to make sure to build clean. - deleteDir() - // Checkout - checkout scm - echo 'Upgrade python and install dependencies to avoid compiling from sources.' - sh 'apt-get update && apt-get -qq install python-pysqlite2 libldap2-dev libsasl2-dev rdiff-backup node-less' - sh 'pip install pip setuptools tox --upgrade' - } - stage("${image}-${env}:Build") { - echo 'Compile catalog and less' - sh 'python setup.py build' - } - stage("${image}-${env}:Test") { - try { - sh "tox --recreate --workdir /tmp --sitepackages -e ${env}" - } finally { - junit "nosetests-${env}.xml" - step([$class: 'CoberturaPublisher', coberturaReportFile: "coverage-${env}.xml"]) - } - } - } - } - } -}}} - -parallel builders - -node { - stage ('Publish') { - if (env.BRANCH_NAME == 'master') { - // Wipe working directory to make sure to build clean. - deleteDir() - // Checkout - checkout scm - // Define version - def pyVersion = sh( - script: 'python setup.py --version | tail -n1', - returnStdout: true - ).trim() - def version = pyVersion.replaceFirst(".dev.*", ".${BUILD_NUMBER}") - - // Push changes to git - withCredentials([usernamePassword(credentialsId: 'gitlab-jenkins', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) { - sh """ - sed -i.bak -r "s/version='(.*).dev.*'/version='${version}'/" setup.py - git config --local user.email "jenkins@patrikdufresne.com" - git config --local user.name "Jenkins" - git commit setup.py -m 'Release ${version}' - git tag '${version}' - git push http://${GIT_USERNAME}:${GIT_PASSWORD}@git.patrikdufresne.com/pdsl/rdiffweb.git --tags - """ - } - - - // Publish to pypi - docker.image("ikus060/docker-debian-py2-py3:jessie").inside { - withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'ikus060-pypi', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { - sh """ - cat > ~/.pypirc << EOF -[distutils] -index-servers = - pypi - -[pypi] -username=${USERNAME} -password=${PASSWORD} -EOF - """ - writeFile file: "/root/.pypirc", text: """ - - """ - sh 'cat /root/.pypirc' - sh 'pip install wheel --upgrade' - sh 'python setup.py sdist bdist_wheel upload -r pypi' - } - } - } - - } -} \ No newline at end of file diff --git a/rdiffweb/filter_authentication.py b/rdiffweb/filter_authentication.py index fef8b0f1..f34da8b3 100644 --- a/rdiffweb/filter_authentication.py +++ b/rdiffweb/filter_authentication.py @@ -184,7 +184,7 @@ class AuthFormTool(BaseAuth): return self.do_logout(**request.params) # No special path, validate session. - logger.info('no special path, running do_check') + logger.debug('no special path, running do_check') return self.do_check() diff --git a/setup.py b/setup.py index b6a43ea2..9751ea6d 100644 --- a/setup.py +++ b/setup.py @@ -169,7 +169,7 @@ if PY2: setup( name='rdiffweb', - version='0.10.6.dev1', + use_scm_version=True, description='A web interface to rdiff-backup repositories', author='Patrik Dufresne', author_email='info@patrikdufresne.com', @@ -202,6 +202,7 @@ setup( # required packages for build process setup_requires=[ "babel>=0.9.6", + "setuptools_scm", ], # requirement for testing tests_require=[ -- GitLab