summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-11-18 13:00:39 +0100
committerGitHub <noreply@github.com>2021-11-18 13:00:39 +0100
commit8f7640dbefd1adbd7e4104a404fa018f851776b5 (patch)
treee1006ae693b44360ec92913ad89eb1545bad7a81 /lib
parent7ee736a158ea9da955c54a282149208200865903 (diff)
downloadspack-8f7640dbefd1adbd7e4104a404fa018f851776b5.tar.gz
spack-8f7640dbefd1adbd7e4104a404fa018f851776b5.tar.bz2
spack-8f7640dbefd1adbd7e4104a404fa018f851776b5.tar.xz
spack-8f7640dbefd1adbd7e4104a404fa018f851776b5.zip
ci: run style unit tests only if we target develop (#27472)
Some tests assume the base branch is develop, but this branch may not have been checked out.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/cmd/style.py13
-rw-r--r--lib/spack/spack/test/package_sanity.py6
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/spack/spack/test/cmd/style.py b/lib/spack/spack/test/cmd/style.py
index af0fc47d24..29cde14400 100644
--- a/lib/spack/spack/test/cmd/style.py
+++ b/lib/spack/spack/test/cmd/style.py
@@ -24,8 +24,19 @@ style_data = os.path.join(spack.paths.test_path, 'data', 'style')
style = spack.main.SpackCommand("style")
+
+def has_develop_branch():
+ git = which('git')
+ if not git:
+ return False
+ git("show-ref", "--verify", "--quiet",
+ "refs/heads/develop", fail_on_error=False)
+ return git.returncode == 0
+
+
# spack style requires git to run -- skip the tests if it's not there
-pytestmark = pytest.mark.skipif(not which('git'), reason='requires git')
+pytestmark = pytest.mark.skipif(not has_develop_branch(),
+ reason='requires git with develop branch')
# The style tools have requirements to use newer Python versions. We simplify by
# requiring Python 3.6 or higher to run spack style.
diff --git a/lib/spack/spack/test/package_sanity.py b/lib/spack/spack/test/package_sanity.py
index 35840d85da..dd2f4b425f 100644
--- a/lib/spack/spack/test/package_sanity.py
+++ b/lib/spack/spack/test/package_sanity.py
@@ -206,8 +206,12 @@ def test_prs_update_old_api():
"""Ensures that every package modified in a PR doesn't contain
deprecated calls to any method.
"""
+ ref = os.getenv("GITHUB_BASE_REF")
+ if not ref:
+ pytest.skip("No base ref found")
+
changed_package_files = [
- x for x in style.changed_files() if style.is_package(x)
+ x for x in style.changed_files(base=ref) if style.is_package(x)
]
failing = []
for file in changed_package_files: