diff --git a/.github/workflows/ubuntu-ci-x86_64-gnu.yaml b/.github/workflows/ubuntu-ci-x86_64-gnu.yaml index 48b8bba49..a20b969dc 100644 --- a/.github/workflows/ubuntu-ci-x86_64-gnu.yaml +++ b/.github/workflows/ubuntu-ci-x86_64-gnu.yaml @@ -177,7 +177,7 @@ jobs: # Test environment chaining echo "Test environment chaining" - spack stack create env --name chaintest --template empty --site linux.default --upstream ${ENVDIR}/install --compiler gcc + spack stack create env --name chaintest --template empty --site linux.default --compiler gcc --upstream ${ENVDIR}/install # Retain config from upstream so we don't have to rebuild: cp -r ${ENVDIR}/{site,common} $PWD/envs/chaintest/. spack env activate ${PWD}/envs/chaintest @@ -186,6 +186,12 @@ jobs: unwanted_duplicates=$(( cat envs/chaintest/log.concretize | grep -E '^ - ' | grep -Fv 'nccmp@1.9.0.1' || true ) | wc -l) if [ ${unwanted_duplicates} -gt 0 ]; then echo "Environment chaining test failed"; exit 1; fi spack env deactivate + echo "Verify 'create env' warnings" + echo "# nothing" >> ${SPACK_STACK_DIR}/envs/chaintest/site/packages.yaml + echo "# nothing" >> ${SPACK_STACK_DIR}/envs/chaintest/common/packages.yaml + spack stack create env --name chaintest3 --site linux.default --compiler gcc --upstream ${SPACK_STACK_DIR}/envs/chaintest/install 2>&1 | tee stderr.txt + cnt=$(grep -c "WARNING.*do not match" stderr.txt || true) + if [ $cnt -ne 2 ]; then echo "Missing 'create env' warnings"; exit 1; fi - name: test-env run: | diff --git a/spack-ext/lib/jcsda-emc/spack-stack/stack/stack_env.py b/spack-ext/lib/jcsda-emc/spack-stack/stack/stack_env.py index d4317fc4d..b63dd93f1 100644 --- a/spack-ext/lib/jcsda-emc/spack-stack/stack/stack_env.py +++ b/spack-ext/lib/jcsda-emc/spack-stack/stack/stack_env.py @@ -1,5 +1,6 @@ from collections import OrderedDict import copy +import filecmp import io import logging import os @@ -279,6 +280,10 @@ def write(self): spack.config.add(lmod_prefix, scope=env_scope) spack.config.add(tcl_prefix, scope=env_scope) if self.upstreams: + env_config_dirs = { + "common": os.path.join(self.env_dir(), "common"), + "site": os.path.join(self.env_dir(), "site"), + } for upstream_path in self.upstreams: upstream_path = upstream_path[0] # spack doesn't handle "~/" correctly, this fixes it: @@ -301,6 +306,24 @@ def write(self): upstream = "upstreams:%s:install_tree:'%s'" % (name, upstream_path) logging.info("Adding upstream path '%s'" % upstream_path) spack.config.add(upstream, scope=env_scope) + # Verify that config files match + upstream_config_dirs = { + "common": os.path.normpath(os.path.join(upstream_path, "../common/")), + "site": os.path.normpath(os.path.join(upstream_path, "../site/")), + } + for n in ("common", "site"): + if not os.path.isdir(upstream_config_dirs[n]): + does_not_match = True + else: + comparison = filecmp.dircmp(upstream_config_dirs[n], env_config_dirs[n]) + does_not_match = comparison.diff_files or comparison.left_only or comparison.right_only + if does_not_match: + logging.warning( + (f"WARNING: {n} config directories for this environment and upstream " + f"'{upstream_path}' do not match! Verify that you are using the same " + "version of spack-stack, or really, really know what you are doing.") + ) + if self.modifypkg: logging.info("Creating custom repo with packages %s" % ", ".join(self.modifypkg)) env_repo_path = os.path.join(env_dir, "envrepo")