diff --git a/jobs/templates/swh-pipeline.groovy b/jobs/templates/swh-pipeline.groovy index fd9e045..412badd 100644 --- a/jobs/templates/swh-pipeline.groovy +++ b/jobs/templates/swh-pipeline.groovy @@ -1,124 +1,125 @@ pipeline {{ agent {{ label '{docker-image}' }} environment {{ PHAB_CONDUIT_URL = 'https://forge.softwareheritage.org/api/' }} stages {{ stage('Checkout') {{ steps {{ withCredentials([ string(credentialsId: 'swh-public-ci', variable: 'PHAB_CONDUIT_TOKEN')]) {{ sh ''' if [ -n "$PHID" ]; then echo "{{ \\\"buildTargetPHID\\\": \\\"$PHID\\\", \\\"artifactKey\\\": \\\"link.jenkins\\\", \\\"artifactType\\\": \\\"uri\\\", \\\"artifactData\\\": {{ \\\"uri\\\": \\\"$BUILD_URL\\\", \\\"name\\\": \\\"Jenkins\\\", \\\"ui.external\\\": true }} }}" | arc call-conduit --conduit-uri $PHAB_CONDUIT_URL --conduit-token $PHAB_CONDUIT_TOKEN harbormaster.createartifact python3 -m pyarcanist send-message work $PHID fi ''' }} checkout([$class: 'GitSCM', branches: [[name: "${{params.REVISION}}"]], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [[url: 'https://forge.softwareheritage.org/source/{display-name}.git']], browser: [$class: 'Phabricator', repoUrl: 'https://forge.softwareheritage.org', repo: '{name}'] ]) }} }} stage('Static analysis') {{ steps {{ echo 'flake8' sh '''python3 -m tox -e flake8''' echo 'mypy' sh '''if python3 -m tox -a 2>/dev/null | grep -qx mypy ; then python3 -m tox -e mypy ; fi''' echo 'radon'; sh ''' mkdir -p reports 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 ''' }} }} // static analysis stage('Unit tests') {{ options {{ timeout(time: 20, unit: 'MINUTES') }} steps {{ sh ''' python3 -m tox -e $TOX_ENVIRONMENT -- \ --cov-report=xml \ - --junit-xml=test-results.xml + --junit-xml=test-results.xml \ + -v ''' }} 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 }} // stages post {{ always {{ // Archive a few report files archiveArtifacts allowEmptyArchive: true, artifacts: 'reports/*,*.xml,tox*.ini', fingerprint: true withCredentials([ string(credentialsId: 'swh-public-ci', variable: 'PHAB_CONDUIT_TOKEN')]) {{ withEnv(["JOBSTATUS=${{currentBuild.currentResult}}"]) {{ sh ''' if [ "$JOBSTATUS" = "SUCCESS" ]; then MSGTYPE=pass else MSGTYPE=fail fi echo "Current job status is $JOBSTATUS -> $MGSTYPE" if [ -n "$PHID" ]; then python3 -m pyarcanist send-message $MSGTYPE $PHID fi ''' }} // withEnv }} // withCredentials }} // always }} // post }} // pipeline diff --git a/jobs/templates/swh-tox.yaml b/jobs/templates/swh-tox.yaml index 198d608..4eca7a9 100644 --- a/jobs/templates/swh-tox.yaml +++ b/jobs/templates/swh-tox.yaml @@ -1,57 +1,57 @@ - job-template: name: '{name}/tox' display-name: 'Phab. Diff' docker-image: swh-tox node: "{docker-image}" default-tox-environment: py3 auth-token: ph4br1cat0r parameters: - string: name: REPO description: PHID of the Diffusion repository - string: name: PHID description: PHID of the Target object - string: name: DIFF_ID description: ID of the Diff patch to apply, if any - string: name: TOX_ENVIRONMENT description: tox environment to use for the main tox run default: "{default-tox-environment}" scm: - git: url: https://forge.softwareheritage.org/source/{display-name}.git branches: - origin/master wrappers: - phabricator-differential: apply-to-master: true patch-with-force-flag: true builders: - shell: | echo "Run tox for:" echo " REPO=$REPO" echo " PHID=$PHID" echo " DIFF_ID=$DIFF_ID" - shell: | if (python3 -m tox -a 2>/dev/null | grep -qx flake8-phab ); then python3 -m tox -e flake8-phab else python3 -m tox -e flake8 fi - - shell: python3 -m tox --result-json tox-results.json -e $TOX_ENVIRONMENT + - shell: python3 -m tox --result-json tox-results.json -e $TOX_ENVIRONMENT -- -v publishers: - phabricator: uberalls-enabled: false comment-on-success: true comment-with-console-link-on-failure: true process-lint: true lint-file: .phabricator-lint lint-file-size: 1000000 - archive: artifacts: "*.json,.coverage*,.phabricator*"