diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..bfdb7f7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,93 @@ +pipeline { + agent none + stages { + stage ('Dependency check') { + agent { label 'use' } + steps { + script { + sh '''#!/usr/bin/env bash + source /opt/conda/etc/profile.d/conda.sh + conda create --yes -p "${WORKSPACE}@tmp/${BUILD_NUMBER}" python=3.9 + conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}" + pip install --use-deprecated=legacy-resolver -r requirements.dev.txt + pip check + pip list --outdated + conda deactivate + ''' + } + } + } + + stage('Tests') { + agent { label 'use' } + steps { + script { + script { + sh '''#!/usr/bin/env bash + source /opt/conda/etc/profile.d/conda.sh + conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}" + tox --recreate + conda deactivate + ''' + } + } + } + } + + stage('Lint') { + agent { label 'use' } + when { + anyOf { + branch 'develop' + branch pattern: "hotfix/.+", comparator: "REGEXP" + } + } + steps { + script { + sh '''#!/usr/bin/env bash + source /opt/conda/etc/profile.d/conda.sh + conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}" + pip install prospector[with_everything] + cd src/; prospector -0 + conda deactivate + ''' + } + } + } + + stage('Sonar') { + agent { label 'use' } + when { branch 'master' } + steps { + script { + sh '''#!/usr/bin/env bash + source /opt/conda/etc/profile.d/conda.sh + conda activate "${WORKSPACE}@tmp/${BUILD_NUMBER}" + pip install prospector[with_everything] + cd src; prospector -0 -o pylint:prospector.txt tsa + conda deactivate + ''' + def scannerHome = tool name: 'SonarQubeScanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation'; + withSonarQubeEnv('sonar') { + GIT_COMMIT_HASH = sh (script: "git log -n 1 --pretty=format:'%H'", returnStdout: true) + sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=cryptbase -Dsonar.projectVersion=${GIT_COMMIT_HASH} -Dsonar.python.pylint.reportPaths=prospector.txt -Dsonar.junit.reportsPath=junit-py39.xml -Dsonar.python.coverage.reportPaths=cov-py39.xml -Dsonar.coverage.dtdVerification=false" + } + } + } + } + + stage('Cleanup') { + agent { label 'use' } + steps { + dir("${env.WORKSPACE}@tmp") { + deleteDir() + } + } + } + } + post { + always { + mattermostSend "Completed ${env.JOB_NAME} ${env.BUILD_NUMBER}: ${currentBuild.currentResult}" + } + } +} diff --git a/requirements.dev.txt b/requirements.dev.txt new file mode 100644 index 0000000..4e0772c --- /dev/null +++ b/requirements.dev.txt @@ -0,0 +1,35 @@ +arrow==1.2.0 +backports.entry-points-selectable==1.1.0 +binaryornot==0.4.4 +build==0.7.0 +certifi==2021.5.30 +chardet==4.0.0 +charset-normalizer==2.0.6 +check-manifest==0.47 +click==8.0.1 +cookiecutter==1.7.3 +distlib==0.3.3 +filelock==3.3.0 +greenlet==1.1.2 +idna==3.2 +Jinja2==3.0.2 +jinja2-time==0.2.0 +MarkupSafe==2.0.1 +packaging==21.0 +pep517==0.11.0 +platformdirs==2.4.0 +pluggy==1.0.0 +poyo==0.5.0 +py==1.10.0 +pyparsing==2.4.7 +python-dateutil==2.8.2 +python-slugify==5.0.2 +requests==2.26.0 +six==1.16.0 +SQLAlchemy==1.4.25 +text-unidecode==1.3 +toml==0.10.2 +tomli==1.2.1 +tox==3.24.4 +urllib3==1.26.7 +virtualenv==20.8.1 diff --git a/src/.prospector.yaml b/src/.prospector.yaml new file mode 100644 index 0000000..1da7e6e --- /dev/null +++ b/src/.prospector.yaml @@ -0,0 +1,33 @@ +output-format: pylint +strictness: veryhigh +max-line-length: 200 +doc-warnings: false +pylint: + member-warnings: false + disable: + - too-few-public-methods +bandit: + run: true +dodgy: + run: true +mccabe: + run: true +pep8: + run: true + full: true +frosted: + run: false +pyflakes: + run: true +pyroma: + run: true +pylint: + run: true + disable: + - too-few-public-methods +vulture: + run: true +mypy: + run: true + options: + ignore-missing-imports: true diff --git a/tox.ini b/tox.ini index e1d435f..6c31863 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ passenv = envlist = clean, check, - docs, +; docs, {py36,py37,py38,py39,pypy3}, report ignore_basepython_conflict = true @@ -38,7 +38,7 @@ deps = pytest pytest-cov commands = - {posargs:pytest --cov --cov-report=term-missing -vv tests} + {posargs:pytest --junitxml=junit-{envname}.xml --cov --cov-report=xml:cov-{envname}.xml -vv tests} [testenv:check] deps =