Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dockerfile update detection #2130

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkins/Dockerfile.torch-cpu
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# Docker image file to build and test AIMET for PyTorch in a CPU environment

ARG REGISTRY
FROM ${REGISTRY}ubuntu:bionic as target
FROM ${REGISTRY}ubuntu:bionic

ARG DEBIAN_FRONTEND=noninteractive

Expand Down
46 changes: 33 additions & 13 deletions Jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pipeline {
agent { label "${params.BUILD_LABEL_CPU}" }
options {
timestamps()
timeout( time: 3, unit: 'HOURS' )
timeout( time: "${params.BUILD_TIMEOUT}", unit: 'HOURS' )
}
environment{
def workspace = pwd()
Expand Down Expand Up @@ -67,16 +67,21 @@ pipeline {
echo 'Running commit checks...'
script{
env.REPO_OR_FORK_URL = "${REPO_URL}"
using_linaro=env.USE_LINARO
if (env.CHANGE_FORK != null) {
env.REPO_OR_FORK_URL = "https://github.com/${env.CHANGE_FORK}/aimet"
}
sh "bash -l -c \"git clone ${env.REPO_OR_FORK_URL} -b ${env.CHANGE_BRANCH} commit_checks_repo\""
if (didDockerFileChange("tf-gpu")) {
// setting USE LINARO value to EMPTY to rebuild docker image
using_linaro=""
}
if ("${env.QCInternalValidation}" == "true") {
withCredentials([usernameColonPassword(credentialsId: 'neoci-pat', variable: 'USERPASS')]) {
sh "AIMET_VARIANT=\"tf-gpu\" bash -l -c \"cd ${REPO_NAME} && ${env.DEPENDENCY_DATA_PATH}/commit_check/commit-checks.sh -e AIMET_VARIANT ${env.USE_LINARO} ${env.PREBUILT_DOCKER_IMAGE_URL}\""
sh "AIMET_VARIANT=\"tf-gpu\" bash -l -c \"cd ${REPO_NAME} && ${env.DEPENDENCY_DATA_PATH}/commit_check/commit-checks.sh -e AIMET_VARIANT ${using_linaro} ${env.PREBUILT_DOCKER_IMAGE_URL}\""
}
} else {
sh "AIMET_VARIANT=\"tf-gpu\" bash -l -c \"cd ${REPO_NAME} && ${env.DEPENDENCY_DATA_PATH}/commit_check/commit-checks.sh -e AIMET_VARIANT ${env.USE_LINARO} ${env.PREBUILT_DOCKER_IMAGE_URL}\""
sh "AIMET_VARIANT=\"tf-gpu\" bash -l -c \"cd ${REPO_NAME} && ${env.DEPENDENCY_DATA_PATH}/commit_check/commit-checks.sh -e AIMET_VARIANT ${using_linaro} ${env.PREBUILT_DOCKER_IMAGE_URL}\""
}
}
sh "bash -l -c \"rm -rf commit_checks_repo\""
Expand Down Expand Up @@ -611,38 +616,53 @@ pipeline {
}
}

def didDockerFileChange(aimet_variant) {
def changedFiles = pullRequest.files.collect {
it.getFilename()
}
echo "Changed files - ${changedFiles}"
if (changedFiles.contains("Jenkins/Dockerfile.${aimet_variant}".toString())) {
echo "*** Jenkins/Dockerfile.${aimet_variant} changed in PR, so building docker image locally. ***"
return true
}
echo "*** Jenkins/Dockerfile.${aimet_variant} NOT changed in PR, so using pre-built docker image. ***"
return false
}

def runStage(aimet_variant, options) {

echo "*** Running stage ${options} for ${aimet_variant} variant on ${env.NODE_NAME} in workspace ${env.WORKSPACE_ROOT} ***"

using_linaro=env.USE_LINARO
if (aimet_variant == "default") {
sh """
bash -l -c "cd ${REPO_NAME} && ./buildntest.sh ${options}"
"""

}
else {
def changedFiles = pullRequest.files.collect {
it.getFilename()
}
print changedFiles
if (!changedFiles.contains("Jenkins/Dockerfile.${aimet_variant}".toString())) {
print "Jenkins/Dockerfile.${aimet_variant} not found in changed file list, so using Linaro Docker image for ${aimet_variant}"
if (didDockerFileChange(aimet_variant)) {
// setting USE LINARO value to EMPTY to rebuild docker image
using_linaro=""
}
sh """
AIMET_VARIANT=${aimet_variant} bash -l -c "cd ${REPO_NAME} && ./buildntest.sh -e AIMET_VARIANT ${options} ${env.USE_LINARO} ${env.PREBUILT_DOCKER_IMAGE_URL}"
AIMET_VARIANT=${aimet_variant} bash -l -c "cd ${REPO_NAME} && ./buildntest.sh -e AIMET_VARIANT ${options} ${using_linaro} ${env.PREBUILT_DOCKER_IMAGE_URL}"
"""
}
}

def callAimetExtra(target_branch) {
echo target_branch
using_linaro=env.USE_LINARO
if (didDockerFileChange("tf-gpu") || didDockerFileChange("tf-cpu") || didDockerFileChange("torch-gpu") || didDockerFileChange("torch-cpu")) {
// setting USE LINARO value to EMPTY to rebuild docker image
using_linaro=""
}
if (target_branch != "develop") {
echo "Running AIMET additional stages on ${CHANGE_TARGET} branch ..."
build job: "AIMET-Extra", parameters: [string(name: 'AIMET_GIT_COMMIT', value: "${CHANGE_BRANCH}"), string(name: 'PROJECT_BRANCH', value: target_branch)]
build job: "AIMET-Extra", parameters: [string(name: 'AIMET_GIT_COMMIT', value: "${CHANGE_BRANCH}"), string(name: 'PROJECT_BRANCH', value: target_branch), string(name: 'USE_LINARO', value: "${using_linaro}")]
} else {
echo "Running AIMET additional stages on develop branch ..."
build job: "AIMET-Extra", parameters: [string(name: 'AIMET_GIT_COMMIT', value: "${CHANGE_BRANCH}")]
build job: "AIMET-Extra", parameters: [string(name: 'AIMET_GIT_COMMIT', value: "${CHANGE_BRANCH}"), string(name: 'USE_LINARO', value: "${using_linaro}")]
}
}