From 9782b94410d15220d47d234f46a8342756fa00d1 Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 15:16:32 -0400 Subject: [PATCH 01/14] make some changes to regression test container workflow --- .github/workflows/regressiontest_container.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/regressiontest_container.yml b/.github/workflows/regressiontest_container.yml index 2f0ce9072..a7875ab7e 100644 --- a/.github/workflows/regressiontest_container.yml +++ b/.github/workflows/regressiontest_container.yml @@ -23,14 +23,8 @@ 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 + export BUILDTEST_CONFIGFILE=$BUILDTEST_ROOT/buildtest/settings/spack_container.yml + python $BUILDTEST_ROOT/buildtest/tools/unittests.py -c returncode=$? - if [ $returncode != 0 ]; then exit $returncode; fi - - - name: Setup tmate session - if: ${{ failure() }} - uses: mxschmitt/action-tmate@v3 - timeout-minutes: 30 \ No newline at end of file + if [ $returncode != 0 ]; then exit $returncode; fi \ No newline at end of file From 978c764234e0bd123a0d7be9f99d8bd4e785db9a Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 15:20:17 -0400 Subject: [PATCH 02/14] change condition for username when to run the spack tests --- tests/buildsystem/test_spack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/buildsystem/test_spack.py b/tests/buildsystem/test_spack.py index a04e476dd..26d30f8c0 100644 --- a/tests/buildsystem/test_spack.py +++ b/tests/buildsystem/test_spack.py @@ -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( From 06d75dba009ae7979be10015c80c750f029bf7bc Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 15:20:34 -0400 Subject: [PATCH 03/14] need to remove environment BUILDTEST_CONFIGFILE since this is handled by regression test --- .github/workflows/regressiontest_container.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/regressiontest_container.yml b/.github/workflows/regressiontest_container.yml index a7875ab7e..2acce5ece 100644 --- a/.github/workflows/regressiontest_container.yml +++ b/.github/workflows/regressiontest_container.yml @@ -24,7 +24,6 @@ jobs: python3 -m venv env source env/bin/activate source setup.sh - export BUILDTEST_CONFIGFILE=$BUILDTEST_ROOT/buildtest/settings/spack_container.yml python $BUILDTEST_ROOT/buildtest/tools/unittests.py -c returncode=$? if [ $returncode != 0 ]; then exit $returncode; fi \ No newline at end of file From c1b6916710a1cc4579415f4d8be81ccec44c5fce Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 15:22:56 -0400 Subject: [PATCH 04/14] add list of file paths when regression test should be invoked --- .github/workflows/regressiontest_container.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/regressiontest_container.yml b/.github/workflows/regressiontest_container.yml index 2acce5ece..a3fbeebe9 100644 --- a/.github/workflows/regressiontest_container.yml +++ b/.github/workflows/regressiontest_container.yml @@ -3,6 +3,12 @@ name: Regression Test in Container on: pull_request: branches: [ devel ] + paths: + - 'buildtest/**' + - 'tests/**' + - '.github/workflows/regressiontest_container.yml' + - 'requirements.txt' + - 'pyproject.toml' jobs: buildtest_tutorial_container: From 1c529f8f3e1fdb28e242a478e6fe4b959e55c71c Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 15:28:10 -0400 Subject: [PATCH 05/14] remove whitespaces --- .github/workflows/regressiontest_container.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regressiontest_container.yml b/.github/workflows/regressiontest_container.yml index a3fbeebe9..20b8a3882 100644 --- a/.github/workflows/regressiontest_container.yml +++ b/.github/workflows/regressiontest_container.yml @@ -2,7 +2,7 @@ name: Regression Test in Container on: pull_request: - branches: [ devel ] + branches: [devel] paths: - 'buildtest/**' - 'tests/**' From acda9704df64681b5dcfe5fb02a14f7df871385c Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 15:42:03 -0400 Subject: [PATCH 06/14] fix typo in csh and zsh test detection for running the shell specific tests --- tests/utils/test_shell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils/test_shell.py b/tests/utils/test_shell.py index 021cc051c..3bb195e79 100755 --- a/tests/utils/test_shell.py +++ b/tests/utils/test_shell.py @@ -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") @@ -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") From ef41d974d0160d6898c7c30cde3115d2e067c266 Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 15:43:49 -0400 Subject: [PATCH 07/14] fix typo in tcsh shell --- tests/utils/test_shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/test_shell.py b/tests/utils/test_shell.py index 3bb195e79..67e05f391 100755 --- a/tests/utils/test_shell.py +++ b/tests/utils/test_shell.py @@ -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") From 9b8a2a2b69ae918f37fcbec6d9b8263f6b2770dd Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 13:25:23 -0700 Subject: [PATCH 08/14] check for pip in $HOME/.local/bin and if its present there then we add this directory to $PATH to ensure script doesnt fail This would be the default behavior when installing python packages outside of virtual environment --- setup.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 9f3901632..603556712 100755 --- a/setup.sh +++ b/setup.sh @@ -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 @@ -80,4 +87,4 @@ if [ -z "$PYTHONPATH" ]; then export PYTHONPATH=${BUILDTEST_ROOT} else export PYTHONPATH=${BUILDTEST_ROOT}:$PYTHONPATH -fi \ No newline at end of file +fi From d0ac91195a2a53e35e5d68b39217025bbd7e8e6d Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 16:27:36 -0400 Subject: [PATCH 09/14] remove execute bit from test_shell.py --- tests/utils/test_shell.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/utils/test_shell.py diff --git a/tests/utils/test_shell.py b/tests/utils/test_shell.py old mode 100755 new mode 100644 From 98b39491c6f37e696327a48858e8fb415867da43 Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 16:35:05 -0400 Subject: [PATCH 10/14] add logic for adding csh and zsh shells if they are not found in /etc/shells --- buildtest/utils/shell.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/buildtest/utils/shell.py b/buildtest/utils/shell.py index 768550bfe..f5e0abab7 100755 --- a/buildtest/utils/shell.py +++ b/buildtest/utils/shell.py @@ -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 From ffab0eb8700dd0845bca869d3f78c4debb12562d Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Fri, 28 Jun 2024 16:39:40 -0400 Subject: [PATCH 11/14] change to /usr/bin/csh when testing the shell --- tests/utils/test_shell.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/utils/test_shell.py b/tests/utils/test_shell.py index 67e05f391..1cc710eb6 100644 --- a/tests/utils/test_shell.py +++ b/tests/utils/test_shell.py @@ -67,13 +67,13 @@ def test_zsh_shell(self): @pytest.mark.utility() def test_csh_shell(self): - if not shutil.which("/bin/csh"): + if not shutil.which("/usr/bin/csh"): pytest.skip("Skipping test for csh shell") - shell = Shell("/bin/csh") - assert shell.name == "/bin/csh" - assert shell.path == shutil.which("/bin/csh") - assert shell.shebang == f"#!{shutil.which('/bin/csh')}" + shell = Shell("/usr/bin/csh") + assert shell.name == "/usr/bin/csh" + assert shell.path == shutil.which("/usr/bin/csh") + assert shell.shebang == f"#!{shutil.which('/usr/bin/csh')}" shell = Shell("csh") assert shell.name == "csh" From 182633b5746dc2593a1ff2827dde9853f207c3bc Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Mon, 1 Jul 2024 12:16:15 -0400 Subject: [PATCH 12/14] add logic for if condition in setup.csh --- setup.csh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/setup.csh b/setup.csh index 436d10de3..bbb55865d 100755 --- a/setup.csh +++ b/setup.csh @@ -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 From 2e960b6c5a79a798d0beb3130b163aeaaf7c35df Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Mon, 1 Jul 2024 12:17:53 -0400 Subject: [PATCH 13/14] we need to only run the spack tests in regression test so use the --pytest option to specify the marker name also add codecov-action to get the coverage results --- .github/workflows/regressiontest_container.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regressiontest_container.yml b/.github/workflows/regressiontest_container.yml index 20b8a3882..ca8b310cf 100644 --- a/.github/workflows/regressiontest_container.yml +++ b/.github/workflows/regressiontest_container.yml @@ -30,6 +30,12 @@ jobs: python3 -m venv env source env/bin/activate source setup.sh - python $BUILDTEST_ROOT/buildtest/tools/unittests.py -c + python $BUILDTEST_ROOT/buildtest/tools/unittests.py -c --pytest="-m spack" returncode=$? - if [ $returncode != 0 ]; then exit $returncode; fi \ No newline at end of file + if [ $returncode != 0 ]; then exit $returncode; fi + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file From 91aefe89569be42d35eebd2602cfffa401bb031a Mon Sep 17 00:00:00 2001 From: Shahzeb Siddiqui Date: Mon, 1 Jul 2024 12:28:53 -0400 Subject: [PATCH 14/14] revert change for regression test for csh shell example to use /bin/csh instead of /usr/bin/csh --- tests/utils/test_shell.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/utils/test_shell.py b/tests/utils/test_shell.py index 1cc710eb6..67e05f391 100644 --- a/tests/utils/test_shell.py +++ b/tests/utils/test_shell.py @@ -67,13 +67,13 @@ def test_zsh_shell(self): @pytest.mark.utility() def test_csh_shell(self): - if not shutil.which("/usr/bin/csh"): + if not shutil.which("/bin/csh"): pytest.skip("Skipping test for csh shell") - shell = Shell("/usr/bin/csh") - assert shell.name == "/usr/bin/csh" - assert shell.path == shutil.which("/usr/bin/csh") - assert shell.shebang == f"#!{shutil.which('/usr/bin/csh')}" + shell = Shell("/bin/csh") + assert shell.name == "/bin/csh" + assert shell.path == shutil.which("/bin/csh") + assert shell.shebang == f"#!{shutil.which('/bin/csh')}" shell = Shell("csh") assert shell.name == "csh"