2018-05-12 15:56:17 +00:00
|
|
|
def pys = [
|
2021-10-10 16:56:11 +00:00
|
|
|
[name: 'Python 3.10', docker: 'python:3.10-buster', tox:'py310,flake8', main: true],
|
|
|
|
[name: 'Python 3.9', docker: 'python:3.9-buster', tox:'py39', main: false],
|
|
|
|
[name: 'Python 3.8', docker: 'python:3.8-buster', tox:'py38', main: false],
|
|
|
|
[name: 'Python 3.7', docker: 'python:3.7-buster', tox:'py37', main: false],
|
|
|
|
[name: 'Python 3.6', docker: 'python:3.6-buster', tox:'py36', main: false],
|
2018-05-12 15:56:17 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
properties([
|
|
|
|
durabilityHint('PERFORMANCE_OPTIMIZED'),
|
2020-04-11 09:43:29 +00:00
|
|
|
buildDiscarder(logRotator(numToKeepStr: '100')),
|
2018-05-12 15:56:17 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
Map tasks = [failFast: true]
|
|
|
|
|
|
|
|
pys.each { py ->
|
|
|
|
tasks[py.name] = {
|
|
|
|
node {
|
|
|
|
def image
|
|
|
|
|
|
|
|
stage("Prepare docker $py.name") {
|
|
|
|
dir('dockerbuild') {
|
|
|
|
deleteDir()
|
2019-07-14 13:19:57 +00:00
|
|
|
docker.image(py.docker).pull()
|
2018-05-12 15:56:17 +00:00
|
|
|
buildDockerfile(py.docker)
|
|
|
|
image = docker.build("dosage-$py.docker")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage("Build $py.name") {
|
|
|
|
image.inside {
|
|
|
|
checkout scm
|
|
|
|
sh '''
|
|
|
|
git clean -fdx
|
|
|
|
git fetch --tags
|
|
|
|
'''
|
|
|
|
|
2019-07-14 10:57:06 +00:00
|
|
|
warnError('tox failed') {
|
2018-05-12 15:56:17 +00:00
|
|
|
sh "tox -e $py.tox"
|
|
|
|
}
|
|
|
|
|
|
|
|
if (py.main) {
|
|
|
|
sh """
|
|
|
|
python setup.py sdist bdist_wheel
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (py.main) {
|
|
|
|
archiveArtifacts artifacts: 'dist/*', fingerprint: true
|
2018-05-13 22:50:45 +00:00
|
|
|
stash includes: 'dist/*.tar.gz', name: 'bin'
|
2021-05-01 09:08:51 +00:00
|
|
|
dir('.tox/reports') {
|
|
|
|
stash includes: '*/allure-data/**', name: 'allure-data'
|
2020-11-22 22:25:11 +00:00
|
|
|
}
|
2018-05-12 15:56:17 +00:00
|
|
|
def buildVer = findFiles(glob: 'dist/*.tar.gz')[0].name.replaceFirst(/\.tar\.gz$/, '')
|
|
|
|
currentBuild.description = buildVer
|
|
|
|
|
2019-10-28 15:15:26 +00:00
|
|
|
publishCoverage calculateDiffForChangeRequests: true,
|
|
|
|
sourceFileResolver: sourceFiles('STORE_LAST_BUILD'),
|
|
|
|
adapters: [
|
2021-05-01 09:08:51 +00:00
|
|
|
coberturaAdapter('.tox/reports/*/coverage.xml')
|
2019-10-28 15:15:26 +00:00
|
|
|
]
|
|
|
|
|
2019-07-14 11:12:03 +00:00
|
|
|
recordIssues sourceCodeEncoding: 'UTF-8',
|
2020-04-11 09:57:44 +00:00
|
|
|
referenceJobName: 'dosage/master',
|
2019-07-14 11:12:03 +00:00
|
|
|
tool: flake8(pattern: '.tox/flake8.log', reportEncoding: 'UTF-8')
|
2018-05-12 15:56:17 +00:00
|
|
|
}
|
2021-05-01 09:08:51 +00:00
|
|
|
junit '.tox/reports/*/junit.xml'
|
2018-05-12 15:56:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-19 13:27:56 +00:00
|
|
|
// MAIN //
|
|
|
|
|
|
|
|
parallel(tasks)
|
|
|
|
stage('Windows binary') {
|
|
|
|
windowsBuild()
|
|
|
|
}
|
|
|
|
stage('Allure report') {
|
|
|
|
processAllure()
|
2018-05-12 15:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def buildDockerfile(image) {
|
|
|
|
def uid = sh(returnStdout: true, script: 'id -u').trim()
|
|
|
|
writeFile file: 'Dockerfile', text: """
|
|
|
|
FROM $image
|
2020-08-19 09:05:36 +00:00
|
|
|
RUN pip install tox
|
2018-05-12 15:56:17 +00:00
|
|
|
RUN useradd -mu $uid dockerjenkins
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
2018-05-13 22:50:45 +00:00
|
|
|
def windowsBuild() {
|
2020-11-22 22:25:11 +00:00
|
|
|
warnError('windows build failed') {
|
|
|
|
node {
|
|
|
|
windowsBuildCommands()
|
2018-05-13 22:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-14 10:47:58 +00:00
|
|
|
def windowsBuildCommands() {
|
|
|
|
deleteDir()
|
|
|
|
unstash 'bin'
|
2020-12-12 16:55:29 +00:00
|
|
|
// Keep 3.8 for now, so we are still compatible with Windows 7
|
|
|
|
def img = docker.image('tobix/pywine:3.8')
|
2019-07-14 13:19:57 +00:00
|
|
|
img.pull()
|
|
|
|
img.inside {
|
2019-07-14 10:47:58 +00:00
|
|
|
sh '''
|
|
|
|
. /opt/mkuserwineprefix
|
|
|
|
tar xvf dist/dosage-*.tar.gz
|
|
|
|
cd dosage-*
|
|
|
|
xvfb-run sh -c "
|
|
|
|
wine py -m pip install -e .[css] &&
|
|
|
|
cd scripts &&
|
|
|
|
wine py -m PyInstaller -y dosage.spec;
|
2019-07-14 20:26:46 +00:00
|
|
|
wineserver -w" 2>&1 | tee log.txt
|
2019-07-14 10:47:58 +00:00
|
|
|
'''
|
|
|
|
archiveArtifacts '*/scripts/dist/*'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-22 22:25:11 +00:00
|
|
|
def processAllure() {
|
|
|
|
warnError('allure report failed') {
|
|
|
|
node {
|
|
|
|
deleteDir()
|
2021-05-01 09:08:51 +00:00
|
|
|
unstash 'allure-data'
|
|
|
|
sh 'mv */allure-data .'
|
2021-01-19 07:37:29 +00:00
|
|
|
copyArtifacts filter: 'allure-history.zip', optional: true, projectName: JOB_NAME, selector: lastWithArtifacts()
|
2020-11-27 23:37:05 +00:00
|
|
|
if (fileExists('allure-history.zip')) {
|
|
|
|
unzip dir: 'allure-data', quiet: true, zipFile: 'allure-history.zip'
|
|
|
|
sh 'rm -f allure-history.zip'
|
|
|
|
}
|
|
|
|
sh 'docker run --rm -v $PWD:/work -u $(id -u) tobix/allure-cli generate allure-data'
|
2020-11-26 23:00:11 +00:00
|
|
|
zip archive: true, dir: 'allure-report', glob: 'history/**', zipFile: 'allure-history.zip'
|
2020-11-22 22:25:11 +00:00
|
|
|
publishHTML reportDir: 'allure-report', reportFiles: 'index.html', reportName: 'Allure Report'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-12 15:56:17 +00:00
|
|
|
// vim: set ft=groovy:
|