diff --git a/jobs/templates/swh-pipeline.yaml b/jobs/templates/swh-pipeline.yaml index bf7c2b0..00545d4 100644 --- a/jobs/templates/swh-pipeline.yaml +++ b/jobs/templates/swh-pipeline.yaml @@ -1,78 +1,111 @@ - job-template: name: "{name}/tests" project-type: pipeline sandbox: true numToKeep: 20 dsl: | pipeline {{ agent {{ label 'swh-tox' }} parameters {{ gitParameter name: 'REVISION', type: 'PT_REVISION', defaultValue: 'master' string name: 'PHID', description: 'PHID of the Phabricator target object on which results will be reported.' }} - stage('Static analysis') {{ - steps {{ - echo "flake8" - sh '''python3 -m flake8''' - echo "radon" - sh ''' - mkdir -p reports - python3 -m pip install --user --upgrade https://github.com/douardda/radon/archive/main-module.zip - python3 -m radon raw --json swh/ > reports/raw_report.json - python3 -m radon cc --json swh/ > reports/cc_report.json - python3 -m radon mi --json swh/ > reports/mi_report.json - python3 -m radon hal --json swh/ > reports/hal_report.json - python3 -m radon cc --xml swh/ > reports/cc_report.xml - ''' - }} - }} - stage('Unit tests') {{ - steps {{ - sh ''' - cat >tox4jenkins.ini < reports/raw_report.json + python3 -m radon cc --json swh/ > reports/cc_report.json + python3 -m radon mi --json swh/ > reports/mi_report.json + python3 -m radon hal --json swh/ > reports/hal_report.json + python3 -m radon cc --xml swh/ > reports/cc_report.xml + ''' + }} + }} // static analysis + + stage('Unit tests') {{ + options {{ + timeout(time: 5, unit: 'MINUTES') + }} + steps {{ + sh ''' + python3 -m tox -- \ + --cov-report=xml \ + --junit-xml=test-results.xml + ''' + }} + post {{ + always {{ + step([$class: 'CoberturaPublisher', + autoUpdateHealth: false, + autoUpdateStability: false, + coberturaReportFile: 'coverage.xml', + failNoReports: false, + failUnhealthy: false, + failUnstable: false, + maxNumberOfBuilds: 10, + onlyStable: false, + sourceEncoding: 'ASCII', + zoomCoverageChart: false]) + // JUnit report + junit allowEmptyResults: true, + testResults: 'test-results.xml' + + // disabled for now, requires the plugin Warning v5 (still in RC) + //recordIssues enabledForFailure: true, + // tools: [[pattern: '**/reports/cc_report.xml', tool: [$class: 'Ccm']]] + }} + }} // post + }} // unit tests + }} // parallel + }} // stage Tests + + stage('Build') {{ + steps {{ + sh 'python3 setup.py sdist bdist_wheel' }} }} - }} - }} - }} + + // stage('Publish') {{ + // when {{ buildingTag() }} + // steps {{ + // TODO + // }} + // }} + }} // stages + + post {{ + always {{ + // Archive a few report files + archiveArtifacts allowEmptyArchive: true, + artifacts: 'reports/*,*.xml,tox*.ini', + fingerprint: true + }} + }} // post + }} // pipeline