diff options
author | Matt Rendina <mrendina@stsci.edu> | 2019-04-15 10:18:59 -0400 |
---|---|---|
committer | Matt Rendina <mrendina@stsci.edu> | 2019-04-15 13:00:15 -0400 |
commit | 01957741c8bb74cec6e72c734ba0b8589efa1f72 (patch) | |
tree | feff8f7acce78abace30aaf1a45f6dafbf716efb | |
parent | d9d2b53ce76d4654f70766acb846c1b3baf5588a (diff) | |
download | jscu_refactor-01957741c8bb74cec6e72c734ba0b8589efa1f72.tar.gz |
Add tests dir; try out inclusion into jenkinsfile
Cleanup jenkinsfile. Add hook instalation script
Rename jenkinsfile.test
Update hook to use renamed Jenkinsfile
-rw-r--r-- | Jenkinsfile | 62 | ||||
-rw-r--r-- | Jenkinsfile.test | 29 | ||||
-rwxr-xr-x | hooks/pre-commit | 5 | ||||
-rwxr-xr-x | install_hooks.sh | 4 | ||||
-rwxr-xr-x | tests/access_env_var.sh | 4 | ||||
-rw-r--r-- | tests/setup.cfg | 3 | ||||
-rw-r--r-- | tests/test_25pass.py | 11 | ||||
-rw-r--r-- | tests/test_75pass.py | 11 | ||||
-rw-r--r-- | tests/test_alwaysfail.py (renamed from test_alwaysfail.py) | 0 | ||||
-rw-r--r-- | tests/test_alwayspass.py | 3 |
10 files changed, 103 insertions, 29 deletions
diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..6ffbe14 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,62 @@ +@Library('utils@master') _ + +//trivial edit +// [skip ci] and [ci skip] have no effect here. +if (utils.scm_checkout(['skip_disable':true])) return + +// Allow modification of the job configuration, affects all relevant build configs. +// Pass this object in the argument list to the`run()` function below to apply these settings to the job's execution. +jobconfig = new JobConfig() +jobconfig.post_test_summary = true +//jobconfig.credentials = ['SECRET_VALUE'] +//jobconfig.enable_env_publication = true +//jobconfig.publish_env_on_success_only = false + + +// Pytest wrapper +def PYTEST_BASETEMP = "test_outputs" +def PYTEST = "pytest \ + -r s \ + --basetemp=${PYTEST_BASETEMP} \ + --junit-xml=results.xml" + +// Configure artifactory ingest +data_config = new DataConfig() +data_config.server_id = 'bytesalad' +data_config.root = '${PYTEST_BASETEMP}' +data_config.match_prefix = '(.*)_result' // .json is appended automatically + + +bc0 = new BuildConfig() +//bc0.nodetype = 'RHEL-6' +bc0.nodetype = 'linux' +bc0.name = 'First buildconfig' +bc0.env_vars = ['VAR_ONE=1', + 'VAR_TWO=2'] +bc0.conda_ver = '4.6.4' +bc0.conda_packages = ['python=3.6', + 'pytest=3.8.2'] +bc0.build_cmds = ["date", + "./access_env_var.sh", + "which python", + "conda install ipython"] +bc0.test_cmds = ["${PYTEST} test_75pass.py"] +bc0.test_configs = [data_config] + + +bc1 = utils.copy(bc0) +bc1.name = 'Second' +bc1.env_vars = ['VAR_THREE=3', + 'VAR_FOUR=4'] +bc1.test_cmds[1] = "${PYTEST} test_25pass.py" + + +bc2 = utils.copy(bc0) +bc2.name = 'Third build config' +bc2.conda_packages = [] +bc2.build_cmds = ["which python"] +bc2.test_cmds = ["ls -al"] +bc2.test_configs = [] + + +utils.run([bc0, bc1, bc2, jobconfig]) diff --git a/Jenkinsfile.test b/Jenkinsfile.test deleted file mode 100644 index 320a16f..0000000 --- a/Jenkinsfile.test +++ /dev/null @@ -1,29 +0,0 @@ -@Library('utils@master') _ - -if (utils.scm_checkout(['skip_disable':true])) return - -def PYTEST = "pytest \ - -r s \ - --basetemp=test_outputs \ - --junit-xml=results.xml" - -jobconfig = new JobConfig() -jobconfig.post_test_summary = true - - -bc0 = new BuildConfig() -bc0.nodetype = 'master' -bc0.name = 'First' -bc0.conda_packages = ['python=3.6', - 'pytest'] -bc0.build_cmds = ["ls -al", - "date"] -bc0.test_cmds = ["printenv | sort", - "${PYTEST}"] - -bc1 = utils.copy(bc0) -bc1.name = 'Second' -bc1.env_vars = ['VAR_THREE=3', - 'VAR_FOUR=4'] - -utils.run([bc0, bc1]) diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 0000000..f4522e4 --- /dev/null +++ b/hooks/pre-commit @@ -0,0 +1,5 @@ +printf "[pre-commit hook] Updating branch reference in Jenkinsfile.test to allow self-testing... " +branch=$(git rev-parse --abbrev-ref HEAD) +sed -i "s/utils@.*'/utils@${branch}'/" Jenkinsfile +git update-index --add Jenkinsfile +printf "done.\n" diff --git a/install_hooks.sh b/install_hooks.sh new file mode 100755 index 0000000..95a2383 --- /dev/null +++ b/install_hooks.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +echo "Installing pre-commit git hook script to facilitate CI testing..." +ln -s ../../hooks/pre-commit .git/hooks/pre-commit diff --git a/tests/access_env_var.sh b/tests/access_env_var.sh new file mode 100755 index 0000000..b7a5b3f --- /dev/null +++ b/tests/access_env_var.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +echo "This is the value of SECRET_VALUE" +echo "${SECRET_VALUE}" diff --git a/tests/setup.cfg b/tests/setup.cfg new file mode 100644 index 0000000..fed90fd --- /dev/null +++ b/tests/setup.cfg @@ -0,0 +1,3 @@ +[tool:pytest] +junit_family=xunit2 +results_root = datb-generic diff --git a/tests/test_25pass.py b/tests/test_25pass.py new file mode 100644 index 0000000..a18bb9c --- /dev/null +++ b/tests/test_25pass.py @@ -0,0 +1,11 @@ +def test_25_1of4(): + assert 1==1 + +def test_25_2of4(): + assert 1==2 + +def test_25_3of4(): + assert 1==3 + +def test_25_4of4(): + assert 1==4 diff --git a/tests/test_75pass.py b/tests/test_75pass.py new file mode 100644 index 0000000..88028a7 --- /dev/null +++ b/tests/test_75pass.py @@ -0,0 +1,11 @@ +def test_75_1of4(): + assert 1==1 + +def test_75_2of4(): + assert 1==1 + +def test_75_3of4(): + assert 1==1 + +def test_75_4of4(): + assert 1==4 diff --git a/test_alwaysfail.py b/tests/test_alwaysfail.py index c3c2558..c3c2558 100644 --- a/test_alwaysfail.py +++ b/tests/test_alwaysfail.py diff --git a/tests/test_alwayspass.py b/tests/test_alwayspass.py new file mode 100644 index 0000000..7e84d20 --- /dev/null +++ b/tests/test_alwayspass.py @@ -0,0 +1,3 @@ +def test_alwayspass(): + assert 1==1 + |