Skip to content

Commit de05a61

Browse files
committed
rebase
1 parent f700e72 commit de05a61

File tree

3 files changed

+126
-5
lines changed

3 files changed

+126
-5
lines changed

Jenkinsfile

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ 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+
needs_relint = false
90+
rebuild_docker_images = true
8891

8992
def per_exec_ws(folder) {
9093
return "workspace/exec_${env.EXECUTOR_NUMBER}/" + folder
@@ -200,11 +203,21 @@ stage('Sanity Check') {
200203
init_git()
201204
is_docs_only_build = sh (
202205
returnStatus: true,
203-
script: './tests/scripts/git_change_docs.sh',
206+
script: './tests/scripts/git_change_files.sh docs/',
204207
label: 'Check for docs only changes',
205208
)
206209
skip_ci = should_skip_ci(env.CHANGE_ID)
207210
skip_slow_tests = should_skip_slow_tests(env.CHANGE_ID)
211+
rebuild_docker_images = sh (
212+
returnStatus: true,
213+
script: './tests/scripts/git_change_files.sh docker/',
214+
label: 'Check for docs only changes',
215+
)
216+
if (rebuild_docker_images) {
217+
// Exit before linting so we can use the newly created Docker images
218+
// to run the lint
219+
return
220+
}
208221
sh (
209222
script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh",
210223
label: 'Run lint',
@@ -214,6 +227,100 @@ stage('Sanity Check') {
214227
}
215228
}
216229

230+
def build_image(image_name) {
231+
hash = sh(
232+
returnStdout: true,
233+
script: 'git log -1 --format=\'%h\''
234+
).trim()
235+
hash = "${env.BRANCH_NAME}-${hash}"
236+
sh(
237+
script: "${docker_build} ${image_name} --spec ${image_name}:${hash}",
238+
label: 'Building docker image'
239+
)
240+
sh "echo NYI: Uploading docker image to registry..."
241+
}
242+
243+
if (rebuild_docker_images) {
244+
stage('Docker') {
245+
// TODO in a follow up PR: Upload to ECR, find tag and use in
246+
// subsequent builds
247+
parallel 'ci-lint': {
248+
node('CPU') {
249+
timeout(time: max_time, unit: 'MINUTES') {
250+
init_git()
251+
build_image('ci_lint')
252+
}
253+
}
254+
}, 'ci-cpu': {
255+
node('CPU') {
256+
timeout(time: max_time, unit: 'MINUTES') {
257+
init_git()
258+
build_image('ci_cpu')
259+
}
260+
}
261+
}, 'ci-gpu': {
262+
node('GPU') {
263+
timeout(time: max_time, unit: 'MINUTES') {
264+
init_git()
265+
build_image('ci_gpu')
266+
}
267+
}
268+
}, 'ci-qemu': {
269+
node('CPU') {
270+
timeout(time: max_time, unit: 'MINUTES') {
271+
init_git()
272+
build_image('ci_qemu')
273+
}
274+
}
275+
}, 'ci-i386': {
276+
node('CPU') {
277+
timeout(time: max_time, unit: 'MINUTES') {
278+
init_git()
279+
build_image('ci_i386')
280+
}
281+
}
282+
}, 'ci-arm': {
283+
node('ARM') {
284+
timeout(time: max_time, unit: 'MINUTES') {
285+
init_git()
286+
build_image('ci_arm')
287+
}
288+
}
289+
}, 'ci-wasm': {
290+
node('CPU') {
291+
timeout(time: max_time, unit: 'MINUTES') {
292+
init_git()
293+
build_image('ci_wasm')
294+
}
295+
}
296+
}, 'ci-hexagon': {
297+
node('CPU') {
298+
timeout(time: max_time, unit: 'MINUTES') {
299+
init_git()
300+
build_image('ci_hexagon')
301+
}
302+
}
303+
}
304+
}
305+
// // TODO: Once we are able to use the built images, enable this step
306+
// // If the docker images changed, we need to run the image build before the lint
307+
// // can run since it requires a base docker image. Most of the time the images
308+
// // aren't build though so it's faster to use the same node that checks for
309+
// // docker changes to run the lint in the usual case.
310+
// stage('Sanity Check (re-run)') {
311+
// timeout(time: max_time, unit: 'MINUTES') {
312+
// node('CPU') {
313+
// ws(per_exec_ws('tvm/sanity')) {
314+
// init_git()
315+
// sh (
316+
// script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh",
317+
// label: 'Run lint',
318+
// )
319+
// }
320+
// }
321+
// }
322+
// }
323+
}
217324

218325
// Run make. First try to do an incremental make from a previous workspace in hope to
219326
// 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)