-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devops: Add tox environment that runs tests with sqlite backend #6450
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6450 +/- ##
==========================================
+ Coverage 77.51% 77.85% +0.35%
==========================================
Files 560 566 +6
Lines 41444 42088 +644
==========================================
+ Hits 32120 32765 +645
+ Misses 9324 9323 -1 ☔ View full report in Codecov by Sentry. |
@agoscinski FYI One another improvement that I wanted to do but did not get to is to make |
@agoscinski what is the status for this PR? |
952f11d
to
5b8a0cb
Compare
I wanted to allow that the developer can set an ssh key that is not There are two @pytest.fixture(scope='session')
def ssh_key(tmp_path_factory) -> t.Generator[pathlib.Path, None, None]:
import os
if (ssh_key_path := os.environ.get('AIIDA_PYTEST_SSH_KEY')) is not None:
yield pathlib.Path(ssh_key_path)
else:
yield None # fallback to default key We could move the logic that generates a new key to a new fixture, but I have the impression that it is not really used anywhere, so why bother. Since running these tests requires some global configuration, I would also mark these tests (in the pytest sense) with something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @agoscinski left a few comments
.github/workflows/setup_ssh.sh
Outdated
set -ev | ||
|
||
mkdir -p ${PWD}/.ssh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it this is necessary because you do ${{ github.workspace }}
in the GHA workflow. But wouldn't it be better to use the temporary file system or ${HOME}
as well there? Or do those options not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One can also put the key to some tmp folder, but then one has to add each generated key to authorized_keys which fills up the file over time (as the tmp folder will be deleted). Since the authorized_keys
is a user file that one cannot just be deleted I rather don't do this. So I did the intermediate solution and put it in the project folder. ${HOME}
would also work, maybe this is even better since a project folder might be also deleted frequently.
.github/workflows/setup_ssh.sh
Outdated
set -ev | ||
|
||
ssh-keygen -q -t rsa -b 4096 -N "" -f "${HOME}/.ssh/id_rsa" | ||
ssh-keygen -y -f "${HOME}/.ssh/id_rsa" >> "${HOME}/.ssh/authorized_keys" | ||
mkdir -p ${HOME}/.ssh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not needed
Will check if this work and remove the ssh part into another PR, because it is orthogonal to this one |
88c0ca4
to
92b3cde
Compare
|
||
|
||
def test_aiida_config_tmp(aiida_config_tmp): | ||
def test_aiida_config_tmp(aiida_config_tmp, tmp_path_factory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed to specify for pre-commit
92b3cde
to
5247849
Compare
I removed now the ssh part and will reintroduce this in another PR |
I would still keep the commit structure and merge them as |
955e400
to
24ba7d9
Compare
Thanks @agoscinski . I approve the changes, please rebase the last three commits in the first four and we can rebase merge |
The test compares the timezones between a fixed date and of the current date. This causes problem with time zones that use daylight saving time (DST). Fixing the test makes would add too much complexity for what the test is actually covering. The `make_aware` function is still thoroughly tested by the remaining tests.
pytest's tmp_path and tempfile returns a different directory on macOS Sonoma than tempfile therefore we change the tests tmp_path as it is also used in in the tests to create the config file.
Before the path for `bash` and `cat` path was hardcoded. This has been changed to run a subprocess running `which bash` and `which cat` to determine the path. This is required to for example run the tests on macOS.
24ba7d9
to
8f66720
Compare
tests/engine/test_process_function.py::test_submit_launchers has failed, keeping log in case this becomes important to debug |
Thanks @agoscinski |
The problem with the current tox test environments is that they do require psql database which require a service running in the background. With the merge of #6425, we can use the sqlite backend to run tests more encapsulated with less dependencies on global configurations.
I still need to figure out how to set up a ssh config in a virtual-environment-friendly way. We could just run the
.github/workflow/setup_ssh.sh
file, but then it messes too much with existing ssh configuration. One could add an include in${HOME}/.ssh/config
to include another config file that is stored locally in the tox environment.This just adds one line to the user config, that only works inside the tox environment. So does not have any effect outside of the environment to the functionality of ssh.