Skip to content
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

CI: move time consuming tests to separate workflow that runs nightly #5354

Merged
merged 2 commits into from
Feb 16, 2022

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Feb 16, 2022

The test that runs the Reverse Polish Notation (RPN) workchains and the
migrations tests are relatively time consuming and they should not be
affected by most commits. That's why we can afford to have them just run
nightly instead of on every PR.

A nightly GHA workflow is added that runs every day at midnight. It
runs a bash script tests_nightly.sh that in turns runs the script
test_polish_workchains.sh as well as the unit test using pytest. The
latter is called with the option -m 'nightly' which will select only
tests that are marked as nightly.

All tests under tests/backends/aiida_sqlalchemy/migrations are marked
as nightly dynamically through the pytest_collection_modifyitems
function in the tests/backends/aiida_sqlalchemy/migrations/conftest.py
configuration file.

@sphuber sphuber requested a review from chrisjsewell February 16, 2022 17:20
@chrisjsewell
Copy link
Member

chrisjsewell commented Feb 16, 2022

All tests under tests/backends/aiida_sqlalchemy/migrations are marked
as nightly

As mentioned, the only issue here is that, this is can going to kill code coverage of unit tests

Even if we do add some, I don't think we should mark all migration tests as nightly.

It should at most be:

def test_django(version, uninitialised_profile, reflect_schema, data_regression):

def test_sqla(_id, version, uninitialised_profile, reflect_schema, data_regression):

and the tests under tests/backends/aiida_sqlalchemy/migrations/django_branch/ and tests/backends/aiida_sqlalchemy/migrations/sqlalchemy_branch/

i.e. only ones that relate to "legacy" migrations

@sphuber
Copy link
Contributor Author

sphuber commented Feb 16, 2022

As mentioned, the only issue here is that, this is can going to kill code coverage of unit tests

I don't think this should be a problem though. Sure the coverage percentage reported by Codecov will be a few points lower, but we know that the code is still being covered, just not at every commit. That is the whole point of this change though. We discussed and agreed that the tests were starting to take way too long and it would make sense to split off those tests that don't require being run at every commit. I don't think we should be led in this discussion by the percentage reported by Codecov. That is just an indicator.

Even if we do add some, I don't think we should mark all migration tests as nightly.
It should at most be:
...
i.e. only ones that relate to "legacy" migrations

That is fair enough. But that is essentially the entire directory which I mark now, except for test_main and test_head_vs_orm in test_all_schema. The test_alembic_cli as well, but that should really not be part of the migrations directory but moved one up.
If you are happy with that compromise, I can add those changes.

@chrisjsewell
Copy link
Member

I don't think we should be led in this discussion by the percentage reported by Codecov.

We are never going to get 100% test coverage with that attitude 😛

If you are happy with that compromise, I can add those changes.

Yeh sounds good

@sphuber
Copy link
Contributor Author

sphuber commented Feb 16, 2022

We are never going to get 100% test coverage with that attitude

Just have to wait until we drop the legacy migrations 😄

The test that runs the Reverse Polish Notation (RPN) workchains and the
migrations tests are relatively time consuming and they should not be
affected by most commits. That's why we can afford to have them just run
nightly instead of on every PR.

A `nightly` GHA workflow is added that runs every day at midnight. It
runs a bash script `tests_nightly.sh` that in turns runs the script
`test_polish_workchains.sh` as well as the unit test using `pytest`. The
latter is called with the option `-m 'nightly'` which will select only
tests that are marked as nightly.

Most tests under `tests/backends/aiida_sqlalchemy/migrations` are marked
as nightly. This is done by applying the `@pytest.mark.nightly` decorator
directly to the test functions. For the tests under the `django_branch`
and `sqlalchemy_branch` this is instead done dynamically through the
`pytest_collection_modifyitems` function in the `conftest.py` module
since having to manually apply this to all test would be too tedious.
@sphuber
Copy link
Contributor Author

sphuber commented Feb 16, 2022

Yeh sounds good

Done!

Copy link
Member

@chrisjsewell chrisjsewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can merge this next cheers 👍

@sphuber sphuber merged commit 5d2f153 into aiidateam:develop Feb 16, 2022
@sphuber sphuber deleted the fix/ci-add-nightly branch February 16, 2022 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants