Skip to content

Commit

Permalink
Merge pull request #1794 from buildtesters/update_regtest_workflow
Browse files Browse the repository at this point in the history
update regression test workflow container
  • Loading branch information
shahzebsiddiqui authored Jul 1, 2024
2 parents 9d12235 + 91aefe8 commit 46174be
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 22 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/regressiontest_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ name: Regression Test in Container

on:
pull_request:
branches: [ devel ]
branches: [devel]
paths:
- 'buildtest/**'
- 'tests/**'
- '.github/workflows/regressiontest_container.yml'
- 'requirements.txt'
- 'pyproject.toml'

jobs:
buildtest_tutorial_container:
Expand All @@ -23,14 +29,13 @@ jobs:
module load python
python3 -m venv env
source env/bin/activate
export HOMEDIR=`pwd`
export BUILDTEST_CONFIGFILE=$HOMEDIR/buildtest/settings/spack_container.yml
source $HOMEDIR/setup.sh
python $HOMEDIR/buildtest/tools/unittests.py -c
source setup.sh
python $BUILDTEST_ROOT/buildtest/tools/unittests.py -c --pytest="-m spack"

Check warning on line 33 in .github/workflows/regressiontest_container.yml

View workflow job for this annotation

GitHub Actions / style_checks

33:81 [line-length] line too long (84 > 80 characters)
returncode=$?
if [ $returncode != 0 ]; then exit $returncode; fi
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 30
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Check failure on line 41 in .github/workflows/regressiontest_container.yml

View workflow job for this annotation

GitHub Actions / style_checks

41:54 [new-line-at-end-of-file] no new line character at the end of file
10 changes: 10 additions & 0 deletions buildtest/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ def get_shells():
out = cmd.get_output()
out = [item.strip() for item in out]

# sometimes /etc/shells doesn't have all shells so we will use shutil.which to find shells
csh = shutil.which("csh")
zsh = shutil.which("zsh")

# if csh and zsh are found and not in list, then we add them to list.
if csh is not None and csh not in out:
out.append(csh)
if zsh is not None and zsh not in out:
out.append(zsh)

return out


Expand Down
13 changes: 10 additions & 3 deletions setup.csh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ curl https://bootstrap.pypa.io/get-pip.py | $python

set pip=pip3

if ( ! -x `command -v $pip` ) then
echo "cannot find program $pip. Please see the pip documentation: https://pip.pypa.io/en/stable/installation/ on how to install pip"
exit 1
if ( ! -x `command -v $pip` ) then
# If not found in PATH, check $HOME/.local/bin
if ( -x "$HOME/.local/bin/$pip" ) then
echo "$pip found in $HOME/.local/bin"
# Optionally, you can add $HOME/.local/bin to PATH
setenv PATH $HOME/.local/bin:$PATH
else
echo "cannot find program $pip. Please see the pip documentation: https://pip.pypa.io/en/stable/installation/ on how to install pip"
exit 1
endif
endif

$python -c "import buildtest.main" >& /dev/null
Expand Down
15 changes: 11 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ fi
python=python3

# install pip in user environment
curl https://bootstrap.pypa.io/get-pip.py | $python
curl https://bootstrap.pypa.io/get-pip.py | $python

pip=pip3

if ! [ -x "$(command -v $pip)" ]; then
echo "cannot find program $pip. Please see the pip documentation: https://pip.pypa.io/en/stable/installation/ on how to install pip"
exit 1
# If not found in PATH, check $HOME/.local/bin
if [ -x "$HOME/.local/bin/$pip" ]; then
echo "$pip found in $HOME/.local/bin"
# Optionally, you can add $HOME/.local/bin to PATH
export PATH=$HOME/.local/bin:$PATH
else
echo "cannot find program $pip. Please see the pip documentation: https://pip.pypa.io/en/stable/installation/ on how to install pip"
exit 1
fi
fi


Expand Down Expand Up @@ -80,4 +87,4 @@ if [ -z "$PYTHONPATH" ]; then
export PYTHONPATH=${BUILDTEST_ROOT}
else
export PYTHONPATH=${BUILDTEST_ROOT}:$PYTHONPATH
fi
fi
4 changes: 2 additions & 2 deletions tests/buildsystem/test_spack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
def test_spack_examples():
# spack builds must run in container ghcr.io/buildtesters/buildtest_spack:latest which comes with username 'spack' and home directory '/home/spack'
# if not (getpass.getuser() == "spack" and os.path.expanduser("~") == "/home/spack"):
if not (getpass.getuser() == "runner" and shutil.which("spack")):
if not (getpass.getuser() in ["root", "spack"] and shutil.which("spack")):
pytest.skip(
"Unable to run this test requires docker container: ghcr.io/buildtesters/buildtest_spack:latest"
"Unable to run this test requires docker container: ghcr.io/buildtesters/buildtest_spack:spack-sc23"
)

configuration = SiteConfiguration(
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/test_shell.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_bash_shell(self):

@pytest.mark.utility()
def test_zsh_shell(self):
if not shutil.which("bin/zsh"):
if not shutil.which("/bin/zsh"):
pytest.skip("Skipping test for zsh shell")

shell = Shell("/bin/zsh")
Expand All @@ -67,7 +67,7 @@ def test_zsh_shell(self):

@pytest.mark.utility()
def test_csh_shell(self):
if not shutil.which("bin/csh"):
if not shutil.which("/bin/csh"):
pytest.skip("Skipping test for csh shell")

shell = Shell("/bin/csh")
Expand All @@ -82,7 +82,7 @@ def test_csh_shell(self):

@pytest.mark.utility()
def test_tcsh_shell(self):
if not shutil.which("bin/tcsh"):
if not shutil.which("/bin/tcsh"):
pytest.skip("Skipping test for tcsh shell")

shell = Shell("/bin/tcsh")
Expand Down

0 comments on commit 46174be

Please sign in to comment.