Skip to content

Commit 5423f33

Browse files
committed
rebase
1 parent f700e72 commit 5423f33

File tree

3 files changed

+129
-5
lines changed

3 files changed

+129
-5
lines changed

Jenkinsfile

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ tvm_multilib_tsim = 'build/libvta_tsim.so, ' +
8383

8484
// command to start a docker container
8585
docker_run = 'docker/bash.sh'
86+
docker_build = 'docker/build.sh'
8687
// timeout in minutes
8788
max_time = 240
89+
rebuild_docker_images = false
8890

8991
def 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

docker/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
# [--dockerfile <DOCKERFILE_PATH>] [-it]
2525
# [--net=host] [--cache-from <IMAGE_NAME>]
2626
# [--name CONTAINER_NAME] [--context-path <CONTEXT_PATH>]
27+
# [--spec DOCKER_IMAGE_SPEC]
2728
# [<COMMAND>]
2829
#
2930
# CONTAINER_TYPE: Type of the docker container used the run the build,
@@ -36,6 +37,9 @@
3637
# this optional value is not supplied (via the --dockerfile
3738
# flag), will use Dockerfile.CONTAINER_TYPE in default
3839
#
40+
# DOCKER_IMAGE_SPEC: Override the default logic to determine the image name and
41+
# tag
42+
#
3943
# IMAGE_NAME: An image to be as a source for cached layers when building the
4044
# Docker image requested.
4145
#
@@ -73,6 +77,11 @@ if [[ "$1" == "-it" ]]; then
7377
shift 1
7478
fi
7579

80+
if [[ "$1" == "--spec" ]]; then
81+
OVERRIDE_IMAGE_SPEC="$2"
82+
shift 2
83+
fi
84+
7685
if [[ "$1" == "--net=host" ]]; then
7786
CI_DOCKER_EXTRA_PARAMS+=('--net=host')
7887
CI_DOCKER_BUILD_EXTRA_PARAMS+=("--network=host")
@@ -162,6 +171,10 @@ DOCKER_IMG_NAME=$(echo "${DOCKER_IMG_NAME}" | tr '[:upper:]' '[:lower:]')
162171
# Compose the full image spec with "name:tag" e.g. "tvm.ci_cpu:v0.03"
163172
DOCKER_IMG_SPEC="${DOCKER_IMG_NAME}:${DOCKER_IMAGE_TAG}"
164173

174+
if [[ -n ${OVERRIDE_IMAGE_SPEC+x} ]]; then
175+
DOCKER_IMG_SPEC="$OVERRIDE_IMAGE_SPEC"
176+
fi
177+
165178
# Print arguments.
166179
echo "WORKSPACE: ${WORKSPACE}"
167180
echo "CI_DOCKER_EXTRA_PARAMS: ${CI_DOCKER_EXTRA_PARAMS[@]}"

tests/scripts/git_change_docs.sh renamed to tests/scripts/git_change_files.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@
2020
set -eux
2121

2222
FOUND_ONE_FILE=0
23-
SAW_NON_DOC_CHANGES=0
23+
SAW_NON_RELEVANT_CHANGES=0
24+
FOLDER_WITH_CHANGES="$1"
2425

2526
changed_files=$(git diff --no-commit-id --name-only -r origin/main)
2627

2728
for file in $changed_files; do
2829
FOUND_ONE_FILE=1
29-
if ! grep -q "docs/" <<< "$file"; then
30-
SAW_NON_DOC_CHANGES=1
30+
if ! grep -q "$FOLDER_WITH_CHANGES" <<< "$file"; then
31+
SAW_NON_RELEVANT_CHANGES=1
3132
break
3233
fi
3334
done
3435

35-
if [ ${FOUND_ONE_FILE} -eq 0 ] || [ ${SAW_NON_DOC_CHANGES} -eq 1 ]; then
36+
if [ ${FOUND_ONE_FILE} -eq 0 ] || [ ${SAW_NON_RELEVANT_CHANGES} -eq 1 ]; then
3637
exit 0
3738
else
3839
exit 1

0 commit comments

Comments
 (0)