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