@@ -83,8 +83,10 @@ tvm_multilib_tsim = 'build/libvta_tsim.so, ' +
8383
8484// command to start a docker container
8585docker_run = ' docker/bash.sh'
86+ docker_build = ' docker/build.sh'
8687// timeout in minutes
8788max_time = 240
89+ rebuild_docker_images = false
8890
8991def per_exec_ws (folder ) {
9092 return " workspace/exec_${ env.EXECUTOR_NUMBER} /" + folder
@@ -200,11 +202,21 @@ stage('Sanity Check') {
200202 init_git()
201203 is_docs_only_build = sh (
202204 returnStatus : true ,
203- script : ' ./tests/scripts/git_change_docs .sh' ,
205+ script : ' ./tests/scripts/git_change_files .sh docs/ ' ,
204206 label : ' Check for docs only changes' ,
205207 )
206208 skip_ci = should_skip_ci(env. CHANGE_ID )
207209 skip_slow_tests = should_skip_slow_tests(env. CHANGE_ID )
210+ rebuild_docker_images = sh (
211+ returnStatus : true ,
212+ script : ' ./tests/scripts/git_change_files.sh docker/' ,
213+ label : ' Check for docs only changes' ,
214+ )
215+ if (rebuild_docker_images) {
216+ // Exit before linting so we can use the newly created Docker images
217+ // to run the lint
218+ return
219+ }
208220 sh (
209221 script : " ${ docker_run} ${ ci_lint} ./tests/scripts/task_lint.sh" ,
210222 label : ' Run lint' ,
@@ -214,6 +226,104 @@ stage('Sanity Check') {
214226 }
215227}
216228
229+ def build_image (image_name ) {
230+ hash = sh(
231+ returnStdout : true ,
232+ script : ' git log -1 --format=\' %h\' '
233+ ). trim()
234+ hash = " ${ env.BRANCH_NAME} -${ hash} "
235+ sh(
236+ script : " ${ docker_build} ${ image_name} --spec ${ image_name} :${ hash} " ,
237+ label : ' Building docker image'
238+ )
239+ sh(
240+ script : " docker rmi ${ image_name} :${ hash} " ,
241+ label : ' Removing docker image'
242+ )
243+ sh " echo NYI: Uploading docker image to registry..."
244+ }
245+
246+ if (rebuild_docker_images) {
247+ stage(' Docker Image Build' ) {
248+ // TODO in a follow up PR: Upload to ECR, find tag and use in
249+ // subsequent builds
250+ parallel ' ci-lint' : {
251+ node(' CPU' ) {
252+ timeout(time : max_time, unit : ' MINUTES' ) {
253+ init_git()
254+ build_image(' ci_lint' )
255+ }
256+ }
257+ }, ' ci-cpu' : {
258+ node(' CPU' ) {
259+ timeout(time : max_time, unit : ' MINUTES' ) {
260+ init_git()
261+ build_image(' ci_cpu' )
262+ }
263+ }
264+ }, ' ci-gpu' : {
265+ node(' GPU' ) {
266+ timeout(time : max_time, unit : ' MINUTES' ) {
267+ init_git()
268+ build_image(' ci_gpu' )
269+ }
270+ }
271+ }, ' ci-qemu' : {
272+ node(' CPU' ) {
273+ timeout(time : max_time, unit : ' MINUTES' ) {
274+ init_git()
275+ build_image(' ci_qemu' )
276+ }
277+ }
278+ }, ' ci-i386' : {
279+ node(' CPU' ) {
280+ timeout(time : max_time, unit : ' MINUTES' ) {
281+ init_git()
282+ build_image(' ci_i386' )
283+ }
284+ }
285+ }, ' ci-arm' : {
286+ node(' ARM' ) {
287+ timeout(time : max_time, unit : ' MINUTES' ) {
288+ init_git()
289+ build_image(' ci_arm' )
290+ }
291+ }
292+ }, ' ci-wasm' : {
293+ node(' CPU' ) {
294+ timeout(time : max_time, unit : ' MINUTES' ) {
295+ init_git()
296+ build_image(' ci_wasm' )
297+ }
298+ }
299+ }, ' ci-hexagon' : {
300+ node(' CPU' ) {
301+ timeout(time : max_time, unit : ' MINUTES' ) {
302+ init_git()
303+ build_image(' ci_hexagon' )
304+ }
305+ }
306+ }
307+ }
308+ // // TODO: Once we are able to use the built images, enable this step
309+ // // If the docker images changed, we need to run the image build before the lint
310+ // // can run since it requires a base docker image. Most of the time the images
311+ // // aren't build though so it's faster to use the same node that checks for
312+ // // docker changes to run the lint in the usual case.
313+ // stage('Sanity Check (re-run)') {
314+ // timeout(time: max_time, unit: 'MINUTES') {
315+ // node('CPU') {
316+ // ws(per_exec_ws('tvm/sanity')) {
317+ // init_git()
318+ // sh (
319+ // script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh",
320+ // label: 'Run lint',
321+ // )
322+ // }
323+ // }
324+ // }
325+ // }
326+ }
217327
218328// Run make. First try to do an incremental make from a previous workspace in hope to
219329// accelerate the compilation. If something is wrong, clean the workspace and then
0 commit comments