Skip to content

Commit 36b74ab

Browse files
yangel2017GitHub Enterprise
authored and
GitHub Enterprise
committed
Deploy test packge for USD Internal Fork. (PixarAnimationStudios#648)
* Deploy test packge for USD Internal Fork. * Update according to comments. * Update comments. * Fix typo.
1 parent 335ad2a commit 36b74ab

File tree

2 files changed

+92
-30
lines changed

2 files changed

+92
-30
lines changed

Jenkinsfile

+57-27
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ finally {
436436
buildConfigs << "${build.key}_versioning"
437437
buildConfigs << "${build.key}_garasign"
438438
}
439-
if ("${build.key}".contains('mac')) {
439+
if ("${build.key}".contains('mac') || "${build.key}".contains('windows_x64')) {
440440
buildConfigs << "${build.key}_deploytest"
441441
}
442442
buildConfigs << "${build.key}_deployment"
@@ -633,6 +633,19 @@ def buildStage(buildInfo, runBuild) {
633633
}
634634
}
635635

636+
def testPackageOnServer(buildInfo){
637+
def commit = "${env.GIT_COMMIT}"[0..6]
638+
def remotePath = "${ARTIFACTORY_URL}/${ARTIFACTORY_FOLDER}/${ARTIFACTORY_TEST_FOLDER}/usd_${buildInfo.Platform}_${commit}.zip"
639+
def status_code = '404'
640+
if ("${buildInfo.Platform}".contains("windows")){
641+
status_code = COMMONSHELL.capture_script_output("""curl -o NUL --silent -Iw "%%{http_code}" ${remotePath}""")
642+
}
643+
else{
644+
status_code = COMMONSHELL.capture_script_output("""curl -o /dev/null --silent -Iw '%{http_code}' ${remotePath}""")
645+
}
646+
return status_code == '200'
647+
}
648+
636649
def windowsBuild(buildInfo) {
637650
// Clean up TBB src to force a clean build as TBB generates binaries on its source path
638651
// Clean up textsystem as it has the same folder name on all platforms but with different binaries
@@ -662,6 +675,13 @@ def windowsBuild(buildInfo) {
662675
"""
663676
}
664677
else{
678+
if (!(isDevBranch() || isReleaseBranch()) && testPackageOnServer(buildInfo)) {
679+
// Check if test package is already deployed
680+
postStatus('SUCCESS', "${buildInfo.Platform}_deploytest")
681+
echo "Package is on server and skip build."
682+
return
683+
}
684+
665685
bat """
666686
:: Set up nasm for OIIO plugin
667687
if not exist ${buildInfo.USDgen_src}\\nasm-2.15.05-win64.zip call curl -o ${buildInfo.USDgen_src}\\nasm-2.15.05-win64.zip https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-win64.zip
@@ -680,16 +700,14 @@ def windowsBuild(buildInfo) {
680700
call ${buildInfo.Python} -m pip install PyOpenGL
681701
call ${buildInfo.Python} -u build_scripts/build_usd.py --generator Ninja --build ${buildInfo.USDgen_build} --src ${buildInfo.USDgen_src} ${buildInfo.USDinst} --build-variant ${buildInfo.BuildVariant} ${USDBUILDINGFLAGS} -v
682702
"""
703+
testDeployStage(buildInfo)
683704
}
684705
}
685706

686707
def macBuild(buildInfo) {
687-
if ((!isDevBranch()) && (!"${buildInfo.Platform}".contains("ios"))) {
708+
if (!(isDevBranch() || isReleaseBranch()) && (!"${buildInfo.Platform}".contains("ios"))) {
688709
// Check if the package is already deployed
689-
def commit = "${env.GIT_COMMIT}"[0..6]
690-
def remotePath = "${ARTIFACTORY_URL}/${ARTIFACTORY_FOLDER}/${ARTIFACTORY_TEST_FOLDER}/usd_${buildInfo.Platform}_${commit}.zip"
691-
def status_code = COMMONSHELL.capture_script_output("""curl -o /dev/null --silent -Iw '%{http_code}' ${remotePath}""")
692-
if (status_code == '200') {
710+
if (testPackageOnServer(buildInfo)) {
693711
postStatus('SUCCESS', "${buildInfo.Platform}_deploytest")
694712
return
695713
}
@@ -791,6 +809,26 @@ def testStage(buildInfo, runTest) {
791809
}
792810
}
793811

812+
def downloadTestPackage(buildInfo){
813+
def commit = "${env.GIT_COMMIT}"[0..6]
814+
def usdinst="${env.WORKSPACE}/usd_${buildInfo.Platform}_${commit}"
815+
def artifactory_env_path = "${ARTIFACTORY_TEST_FOLDER}"
816+
def server = "${ARTIFACTORY_URL}"
817+
def remotePath = "${ARTIFACTORY_FOLDER}/${artifactory_env_path}"
818+
withEnv(["OGS_ARTIFACTORY_SERVER=art-bobcat"]){
819+
COMMONSHELL.shell """\
820+
${buildInfo.Python} -u adsk-build-scripts/deploy.py --download_test \
821+
--git_commit ${commit} \
822+
--remotepath ${remotePath} \
823+
--platform ${buildInfo.Platform} \
824+
--packagename ${PROJECT_NAME} \
825+
--server ${server} \
826+
--source ${env.WORKSPACE}
827+
"""
828+
}
829+
return usdinst
830+
}
831+
794832
def windowsTest(buildInfo) {
795833
// Skip test on windows_android as no tests are generated currently
796834
// TODO: Run unittest on windows_android
@@ -803,13 +841,19 @@ def windowsTest(buildInfo) {
803841
rd %temp% /s /q
804842
"""
805843

844+
def usdinst = "${buildInfo.USDinst}"
845+
def testpath = "${buildInfo.USDgen_build_usd}"
846+
if (!(isDevBranch() || isReleaseBranch()) && testPackageOnServer(buildInfo)) {
847+
usdinst = downloadTestPackage(buildInfo)
848+
testpath = usdinst
849+
}
850+
806851
bat """
807-
:: As part of relocatable support, user needs EnvVar("PXR_MTLX_STDLIB_SEARCH_PATHS") to use MaterialX libraies from USD installed path,
808-
:: but it's necessay on the build machine as USD also adds path to the MaterialX standard library discovered at build time.
809-
:: call set PXR_MTLX_STDLIB_SEARCH_PATHS=<Full_Of_USDinst_Extracted_Path>/libraries
810-
call set PATH=%PATH%;${buildInfo.USDinst}\\lib;${buildInfo.USDinst}\\bin;${buildInfo.USDinst}\\share\\usd\\examples\\plugin;
811-
call set PYTHONPATH=${buildInfo.USDinst}\\lib\\python
812-
call cd /d ${buildInfo.USDgen_build_usd} && ctest -C ${buildInfo.CMakeConfig} ${USDTESTINGFLAGS}
852+
:: As part of relocatable support, user needs EnvVar("PXR_MTLX_STDLIB_SEARCH_PATHS") to use MaterialX libraies from USD installed path.
853+
call set PXR_MTLX_STDLIB_SEARCH_PATHS=${usdinst}\\libraries;
854+
call set PATH=%PATH%;${usdinst}\\lib;${usdinst}\\bin;${usdinst}\\share\\usd\\examples\\plugin;
855+
call set PYTHONPATH=${usdinst}\\lib\\python
856+
call cd /d ${testpath} && ctest -C ${buildInfo.CMakeConfig} ${USDTESTINGFLAGS}
813857
"""
814858
}
815859
}
@@ -894,22 +938,8 @@ def runMacTest(buildInfo, runlocally) {
894938
// Set up testing environment on the newly allocated node
895939
if (!runlocally) {
896940
checkoutGit()
897-
898-
def commit = "${env.GIT_COMMIT}"[0..6]
899-
usdinst="${env.WORKSPACE}/usd_${buildInfo.Platform}_${commit}"
900-
def artifactory_env_path = "${ARTIFACTORY_TEST_FOLDER}"
901-
def server = "${ARTIFACTORY_URL}"
902-
def remotePath = "${ARTIFACTORY_FOLDER}/${artifactory_env_path}"
941+
usdinst = downloadTestPackage(buildInfo)
903942
sh """
904-
export OGS_ARTIFACTORY_SERVER=art-bobcat
905-
python3 -u adsk-build-scripts/deploy.py --download_test \
906-
--git_commit ${commit} \
907-
--remotepath ${remotePath} \
908-
--platform ${buildInfo.Platform} \
909-
--packagename ${PROJECT_NAME} \
910-
--server ${server} \
911-
--source ${env.WORKSPACE}
912-
913943
install_name_tool -add_rpath ${usdinst}/lib ${usdinst}/bin/idiff
914944
"""
915945
testpath = "${usdinst}"

adsk-build-scripts/deploy.py

+35-3
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,28 @@ def downloadPackageThreaded(url, archivePath):
544544
if not successful_download and os.path.isfile(archivePath):
545545
os.remove(archivePath)
546546

547+
def winapi_path(dos_path, encoding=None):
548+
if (not isinstance(dos_path, str) and encoding is not None):
549+
dos_path = dos_path.decode(encoding)
550+
path = os.path.abspath(dos_path)
551+
if path.startswith(u"\\\\"):
552+
return u"\\\\?\\UNC\\" + path[2:]
553+
return u"\\\\?\\" + path
554+
555+
# Custom zipfile.ZipFile to handle long path in Windows and permissions reservation.
556+
class CustomZipFile(zipfile.ZipFile):
557+
def _extract_member(self, member, targetpath, pwd):
558+
if not isinstance(member, zipfile.ZipInfo):
559+
member = self.getinfo(member)
560+
if platform.system() == 'Windows':
561+
targetpath = winapi_path(targetpath)
562+
targetpath = super()._extract_member(member, targetpath, pwd)
563+
564+
attr = member.external_attr >> 16
565+
if attr != 0:
566+
os.chmod(targetpath, attr)
567+
return targetpath
568+
547569
def download_test(cargs):
548570
# Get the closet Artifactory server to gain fastest download speed
549571
server = os.getenv('OGS_ARTIFACTORY_SERVER', None)
@@ -572,7 +594,8 @@ def download_test(cargs):
572594

573595
start = time.time()
574596
try:
575-
subprocess.run(['unzip', '-q', zipfile_name, '-d', extract_to])
597+
with CustomZipFile(zipfile_name, 'r') as zip_ref:
598+
zip_ref.extractall(extract_to)
576599
duration = time.time() - start
577600
print('Used {dur} secs to extract {file}'.format(dur=str(duration), file=zip_name))
578601
except BaseException as e:
@@ -587,14 +610,19 @@ def download_test(cargs):
587610

588611
# Replace the relative paths for CTestTestfile.cmake
589612
contents = ''
613+
extract_to_slash = extract_to.replace('\\','/')
614+
usd_git_slash = usd_git.replace('\\','/')
590615
with open(os.path.join(extract_to, 'CTestTestfile.cmake.all'), 'r') as f:
591616
lines = f.read()
592-
contents += lines.replace('<usd_build>', extract_to).replace('<usd_inst>', extract_to).replace('<usd_git>', usd_git)
617+
contents += lines.replace('<usd_build>', extract_to_slash).replace('<usd_inst>', extract_to_slash).replace('<usd_git>', usd_git_slash)
593618
with open(os.path.join(extract_to, 'CTestTestfile.cmake'), 'w') as f:
594619
f.write(contents)
595620

596621
sys.exit()
597622

623+
def uppercase_first_letter(string):
624+
return string[0].upper() + string[1:]
625+
598626
def zip_test(source_dir, archive, usd_build):
599627
abs_usd_build=os.path.abspath(usd_build)
600628
usd_git = os.path.abspath(os.path.join(SCRIPT_PATH, '..'))
@@ -613,9 +641,13 @@ def zip_test(source_dir, archive, usd_build):
613641
# Consolidate all tests to single CTestTestfile.cmake.all,
614642
# and replace relative paths with defined tags to be replaced in future,
615643
# for it to be able to run from anywhere with local paths replaced
644+
# Uppercase the drive and replace '\' to '/' for path in Windows to be consistent with CTestTestfile.cmake.
645+
abs_usd_build_slash = uppercase_first_letter(abs_usd_build).replace('\\','/') if platform.system() == 'Windows' else abs_usd_build
646+
source_dir_slash = uppercase_first_letter(source_dir).replace('\\','/') if platform.system() == 'Windows' else source_dir
647+
usd_git_slash = uppercase_first_letter(usd_git).replace('\\','/') if platform.system() == 'Windows' else usd_git
616648
ctestfile_all = os.path.join(abs_usd_build, 'CTestTestfile.cmake.all')
617649
with open(ctestfile_all, 'w') as f:
618-
f.write(contents.replace(abs_usd_build, '<usd_build>').replace(source_dir, '<usd_inst>').replace(usd_git, '<usd_git>'))
650+
f.write(contents.replace(abs_usd_build_slash, '<usd_build>').replace(source_dir_slash, '<usd_inst>').replace(usd_git_slash, '<usd_git>'))
619651

620652
# Zip test case file and necessary binaries into archive
621653
ziph = zipfile.ZipFile(archive, 'w', compression=zipfile.ZIP_DEFLATED)

0 commit comments

Comments
 (0)