|
| 1 | +# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions |
| 2 | +name: EasyBuild framework unit tests (python2) |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read # to fetch code (actions/checkout) |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{format('{0}:{1}:{2}', github.repository, github.ref, github.workflow)}} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + test_python2: |
| 14 | + runs-on: ubuntu-20.04 |
| 15 | + container: |
| 16 | + # CentOS 7.9 container that already includes Lmod & co, |
| 17 | + # see https://github.com/easybuilders/easybuild-containers |
| 18 | + image: ghcr.io/easybuilders/centos-7.9-amd64 |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: install Python packages |
| 23 | + run: | |
| 24 | + # Python packages |
| 25 | + python2 -V |
| 26 | + python2 -m pip --version |
| 27 | + python2 -m pip install --upgrade pip |
| 28 | + python2 -m pip --version |
| 29 | + # strip out GC3Pie since installation with ancient setuptools (0.9.8) fails |
| 30 | + sed -i '/GC3Pie/d' requirements.txt |
| 31 | + python2 -m pip install -r requirements.txt |
| 32 | + # git config is required to make actual git commits (cfr. tests for GitRepository) |
| 33 | + sudo -u easybuild git config --global user.name "GitHub Actions" |
| 34 | + sudo -u easybuild git config --global user.email "[email protected]" |
| 35 | + sudo -u easybuild git config --get-regexp 'user.*' |
| 36 | +
|
| 37 | + - name: install GitHub token (if available) |
| 38 | + env: |
| 39 | + # token (owned by @boegelbot) with gist permissions (required for some of the tests for GitHub integration); |
| 40 | + # this token is not available in pull requests, so tests that require it are skipped in PRs, |
| 41 | + # and are only run after the PR gets merged |
| 42 | + GITHUB_TOKEN: ${{secrets.CI_UNIT_TESTS_GITHUB_TOKEN}} |
| 43 | + run: | |
| 44 | + # tests that require a GitHub token are skipped automatically when no GitHub token is available |
| 45 | + if [ ! -z $GITHUB_TOKEN ]; then |
| 46 | + sudo -u easybuild python2 -c "import keyring; import keyrings.alt.file; keyring.set_keyring(keyrings.alt.file.PlaintextKeyring()); keyring.set_password('github_token', 'easybuild_test', '$GITHUB_TOKEN')"; |
| 47 | + echo "GitHub token installed!" |
| 48 | + else |
| 49 | + echo "Installation of GitHub token skipped!" |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: install sources |
| 53 | + run: | |
| 54 | + # install from source distribution tarball, to test release as published on PyPI |
| 55 | + python2 setup.py sdist |
| 56 | + ls dist |
| 57 | + export PREFIX=/tmp/$USER/$GITHUB_SHA |
| 58 | + python2 -m pip install --prefix $PREFIX dist/easybuild-framework*tar.gz |
| 59 | +
|
| 60 | + - name: run test suite |
| 61 | + run: | |
| 62 | + # run tests *outside* of checked out easybuild-framework directory, |
| 63 | + # to ensure we're testing installed version (see previous step) |
| 64 | + cd $HOME |
| 65 | + # make sure 'eb' is available via $PATH, and that $PYTHONPATH is set (some tests expect that) |
| 66 | + export PREFIX=/tmp/$USER/$GITHUB_SHA |
| 67 | + ENV_CMDS="export PATH=$PREFIX/bin:$PATH; export PYTHONPATH=$PREFIX/lib/python2.7/site-packages:$PYTHONPATH" |
| 68 | + ENV_CMDS="${ENV_CMDS}; export EB_VERBOSE=1; export EB_PYTHON=python2; export TEST_EASYBUILD_SILENCE_DEPRECATION_WARNINGS=python2" |
| 69 | + # run EasyBuild command via (non-root) easybuild user + login shell |
| 70 | + sudo -u easybuild bash -l -c "${ENV_CMDS}; module --version; eb --version" |
| 71 | + # show active EasyBuild configuration |
| 72 | + sudo -u easybuild bash -l -c "${ENV_CMDS}; eb --show-config" |
| 73 | + # gather some useful info on test system |
| 74 | + sudo -u easybuild bash -l -c "${ENV_CMDS}; eb --show-system-info" |
| 75 | + # check GitHub configuration |
| 76 | + sudo -u easybuild bash -l -c "${ENV_CMDS}; eb --check-github --github-user=easybuild_test" |
| 77 | + # create file owned by root but writable by anyone (used by test_copy_file) |
| 78 | + sudo touch /tmp/file_to_overwrite_for_easybuild_test_copy_file.txt |
| 79 | + sudo chmod o+w /tmp/file_to_overwrite_for_easybuild_test_copy_file.txt |
| 80 | + # run test suite (via easybuild user + login shell) |
| 81 | + sudo -u easybuild bash -l -c "${ENV_CMDS}; python2 -O -m test.framework.suite" |
0 commit comments