Conversation
78534c8 to
325fd2d
Compare
…iles and push to buildcache
…e spack-config relink step, add correct spack-packages-repository-path
325fd2d to
57affb8
Compare
d7f873d to
91d9e95
Compare
Member
Author
|
Hmm...currently we activate the environment in the CI before we run @pytest.fixture(autouse=True)
def spack_env(pytestconfig):
spack_env_path: str | None = pytestconfig.getoption("spack_env_path", default=None)
if not spack_env_path:
# Don't use this fixture if the spack_env_path is not set
return
# Reference the default environment the packages were installed in, before each test
env: spack.environment.Environment = spack.environment.Environment(
spack_env_path
)
# Activate the spack environment, and collect the users environment variable modifications
env_activate_mods = spack.environment.shell.activate(env)
# Apply the environment variable modifications to the user
env_activate_mods.apply_modifications()
if not env.active:
raise RuntimeError(
f"Couldn't activate the default environment at {spack_env_path}"
)
# Return control to the test
yield
# Once the above completes, deactivate the environment and collect the now-reversed user environment modifications
env_deactivate_mods = spack.environment.shell.deactivate()
# Apply those modifications so we're now back where we started!
env_deactivate_mods.apply_modifications() |
17e67d7 to
efb73a3
Compare
efb73a3 to
f432b6c
Compare
9d346b7 to
1772428
Compare
9c316a9 to
61b3de6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #193
Background
Right now, we install the component manifests but don't do any testing outside of the installation status of
spack. We need a framework for post-build testing, and right now we're going withpytestdue to the strength of test specification via--markers, it's use as a testing meta-framework in other repositories such asACCESS-NRI/model-config-tests, and it's integration with GitHub Actions.Essentially we will have a second job (
Test) after the first (Install), that will reinstall the lockfile via a buildcache, then discover all tests in the MCR, and run them. Users can specify args topytestat the manifest level via a reserved definition_pytest-args, like so:Note
The exact machinations of pytest discovery will be based on the resolution of #298
The PR
test-builddependent job in theci.ymlworkflow that install the previously installed-and-pushed packages from the lockfile, then runspytestpytestare given at the manifest level via a_pytest-argsreserved definition in the manifest..github/actions/setup-instanceaction.Testing
Proof of Concept
Tested in ACCESS-NRI/access-test-component#19, specifically https://github.com/ACCESS-NRI/access-test-component/actions/runs/24760630710?pr=19. Note the tests under
.github/build-ci/tests, discovered byinputs.pytest-search-path(as hidden directories aren't found traditionally.Also note the reading of reserved definitions, for example written in https://github.com/ACCESS-NRI/access-test-component/pull/19/changes#diff-b5e432583957cd6026f987a7ddf4b2df3a0daab1e7afd40293562f16c0d6b4b1R3 and added successfully in https://github.com/ACCESS-NRI/access-test-component/actions/runs/24760630710/job/72443635335#step:11:8.
Installation in the test job is much quicker when using a lockfile and
spack install --use-cache- possibly because we skip concretization and go to querying the buildcache immediately - from 2m with perfect reuse in the initial install job to 20s with perfect reuse in the later test job.