-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJenkinsfile
212 lines (193 loc) · 5.91 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
@Library('[email protected]')
def runningOn(machine) {
println "Stage running on:"
println machine
}
def versionsPairs = [
"pyproject.toml": /version[\s='\"]*([\d.]+)/,
"settings.yml": /version[\s:'\"]*([\d.]+)/,
"CHANGELOG.rst": /(\d+\.\d+\.\d+)/,
"**/xscope_fileio/lib_build_info.cmake": /set\(LIB_VERSION \"?([\d.]+)/,
"**/xscope_fileio/module_build_info": /VERSION[\s='\"]*([\d.]+)/,
"**/xscope_fileio/xscope_io_common.h": /#define\s+XSCOPE_IO_VERSION\s+"(\d+\.\d+\.\d+)"/
]
def buildandTestPyWheel(delocate = false) {
runningOn(env.NODE_NAME)
dir('xscope_fileio') {
checkout scm
withTools(params.TOOLS_VERSION) {
createVenv(reqFile:"requirements.txt")
withVenv {
sh "pip install build cmake ninja"
sh "python -m build --wheel"
if (delocate) { // delocate fixes wheels on macos
sh "pip install delocate"
sh "delocate-wheel dist/*.whl"
}
sh "pip install --find-links=dist xscope_fileio --force-reinstall"
dir('tests') {
sh "cmake -G Ninja -B build -S simple"
sh "cmake --build build"
sh "pytest test_simple.py"
}
archiveArtifacts artifacts: "dist/*.whl", allowEmptyArchive: true, fingerprint: true
}
}
}
}
getApproval()
pipeline {
agent none
parameters {
string(
name: 'TOOLS_VERSION',
defaultValue: '15.3.0',
description: 'The tools version to build with (check /projects/tools/ReleasesTools/)'
)
string(
name: 'XMOSDOC_VERSION',
defaultValue: 'v6.3.0',
description: 'xmosdoc version'
)
} // parameters
environment {
REPO_NAME = 'xscope_fileio' //TODO remove this after Jenkins Shared Library Update
} // environment
options {
skipDefaultCheckout()
timestamps()
buildDiscarder(xmosDiscardBuildSettings(onlyArtifacts=false))
} // options
stages {
stage('xcore.ai') {
agent {
label 'xcore.ai' // xcore.ai nodes have 2 devices atatched, allowing parallel HW test
}
stages {
stage('Checkout') {
steps {
runningOn(env.NODE_NAME)
dir('xscope_fileio') {
checkout scm
sh "git clone [email protected]:xmos-int/xtagctl.git"
} // dir
} // steps
} // stage 'Checkout'
stage('Install Dependencies') {
steps {
dir('xscope_fileio') {
withTools(params.TOOLS_VERSION) {
createVenv(reqFile:"requirements.txt")
withVenv {
sh "pip install -e xtagctl/"
}
}
}
}
}
stage('Static analysis') {
steps {
dir('xscope_fileio') {
withVenv {
warnError("Flake") {
sh "flake8 --exit-zero --output-file=flake8.xml xscope_fileio"
recordIssues enabledForFailure: true, tool: flake8(pattern: 'flake8.xml')
}
}
}
}
}
stage('Build examples') {
steps {
dir("xscope_fileio/examples") {
xcoreBuild()
} // dir
} // steps
} // Build examples
stage('Build tests') {
steps {
dir("xscope_fileio/tests") {
xcoreBuild()
} // dir
} // steps
} // Build examples
stage('Cleanup xtagctl'){
steps {
dir('xscope_fileio') {
withVenv {
withTools(params.TOOLS_VERSION) {
sh 'rm -f ~/.xtag/status.lock ~/.xtag/acquired'
sh 'xtagctl reset_all XCORE-AI-EXPLORER'
}
}
}
}
}
stage('Tests') {
steps {
dir('xscope_fileio/tests') {
withVenv {
withTools(params.TOOLS_VERSION) {
sh 'pytest' // info: configuration opts in pytest.ini
} // withTools
} // withVenv
} // dir
} // steps
} // Tests
} // stages
post {
always {
junit '**/reports/*.xml'
}
cleanup {
xcoreCleanSandbox()
}
}
} // stage: xcore.ai
stage('Build and Test Wheels') {
parallel {
stage('Windows wheel build') {
agent {label 'x86_64&&windows'}
steps {withVS("vcvars64.bat") {buildandTestPyWheel()}}
post {cleanup {xcoreCleanSandbox()}}
} // stage: Windows build
stage('Mac_x64 wheel build') {
agent {label 'sw-hw-usba-mac0'}
steps {buildandTestPyWheel(delocate = true)}
post {cleanup {xcoreCleanSandbox()}}
} // stage: Mac_x64 build
stage('Mac_arm64 wheel build') {
agent {label 'arm64&&macos'}
steps {buildandTestPyWheel(delocate = true)}
post {cleanup {xcoreCleanSandbox()}}
} // stage: Mac_arm64 build
stage('Linux_x64 wheel build') {
agent {label 'x86_64 && linux'}
steps {buildandTestPyWheel()}
post {cleanup {xcoreCleanSandbox()}}
} // stage: Linux_x64 build
} // parallel
} // stage: Build and Test Wheels
stage('Docs') {
agent {
label 'documentation'
}
steps {
runningOn(env.NODE_NAME)
checkout scm
createVenv("requirements.txt")
withVenv {
withTools(params.TOOLS_VERSION) {
buildDocs xmosdocVenvPath: "${WORKSPACE}", archiveZipOnly: true // needs python run
versionChecks checkReleased: false, versionsPairs: versionsPairs
} // withTools
} // withVenv
} // steps
post {
cleanup {
cleanWs()
}
}
} // stage: Docs
} // stages
} // pipeline