Skip to content

check presence of CWD at the end of run_shell_cmd and try to return to original working directory if non-existent #4607

check presence of CWD at the end of run_shell_cmd and try to return to original working directory if non-existent

check presence of CWD at the end of run_shell_cmd and try to return to original working directory if non-existent #4607

Workflow file for this run

# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions
name: EasyBuild framework unit tests
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:
setup:
runs-on: ubuntu-20.04
outputs:
lmod8: Lmod-8.7.6
modules4: modules-4.1.4
steps:
- run: "true"
build:
needs: setup
runs-on: ubuntu-20.04
strategy:
matrix:
python: [3.6]
modules_tool:
# use variables defined by 'setup' job above, see also
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context
- ${{needs.setup.outputs.lmod8}}
- ${{needs.setup.outputs.modules4}}
lc_all: [""]
include:
# Test different Python 3 versions with Lmod 8.x (with both Lua and Tcl module syntax)
- python: 3.7
modules_tool: ${{needs.setup.outputs.lmod8}}
- python: 3.8
modules_tool: ${{needs.setup.outputs.lmod8}}
- python: 3.9
modules_tool: ${{needs.setup.outputs.lmod8}}
- python: '3.10'
modules_tool: ${{needs.setup.outputs.lmod8}}
- python: '3.11'
modules_tool: ${{needs.setup.outputs.lmod8}}
- python: '3.12'
modules_tool: ${{needs.setup.outputs.lmod8}}
# There may be encoding errors in Python 3 which are hidden when an UTF-8 encoding is set
# Hence run the tests (again) with LC_ALL=C and Python 3.6 (or any < 3.7)
- python: 3.6
modules_tool: ${{needs.setup.outputs.lmod8}}
lc_all: C
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: set up Python
uses: actions/setup-python@v4
with:
python-version: ${{matrix.python}}
architecture: x64
- name: install OS & Python packages
run: |
# for modules tool
APT_PKGS="lua5.2 liblua5.2-dev lua-filesystem lua-posix tcl tcl-dev"
# for GitPython, python-hglib
APT_PKGS+=" git mercurial"
# dep for GC3Pie
APT_PKGS+=" time"
# Avoid apt-get update, as we don't really need it,
# and it does more harm than good (it's fairly expensive, and it results in flaky test runs)
if ! sudo apt-get install $APT_PKGS; then
# Try to update cache, then try again to resolve 404s of old packages
sudo apt-get update -yqq || true
sudo apt-get install $APT_PKGS
fi
# fix for lua-posix packaging issue, see https://bugs.launchpad.net/ubuntu/+source/lua-posix/+bug/1752082
# needed for Ubuntu 18.04, but not for Ubuntu 20.04, so skipping symlinking if posix.so already exists
if [ ! -e /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so ] ; then
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
fi
# Python packages
pip --version
pip install --upgrade pip
pip --version
pip install -r requirements.txt
if ! python -c "import distutils" 2> /dev/null; then
# we need setuptools for distutils in Python 3.12+, needed for python setup.py sdist
pip install --upgrade setuptools
fi
# git config is required to make actual git commits (cfr. tests for GitRepository)
git config --global user.name "Travis CI"
git config --global user.email "travis@travis-ci.org"
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: |
# only install GitHub token when testing with Lmod 8.x + Python 3.6 or 3.9, to avoid hitting GitHub rate limit;
# tests that require a GitHub token are skipped automatically when no GitHub token is available
if [[ "${{matrix.modules_tool}}" =~ 'Lmod-8' ]] && [[ "${{matrix.python}}" =~ 3.[69] ]]; then
if [ ! -z $GITHUB_TOKEN ]; then
SET_KEYRING="import keyrings.alt.file; keyring.set_keyring(keyrings.alt.file.PlaintextKeyring())";
python -c "import keyring; $SET_KEYRING; keyring.set_password('github_token', 'easybuild_test', '$GITHUB_TOKEN')";
fi
echo "GitHub token installed!"
else
echo "Installation of GitHub token skipped!"
fi
- name: install modules tool
run: |
# avoid downloading modules tool sources into easybuild-framework dir
cd $HOME
export INSTALL_DEP=$GITHUB_WORKSPACE/easybuild/scripts/install_eb_dep.sh
# install Lmod
source $INSTALL_DEP ${{matrix.modules_tool}} $HOME
# changes in environment are not passed to other steps, so need to create files...
echo $MOD_INIT > mod_init
echo $PATH > path
if [ ! -z $MODULESHOME ]; then echo $MODULESHOME > moduleshome; fi
- name: check sources
run: |
# make sure there are no (top-level) "import setuptools" or "import pkg_resources" statements,
# since EasyBuild should not have a runtime requirement on setuptools
SETUPTOOLS_IMPORTS=$(egrep -RI '^(from|import)[ ]*pkg_resources|^(from|import)[ ]*setuptools' * || true)
test "x$SETUPTOOLS_IMPORTS" = "x" || (echo "Found setuptools and/or pkg_resources imports in easybuild/:\n${SETUPTOOLS_IMPORTS}" && exit 1)
- name: install sources
run: |
# install from source distribution tarball, to test release as published on PyPI
python setup.py sdist
ls dist
export PREFIX=/tmp/$USER/$GITHUB_SHA
pip install --prefix $PREFIX dist/easybuild[-_]framework*tar.gz
- name: run test suite
env:
EB_VERBOSE: 1
LC_ALL: ${{matrix.lc_all}}
run: |
# run tests *outside* of checked out easybuild-framework directory,
# to ensure we're testing installed version (see previous step)
cd $HOME
# initialize environment for modules tool
if [ -f $HOME/moduleshome ]; then export MODULESHOME=$(cat $HOME/moduleshome); fi
source $(cat $HOME/mod_init); type module
# make sure 'eb' is available via $PATH, and that $PYTHONPATH is set (some tests expect that);
# also pick up changes to $PATH set by sourcing $MOD_INIT
export PREFIX=/tmp/$USER/$GITHUB_SHA
export PATH=$PREFIX/bin:$(cat $HOME/path)
export PYTHONPATH=$PREFIX/lib/python${{matrix.python}}/site-packages:$PYTHONPATH
eb --version
# tell EasyBuild which modules tool is available
if [[ ${{matrix.modules_tool}} =~ ^modules-4 ]]; then
export EASYBUILD_MODULES_TOOL=EnvironmentModules
else
export EASYBUILD_MODULES_TOOL=Lmod
fi
export TEST_EASYBUILD_MODULES_TOOL=${EASYBUILD_MODULES_TOOL}
# Run tests with LUA and Tcl module syntax (where supported)
for module_syntax in Lua Tcl; do
# Only Lmod supports Lua
if [[ "${module_syntax}" == "Lua" ]] && [[ "${EASYBUILD_MODULES_TOOL}" != "Lmod" ]]; then
echo "Not testing with '${module_syntax}' as module syntax with '${EASYBUILD_MODULES_TOOL}' as modules tool"
continue
fi
printf "\n\n=====================> Using $module_syntax module syntax <=====================\n\n"
export EASYBUILD_MODULE_SYNTAX="${module_syntax}"
export TEST_EASYBUILD_MODULE_SYNTAX="${EASYBUILD_MODULE_SYNTAX}"
eb --show-config
# gather some useful info on test system
eb --show-system-info
# check GitHub configuration
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
python -O -m test.framework.suite 2>&1 | tee test_framework_suite.log
# try and make sure output of running tests is clean (no printed messages/warnings)
IGNORE_PATTERNS="no GitHub token available|skipping SvnRepository test|requires Lmod as modules tool|stty: 'standard input': Inappropriate ioctl for device|CryptographyDeprecationWarning: Python 3.[56]|from cryptography.* import |CryptographyDeprecationWarning: Python 2|Blowfish|GC3Pie not available, skipping test"
# '|| true' is needed to avoid that GitHub Actions stops the job on non-zero exit of grep (i.e. when there are no matches)
PRINTED_MSG=$(egrep -v "${IGNORE_PATTERNS}" test_framework_suite.log | grep '\.\n*[A-Za-z]' || true)
test "x$PRINTED_MSG" = "x" || (echo "ERROR: Found printed messages in output of test suite" && echo "${PRINTED_MSG}" && exit 1)
done