diff options
author | Matt Rendina <mrendina@stsci.edu> | 2019-02-14 16:17:55 -0500 |
---|---|---|
committer | Matt Rendina <mrendina@stsci.edu> | 2019-02-14 16:17:55 -0500 |
commit | 795a55083a98b0b4a2cd238ae58062dd43eaf962 (patch) | |
tree | ae98a17aa7e345841c68418bf0045350eabe09f0 /deliver.groovy | |
parent | 7d9d15de3935e853034367df3012ecaf14a77d0f (diff) | |
download | delivery_control-795a55083a98b0b4a2cd238ae58062dd43eaf962.tar.gz |
Skip projects that don't have a JenkinsfileRT
Diffstat (limited to 'deliver.groovy')
-rw-r--r-- | deliver.groovy | 219 |
1 files changed, 113 insertions, 106 deletions
diff --git a/deliver.groovy b/deliver.groovy index 5d78e88..8ef0687 100644 --- a/deliver.groovy +++ b/deliver.groovy @@ -110,115 +110,122 @@ def gen_specfiles(label, run_tests) { jenkinsfile = "${WORKDIR}/${pkg_name}/JenkinsfileRT" //} - // Post-process each -dev project's JenkinsfileRT to allow - // importing of only the configuration values without running - // the processing machinery called within which would complicate - // matters here. - // Disable scm_checkout call in project's JenkinsfileRT. - // NOTE: 'if' statement must be on same line as scm_checkout call. - // TODO: Generalize to make this more robust against layout - // changes in file. - sh "sed -i 's/^\\s*if/\\/\\/if/' ${jenkinsfile}" - // Disable utils.run line in projects's JenkinsfileRT. - sh "sed -i 's/^\\s*utils.run/\\/\\/utils.run/' ${jenkinsfile}" - - println("About lo load local modified JenkinsfileRT") - sh "ls -al" - // Add declarations from file to this namespace. Provides 'bc'. - // TODO: Iterate through namespace to locate buildConfig - // objects without a standard name? - // NOTE: 'evaluate' runs the methods it encounters. - // Edit to disable to prevent undesired side effects. - jf = evaluate readFile(jenkinsfile) - - def conda_prefix = "${conda_root}/envs/${env_name}".trim() - - def path_found = false - for (var in bc.env_vars) { - println("--> ${var}") - if (var[0..3] == 'PATH') { - path_found = true - pathvar_idx = bc.env_vars.indexOf(var) - bc.env_vars.remove(pathvar_idx) - println(" --- ADJUSTING PATH FOR CONDA ENV ----") - var = "PATH=${conda_prefix}/bin:${WORKDIR}/miniconda/bin:${var[5..-1]}" + + // Only run tests if JenkinsfileRT exists for project. + if (fileExists(jenkinsfile)) { + + // Post-process each -dev project's JenkinsfileRT to allow + // importing of only the configuration values without running + // the processing machinery called within which would complicate + // matters here. + // Disable scm_checkout call in project's JenkinsfileRT. + // NOTE: 'if' statement must be on same line as scm_checkout call. + // TODO: Generalize to make this more robust against layout + // changes in file. + sh "sed -i 's/^\\s*if/\\/\\/if/' ${jenkinsfile}" + // Disable utils.run line in projects's JenkinsfileRT. + sh "sed -i 's/^\\s*utils.run/\\/\\/utils.run/' ${jenkinsfile}" + + println("About lo load local modified JenkinsfileRT") + sh "ls -al" + // Add declarations from file to this namespace. Provides 'bc'. + // TODO: Iterate through namespace to locate buildConfig + // objects without a standard name? + // NOTE: 'evaluate' runs the methods it encounters. + // Edit to disable to prevent undesired side effects. + jf = evaluate readFile(jenkinsfile) + + def conda_prefix = "${conda_root}/envs/${env_name}".trim() + + def path_found = false + for (var in bc.env_vars) { + println("--> ${var}") + if (var[0..3] == 'PATH') { + path_found = true + pathvar_idx = bc.env_vars.indexOf(var) + bc.env_vars.remove(pathvar_idx) + println(" --- ADJUSTING PATH FOR CONDA ENV ----") + var = "PATH=${conda_prefix}/bin:${WORKDIR}/miniconda/bin:${var[5..-1]}" + println(var) + bc.env_vars.add(var) + } + } + if (!path_found) { + println("--- Adding PATH prefix for conda environment and conda exe.") + bc.env_vars.add("PATH=${conda_prefix}/bin:${WORKDIR}/miniconda/bin:\$PATH") + } + bc.env_vars.add("ENVIRONMENT=VARIABLE-${pkg}") + + def bconfig = utils.expandEnvVars(bc) // expand vars into .runtime + + def env_vars = bconfig.runtime + // 'Activate' conda env and operate within it. + env_vars.add(0, "CONDA_SHLVL=1") + env_vars.add(0, "CONDA_PROMPT_MODIFIER=${env_name}") + env_vars.add(0, "CONDA_EXE=${conda_exe}") + env_vars.add(0, "CONDA_PREFIX=${conda_prefix}") + env_vars.add(0, "CONDA_PYTHON_EXE=${conda_prefix}/bin/python") + env_vars.add(0, "CONDA_DEFAULT_ENV=${env_name}") + + println('FINAL ENV VARS') + for (var in env_vars) { println(var) - bc.env_vars.add(var) } - } - if (!path_found) { - println("--- Adding PATH prefix for conda environment and conda exe.") - bc.env_vars.add("PATH=${conda_prefix}/bin:${WORKDIR}/miniconda/bin:\$PATH") - } - bc.env_vars.add("ENVIRONMENT=VARIABLE-${pkg}") - - def bconfig = utils.expandEnvVars(bc) // expand vars into .runtime - - def env_vars = bconfig.runtime - // 'Activate' conda env and operate within it. - env_vars.add(0, "CONDA_SHLVL=1") - env_vars.add(0, "CONDA_PROMPT_MODIFIER=${env_name}") - env_vars.add(0, "CONDA_EXE=${conda_exe}") - env_vars.add(0, "CONDA_PREFIX=${conda_prefix}") - env_vars.add(0, "CONDA_PYTHON_EXE=${conda_prefix}/bin/python") - env_vars.add(0, "CONDA_DEFAULT_ENV=${env_name}") - - println('FINAL ENV VARS') - for (var in env_vars) { - println(var) - } - - // Run testing commands - withEnv(env_vars) { - println("============= withEnv ==========") - sh "env | sort" - // Obtain pip for build/install use - sh "conda install pip" - dir(pkg_name) { - sh "ls -l" - def conda_pkgs = "" - for (cpkg in bc.conda_packages) { - conda_pkgs = "${conda_pkgs} ${cpkg} " - } - sh "conda install ${conda_pkgs} pytest -c http://ssb.stsci.edu/astroconda -c defaults -q -y" - - // If setup.py exists in project, run `python setup.py build` to prepare - // local source tree for testing. This is required for projects with C - // extensions. - if (fileExists("setup.py")) { - sh(script: "pip install --no-deps -e .") - } - println("Test commands(s):") - println(bc.test_cmds) - for (tcmd in bc.test_cmds) { - sh(script: "${tcmd} || true") - } - // Uninstall packages pulled in for this test run. - sh "conda remove ${conda_pkgs} --force -y" - - // Read in test reports for display. - // TODO: Use shared lib for this functionality. - // Process the results file to include the build config name as a prefix - // on each test name so that it is obvious from where each test result - // comes. - report_exists = sh(script: "test -e *.xml", returnStatus: true) - if (report_exists == 0) { - repfile = sh(script:"find *.xml", returnStdout: true).trim() - command = "cp ${repfile} ${repfile}.modified" - sh(script:command) - sh(script:"sed -i 's/ name=\"/ name=\"[${pkg_name}:${bc.name}] /g' *.xml.modified") - step([$class: 'XUnitBuilder', - thresholds: [ - [$class: 'SkippedThreshold', unstableThreshold: "${bc.skippedUnstableThresh}"], - [$class: 'SkippedThreshold', failureThreshold: "${bc.skippedFailureThresh}"], - [$class: 'FailedThreshold', unstableThreshold: "${bc.failedUnstableThresh}"], - [$class: 'FailedThreshold', failureThreshold: "${bc.failedFailureThresh}"]], - tools: [[$class: 'JUnitType', pattern: '*.xml.modified']]]) - } else { - println("No .xml files found in directory ${pkg_name}. Test report ingestion skipped.") - } + + // Run testing commands + withEnv(env_vars) { + println("============= withEnv ==========") + sh "env | sort" + // Obtain pip for build/install use + sh "conda install pip" + dir(pkg_name) { + sh "ls -l" + def conda_pkgs = "" + for (cpkg in bc.conda_packages) { + conda_pkgs = "${conda_pkgs} ${cpkg} " + } + sh "conda install ${conda_pkgs} pytest -c http://ssb.stsci.edu/astroconda -c defaults -q -y" + + // If setup.py exists in project, run `python setup.py build` to prepare + // local source tree for testing. This is required for projects with C + // extensions. + if (fileExists("setup.py")) { + sh(script: "pip install --no-deps -e .") + } + println("Test commands(s):") + println(bc.test_cmds) + for (tcmd in bc.test_cmds) { + sh(script: "${tcmd} || true") + } + // Uninstall packages pulled in for this test run. + sh "conda remove ${conda_pkgs} --force -y" + + // Read in test reports for display. + // TODO: Use shared lib for this functionality. + // Process the results file to include the build config name as a prefix + // on each test name so that it is obvious from where each test result + // comes. + report_exists = sh(script: "test -e *.xml", returnStatus: true) + if (report_exists == 0) { + repfile = sh(script:"find *.xml", returnStdout: true).trim() + command = "cp ${repfile} ${repfile}.modified" + sh(script:command) + sh(script:"sed -i 's/ name=\"/ name=\"[${pkg_name}:${bc.name}] /g' *.xml.modified") + step([$class: 'XUnitBuilder', + thresholds: [ + [$class: 'SkippedThreshold', unstableThreshold: "${bc.skippedUnstableThresh}"], + [$class: 'SkippedThreshold', failureThreshold: "${bc.skippedFailureThresh}"], + [$class: 'FailedThreshold', unstableThreshold: "${bc.failedUnstableThresh}"], + [$class: 'FailedThreshold', failureThreshold: "${bc.failedFailureThresh}"]], + tools: [[$class: 'JUnitType', pattern: '*.xml.modified']]]) + } else { + println("No .xml files found in directory ${pkg_name}. Test report ingestion skipped.") + } + } } - } + } else { + println('JenkinsfileRT not found for ${pkg_name}, skipping test run.") + } //end if(fileExists(jenkinsfile)) } // endfor pkg } |