From c5600cca6fcbaa00f32ef19f693d776b1edeb4e0 Mon Sep 17 00:00:00 2001 From: driazati Date: Wed, 22 Jun 2022 09:58:45 -0700 Subject: [PATCH] [ci][docker] Tag tlcpackstaging images to tlcpack See #11768, this PR changes the deploy workflow so that after a successful build with fallback images (see #11775), they get moved over to tlcpack automatically --- Jenkinsfile | 124 +++++++++++++++++++++++++++++++++++- ci/jenkins/Deploy.groovy.j2 | 33 ++++++++++ 2 files changed, 156 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c2f6407333389..d942bf6f2b737 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ // 'python3 jenkins/generate.py' // Note: This timestamp is here to ensure that updates to the Jenkinsfile are // always rebased on main before merging: -// Generated at 2022-07-15T13:35:24.676914 +// Generated at 2022-07-28T14:08:44.349279 import org.jenkinsci.plugins.pipeline.modeldefinition.Utils // NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. --> @@ -3418,6 +3418,128 @@ def deploy() { } } } + if (env.BRANCH_NAME == 'main' && env.RETAG_STAGING_IMAGES == 'yes') { + withCredentials([string( + credentialsId: 'dockerhub-tlcpack-key', + variable: 'TLCPACK_TOKEN', + )]) { + try { + sh( + script: 'echo $TLCPACK_TOKEN | docker login --username octomldriazati --password-stdin', + label: 'Log in to Docker Hub' + ) + if (ci_arm.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_arm.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_arm:${tag} + docker tag tlcpackstaging/ci_arm:${tag} tlcpack/ci-arm:${tag} + docker push tlcpack/ci-arm:${tag} + """, + label: 'Tag tlcpackstaging/ci_arm image to tlcpack', + ) + } + if (ci_cpu.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_cpu.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_cpu:${tag} + docker tag tlcpackstaging/ci_cpu:${tag} tlcpack/ci-cpu:${tag} + docker push tlcpack/ci-cpu:${tag} + """, + label: 'Tag tlcpackstaging/ci_cpu image to tlcpack', + ) + } + if (ci_gpu.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_gpu.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_gpu:${tag} + docker tag tlcpackstaging/ci_gpu:${tag} tlcpack/ci-gpu:${tag} + docker push tlcpack/ci-gpu:${tag} + """, + label: 'Tag tlcpackstaging/ci_gpu image to tlcpack', + ) + } + if (ci_hexagon.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_hexagon.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_hexagon:${tag} + docker tag tlcpackstaging/ci_hexagon:${tag} tlcpack/ci-hexagon:${tag} + docker push tlcpack/ci-hexagon:${tag} + """, + label: 'Tag tlcpackstaging/ci_hexagon image to tlcpack', + ) + } + if (ci_i386.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_i386.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_i386:${tag} + docker tag tlcpackstaging/ci_i386:${tag} tlcpack/ci-i386:${tag} + docker push tlcpack/ci-i386:${tag} + """, + label: 'Tag tlcpackstaging/ci_i386 image to tlcpack', + ) + } + if (ci_lint.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_lint.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_lint:${tag} + docker tag tlcpackstaging/ci_lint:${tag} tlcpack/ci-lint:${tag} + docker push tlcpack/ci-lint:${tag} + """, + label: 'Tag tlcpackstaging/ci_lint image to tlcpack', + ) + } + if (ci_qemu.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_qemu.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_qemu:${tag} + docker tag tlcpackstaging/ci_qemu:${tag} tlcpack/ci-qemu:${tag} + docker push tlcpack/ci-qemu:${tag} + """, + label: 'Tag tlcpackstaging/ci_qemu image to tlcpack', + ) + } + if (ci_wasm.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_wasm.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/ci_wasm:${tag} + docker tag tlcpackstaging/ci_wasm:${tag} tlcpack/ci-wasm:${tag} + docker push tlcpack/ci-wasm:${tag} + """, + label: 'Tag tlcpackstaging/ci_wasm image to tlcpack', + ) + } + } finally { + sh( + script: 'docker logout', + label: 'Clean up login credentials' + ) + } + } + } if (env.BRANCH_NAME == 'main' && env.DEPLOY_DOCKER_IMAGES == 'yes' && rebuild_docker_images && upstream_revision != null) { node('CPU') { ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/deploy-docker") { diff --git a/ci/jenkins/Deploy.groovy.j2 b/ci/jenkins/Deploy.groovy.j2 index 0249aaffc5123..96e0be68547ef 100644 --- a/ci/jenkins/Deploy.groovy.j2 +++ b/ci/jenkins/Deploy.groovy.j2 @@ -86,6 +86,39 @@ def deploy() { } } } + if (env.BRANCH_NAME == 'main' && env.RETAG_STAGING_IMAGES == 'yes') { + withCredentials([string( + credentialsId: 'dockerhub-tlcpack-key', + variable: 'TLCPACK_TOKEN', + )]) { + try { + sh( + script: 'echo $TLCPACK_TOKEN | docker login --username octomldriazati --password-stdin', + label: 'Log in to Docker Hub' + ) + {% for image in images %} + if ({{ image.name }}.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = {{ image.name }}.split(":")[1] + sh( + script: """ + set -eux + docker pull tlcpackstaging/{{ image.name }}:${tag} + docker tag tlcpackstaging/{{ image.name }}:${tag} tlcpack/{{ image.name.replace("_", "-") }}:${tag} + docker push tlcpack/{{ image.name.replace("_", "-") }}:${tag} + """, + label: 'Tag tlcpackstaging/{{ image.name }} image to tlcpack', + ) + } + {% endfor %} + } finally { + sh( + script: 'docker logout', + label: 'Clean up login credentials' + ) + } + } + } if (env.BRANCH_NAME == 'main' && env.DEPLOY_DOCKER_IMAGES == 'yes' && rebuild_docker_images && upstream_revision != null) { node('CPU') { ws({{ m.per_exec_ws('tvm/deploy-docker') }}) {