|
| 1 | +# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions |
| 2 | +name: EasyBuild framework unit tests |
| 3 | +on: [push, pull_request] |
| 4 | +jobs: |
| 5 | + build: |
| 6 | + runs-on: ubuntu-18.04 |
| 7 | + strategy: |
| 8 | + matrix: |
| 9 | + python: [2.7, 3.5, 3.6, 3.7] |
| 10 | + modules_tool: [Lmod-6.6.3, Lmod-7.8.22, Lmod-8.1.14, modules-tcl-1.147, modules-3.2.10, modules-4.1.4] |
| 11 | + module_syntax: [Lua, Tcl] |
| 12 | + # exclude some configuration for non-Lmod modules tool: |
| 13 | + # - don't test with Lua module syntax (only supported in Lmod) |
| 14 | + # - don't test with Python 3.5 and 3.7 (only with 2.7 and 3.6), to limit test configurations |
| 15 | + exclude: |
| 16 | + - modules_tool: modules-tcl-1.147 |
| 17 | + module_syntax: Lua |
| 18 | + - modules_tool: modules-3.2.10 |
| 19 | + module_syntax: Lua |
| 20 | + - modules_tool: modules-4.1.4 |
| 21 | + module_syntax: Lua |
| 22 | + - modules_tool: modules-tcl-1.147 |
| 23 | + python: 3.5 |
| 24 | + - modules_tool: modules-tcl-1.147 |
| 25 | + python: 3.7 |
| 26 | + - modules_tool: modules-3.2.10 |
| 27 | + python: 3.5 |
| 28 | + - modules_tool: modules-3.2.10 |
| 29 | + python: 3.7 |
| 30 | + - modules_tool: modules-4.1.4 |
| 31 | + python: 3.5 |
| 32 | + - modules_tool: modules-4.1.4 |
| 33 | + python: 3.7 |
| 34 | + fail-fast: false |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v1 |
| 37 | + |
| 38 | + - name: set up Python |
| 39 | + uses: actions/setup-python@v1 |
| 40 | + with: |
| 41 | + python-version: ${{matrix.python}} |
| 42 | + architecture: x64 |
| 43 | + |
| 44 | + - name: install OS & Python packages |
| 45 | + run: | |
| 46 | + # for modules tool |
| 47 | + sudo apt-get install lua5.2 liblua5.2-dev lua-filesystem lua-posix tcl tcl-dev |
| 48 | + # fix for lua-posix packaging issue, see https://bugs.launchpad.net/ubuntu/+source/lua-posix/+bug/1752082 |
| 49 | + sudo ln -s /usr/lib/x86_64-linux-gnu/lua/5.2/posix_c.so /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so |
| 50 | + # for GitPython, python-hglib |
| 51 | + sudo apt-get install git mercurial |
| 52 | + # dep for GC3Pie |
| 53 | + sudo apt-get install time |
| 54 | + # Python packages |
| 55 | + pip --version |
| 56 | + pip install --upgrade pip |
| 57 | + pip --version |
| 58 | + pip install -r requirements.txt |
| 59 | + # git config is required to make actual git commits (cfr. tests for GitRepository) |
| 60 | + git config --global user.name "Travis CI" |
| 61 | + git config --global user.email "[email protected]" |
| 62 | + git config --get-regexp 'user.*' |
| 63 | +
|
| 64 | + - name: install GitHub token (if available) |
| 65 | + env: |
| 66 | + # see https://github.com/<username>/easybuild-framework/settings/secrets |
| 67 | + GITHUB_TOKEN: ${{secrets.TEST_GITHUB_TOKEN}} |
| 68 | + run: | |
| 69 | + if [ ! -z $GITHUB_TOKEN ]; then |
| 70 | + if [ "x${{matrix.python}}" == 'x2.6' ]; |
| 71 | + then SET_KEYRING="keyring.set_keyring(keyring.backends.file.PlaintextKeyring())"; |
| 72 | + else SET_KEYRING="import keyrings; keyring.set_keyring(keyrings.alt.file.PlaintextKeyring())"; |
| 73 | + fi; |
| 74 | + python -c "import keyring; $SET_KEYRING; keyring.set_password('github_token', 'easybuild_test', '$GITHUB_TOKEN')"; |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: install modules tool |
| 78 | + run: | |
| 79 | + # avoid downloading modules tool sources into easybuild-framework dir |
| 80 | + cd $HOME |
| 81 | + export INSTALL_DEP=$GITHUB_WORKSPACE/easybuild/scripts/install_eb_dep.sh |
| 82 | + # install Lmod |
| 83 | + source $INSTALL_DEP ${{matrix.modules_tool}} $HOME |
| 84 | + # changes in environment are not passed to other steps, so need to create files... |
| 85 | + echo $MOD_INIT > mod_init |
| 86 | + echo $PATH > path |
| 87 | + if [ ! -z $MODULESHOME ]; then echo $MODULESHOME > moduleshome; fi |
| 88 | +
|
| 89 | + - name: check sources |
| 90 | + run: | |
| 91 | + # make sure there are no (top-level) "import setuptools" or "import pkg_resources" statements, |
| 92 | + # since EasyBuild should not have a runtime requirement on setuptools |
| 93 | + SETUPTOOLS_IMPORTS=$(egrep -RI '^(from|import)[ ]*pkg_resources|^(from|import)[ ]*setuptools' * || true) |
| 94 | + test "x$SETUPTOOLS_IMPORTS" = "x" || (echo "Found setuptools and/or pkg_resources imports in easybuild/:\n${SETUPTOOLS_IMPORTS}" && exit 1) |
| 95 | +
|
| 96 | + - name: install sources |
| 97 | + run: | |
| 98 | + # install from source distribution tarball, to test release as published on PyPI |
| 99 | + python setup.py sdist |
| 100 | + ls dist |
| 101 | + export PREFIX=/tmp/$USER/$GITHUB_SHA |
| 102 | + pip install --prefix $PREFIX dist/easybuild-framework*tar.gz |
| 103 | +
|
| 104 | + - name: run test suite & test bootstrap script |
| 105 | + env: |
| 106 | + EB_VERBOSE: 1 |
| 107 | + EASYBUILD_MODULE_SYNTAX: ${{matrix.module_syntax}} |
| 108 | + TEST_EASYBUILD_MODULE_SYNTAX: ${{matrix.module_syntax}} |
| 109 | + run: | |
| 110 | + # initialize environment for modules tool |
| 111 | + if [ -f $HOME/moduleshome ]; then export MODULESHOME=$(cat $HOME/moduleshome); fi |
| 112 | + source $(cat $HOME/mod_init); type module |
| 113 | + # make sure 'eb' is available via $PATH, and that $PYTHONPATH is set (some tests expect that); |
| 114 | + # also pick up changes to $PATH set by sourcing $MOD_INIT |
| 115 | + export PREFIX=/tmp/$USER/$GITHUB_SHA |
| 116 | + export PATH=$PREFIX/bin:$(cat $HOME/path) |
| 117 | + export PYTHONPATH=$PREFIX/lib/python${{matrix.python}}/site-packages:$PYTHONPATH |
| 118 | + eb --version |
| 119 | + # tell EasyBuild which modules tool is available |
| 120 | + if [[ ${{matrix.modules_tool}} =~ ^modules-tcl- ]]; then |
| 121 | + export EASYBUILD_MODULES_TOOL=EnvironmentModulesTcl |
| 122 | + elif [[ ${{matrix.modules_tool}} =~ ^modules-3 ]]; then |
| 123 | + export EASYBUILD_MODULES_TOOL=EnvironmentModulesC |
| 124 | + elif [[ ${{matrix.modules_tool}} =~ ^modules-4 ]]; then |
| 125 | + export EASYBUILD_MODULES_TOOL=EnvironmentModules |
| 126 | + else |
| 127 | + export EASYBUILD_MODULES_TOOL=Lmod |
| 128 | + fi |
| 129 | + export TEST_EASYBUILD_MODULES_TOOL=$EASYBUILD_MODULES_TOOL |
| 130 | + eb --show-config |
| 131 | + # gather some useful info on test system |
| 132 | + eb --show-system-info |
| 133 | + # check GitHub configuration |
| 134 | + eb --check-github --github-user=easybuild_test |
| 135 | + # run test suite |
| 136 | + python -O -m test.framework.suite 2>&1 | tee test_framework_suite.log |
| 137 | + # try and make sure output of running tests is clean (no printed messages/warnings) |
| 138 | + IGNORE_PATTERNS="no GitHub token available|skipping SvnRepository test|requires Lmod as modules tool|stty: 'standard input': Inappropriate ioctl for device" |
| 139 | + # '|| true' is needed to avoid that Travis stops the job on non-zero exit of grep (i.e. when there are no matches) |
| 140 | + PRINTED_MSG=$(egrep -v "${IGNORE_PATTERNS}" test_framework_suite.log | grep '\.\n*[A-Za-z]' || true) |
| 141 | + test "x$PRINTED_MSG" = "x" || (echo "ERROR: Found printed messages in output of test suite\n${PRINTED_MSG}" && exit 1) |
| 142 | +
|
| 143 | + # version and SHA256 checksum are hardcoded below to avoid forgetting to update the version in the script along with contents |
| 144 | + EB_BOOTSTRAP_VERSION=$(grep '^EB_BOOTSTRAP_VERSION' easybuild/scripts/bootstrap_eb.py | sed 's/[^0-9.]//g') |
| 145 | + EB_BOOTSTRAP_SHA256SUM=$(sha256sum easybuild/scripts/bootstrap_eb.py | cut -f1 -d' ') |
| 146 | + EB_BOOTSTRAP_FOUND="$EB_BOOTSTRAP_VERSION $EB_BOOTSTRAP_SHA256SUM" |
| 147 | + EB_BOOTSTRAP_EXPECTED="20190922.01 778762479d77df641c247aba33c13203c8c5b8275e47f59464bab93917aaaf22" |
| 148 | + test "$EB_BOOTSTRAP_FOUND" = "$EB_BOOTSTRAP_EXPECTED" || (echo "Version check on bootstrap script failed $EB_BOOTSTRAP_FOUND" && exit 1) |
| 149 | +
|
| 150 | + # test bootstrap script (only compatible with Python 2 for now) |
| 151 | + if [[ ${{matrix.python}} =~ '2.' ]]; then |
| 152 | + export PREFIX=/tmp/$USER/$GITHUB_SHA/eb_bootstrap |
| 153 | + python easybuild/scripts/bootstrap_eb.py $PREFIX |
| 154 | + # unset $PYTHONPATH to avoid mixing two EasyBuild 'installations' when testing bootstrapped EasyBuild module |
| 155 | + unset PYTHONPATH |
| 156 | + # simple sanity check on bootstrapped EasyBuild module (skip when testing with Python 3, for now) |
| 157 | + module use $PREFIX/modules/all |
| 158 | + module load EasyBuild |
| 159 | + eb --version |
| 160 | + else |
| 161 | + echo "Testing of bootstrap script skipped when testing with Python ${{matrix.python}}" |
| 162 | + fi |
0 commit comments