-
Notifications
You must be signed in to change notification settings - Fork 59
/
Jenkinsfile
141 lines (125 loc) · 4.54 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
def pys = [
[name: 'Python 3.12', docker: '3.12-bookworm', tox:'py312,flake8', main: true],
[name: 'Python 3.11', docker: '3.11-bookworm', tox:'py311', main: false],
[name: 'Python 3.10', docker: '3.10-bookworm', tox:'py310', main: false],
[name: 'Python 3.9', docker: '3.9-bookworm', tox:'py39', main: false],
[name: 'Python 3.8', docker: '3.8-bookworm', tox:'py38', main: false],
]
properties([
durabilityHint('PERFORMANCE_OPTIMIZED'),
buildDiscarder(logRotator(numToKeepStr: '100')),
])
Map tasks = [failFast: true]
pys.each { py ->
tasks[py.name] = {
node {
stage("Checkout $py.name") {
checkout scm
sh '''
git clean -fdx
git fetch --tags
'''
}
stage("Build $py.name") {
def image = docker.image('docker.io/python:' + py.docker)
image.pull()
image.inside {
def tmpDir = pwd(tmp: true)
warnError('tox failed') {
sh """
HOME='$tmpDir'
pip install --no-warn-script-location tox
python -m tox -e $py.tox
"""
}
if (py.main) {
sh """
HOME='$tmpDir'
pip install --no-warn-script-location build
python -m build
"""
}
}
if (py.main) {
archiveArtifacts artifacts: 'dist/*', fingerprint: true
stash includes: 'dist/*.tar.gz', name: 'bin'
dir('.tox/reports') {
stash includes: '*/allure-data/**', name: 'allure-data'
}
def buildVer = findFiles(glob: 'dist/*.tar.gz')[0].name.replaceFirst(/\.tar\.gz$/, '')
currentBuild.description = buildVer
recordCoverage sourceCodeEncoding: 'UTF-8', tools: [
[parser: 'COBERTURA', pattern: '.tox/reports/*/coverage.xml']
]
recordIssues sourceCodeEncoding: 'UTF-8',
referenceJobName: 'dosage/master',
tool: flake8(pattern: '.tox/flake8.log', reportEncoding: 'UTF-8')
}
junit '.tox/reports/*/junit.xml'
}
}
}
}
// MAIN //
parallel(tasks)
parallel modern: {
stage('Modern Windows binary') {
windowsBuild('3.12', 'dosage.exe')
}
},
legacy: {
stage('Legacy Windows binary') {
// Still compatible with Windows 7
windowsBuild('3.8', 'dosage-legacy.exe')
}
},
report: {
stage('Allure report') {
processAllure()
}
}, failFast: true
def windowsBuild(pyver, exename) {
warnError('windows build failed') {
node {
windowsBuildCommands(pyver, exename)
}
}
}
def windowsBuildCommands(pyver, exename) {
deleteDir()
unstash 'bin'
def img = docker.image('docker.io/tobix/pywine:' + pyver)
img.pull()
img.inside {
sh '''
. /opt/mkuserwineprefix
tar xvf dist/dosage-*.tar.gz
cd dosage-*
xvfb-run sh -c "
wine python -m pip install .[css] &&
cd scripts &&
wine python -m PyInstaller -y dosage.spec;
wineserver -w" 2>&1 | tee log.txt
'''
sh "mv */scripts/dist/*.exe $exename"
archiveArtifacts '*.exe'
}
}
def processAllure() {
warnError('allure report failed') {
node {
deleteDir()
unstash 'allure-data'
sh 'mv */allure-data .'
copyArtifacts filter: 'allure-history.zip', optional: true, projectName: JOB_NAME, selector: lastWithArtifacts()
if (fileExists('allure-history.zip')) {
unzip dir: 'allure-data', quiet: true, zipFile: 'allure-history.zip'
sh 'rm -f allure-history.zip'
}
sh 'podman run --rm -v $PWD:/work --userns=keep-id docker.io/tobix/allure-cli generate allure-data'
zip archive: true, dir: 'allure-report', glob: 'history/**', zipFile: 'allure-history.zip'
publishHTML reportDir: 'allure-report', reportFiles: 'index.html', reportName: 'Allure Report'
}
}
}
// vim: set ft=groovy: