Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9341759
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
View Options
diff --git a/jobs/templates/swh-pipeline.yaml b/jobs/templates/swh-pipeline.yaml
index 8b87ab3..6e642af 100644
--- a/jobs/templates/swh-pipeline.yaml
+++ b/jobs/templates/swh-pipeline.yaml
@@ -1,170 +1,178 @@
- job-template:
name: "{name}/tests"
project-type: pipeline
triggers:
- timed: '@daily'
sandbox: true
auth-token: 'ph4br1cat0r'
properties:
- build-discarder:
num-to-keep: 20
parameters:
- git-parameter:
name: REVISION
type: PT_REVISION
defaultValue: master
description: Git revision to build.
- string:
name: PHID
description: PHID of the Phabricator target object on which results will be reported.
- string:
name: PYPI
description: |
PYPI registry to publish to when built revision is a tag. There
must exists a usernamePassword credential object with that name.
The publication endpoint is built as https://$PYPI/legagy/
default: test.pypi.org
- bool:
name: FORCE_UPLOAD
default: false
description: |
Force uploading python packages on the chosen PYPI registry.
dsl: |
pipeline {{
agent {{ label 'swh-tox' }}
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
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']]
])
}}
}}
stage('Tests') {{
parallel {{
stage('Static analysis') {{
steps {{
echo 'flake8'
sh '''python3 -m tox -e flake8 --parallel--safe-build'''
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: 5, unit: 'MINUTES')
}}
steps {{
sh '''
python3 -m tox -e py3 --parallel--safe-build -- \
--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 {{ anyOf {{
expression {{ return params.FORCE_UPLOAD }}
- expression {{
- GITTAG=sh(returnStdout: true, script:'git describe --exact-match 2>/dev/null || true').trim()
- return GITTAG != ''
+ allOf {{
+ expression {{
+
+ }}
+ expression {{
+ GITTAG=sh(returnStdout: true,
+ script:'git describe --exact-match 2>/dev/null || true').trim()
+ LASTV=sh(returnStdout: true,
+ script:'curl -s https://${{params.PYPI}}/pypi/`python setup.py --name`/json | jq -r .info.version || true').trim()
+ return ! (GITTAG in ['', 'v'+LASTV])
+ }}
}}
}}
}}
steps {{
withCredentials([
usernamePassword(credentialsId: "${{params.PYPI}}",
usernameVariable: 'TWINE_USERNAME',
passwordVariable: 'TWINE_PASSWORD')]) {{
sh 'python3 -m twine upload --repository-url https://${{PYPI}}/legacy/ dist/*'
}}
}}
}}
}} // 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
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jul 4, 12:18 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3255656
Attached To
rCJSWH Jenkins jobs
Event Timeline
Log In to Comment