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

Run examples using pytest + optimize CI setup #675

Merged
merged 48 commits into from
Jun 19, 2023

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented May 12, 2023

Description

Closes #641

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label May 12, 2023
git diff --exit-code
package-name: ${{ github.event.repository.name }}
subdir: ${{ matrix.subdir }}
anaconda-org-channel: ctools
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we change to conda-canary here? xref #612

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link

Choose a reason for hiding this comment

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

Still TODO?

@@ -314,7 +314,7 @@ def main():
logger.info("Got the following cli arguments: '%s'", args)

if args.verbose or args.debug:
logger.setLevel(logging.DEBUG)
logging.getLogger("constructor").setLevel(logging.DEBUG)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes a few logging issues (because the level was only set to constructor.main, other modules didn't have the right level set).

@@ -20,6 +21,17 @@
logger = logging.getLogger(__name__)


def calculate_install_dir(yaml_file, subdir=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Utility function needed in tests.

@jaimergp jaimergp marked this pull request as ready for review May 30, 2023 16:26
@jaimergp jaimergp requested a review from a team as a code owner May 30, 2023 16:26
@jaimergp
Copy link
Contributor Author

This PR is now ready for review. Hopefully it makes testing and debugging simpler / less surprising. Adding new examples is now a matter of adding a test_* function in test_examples. The infra has been set up so the boilerplate is minimal.

cc @conda/constructor - thanks (and apologies) in advance, this one is a bit large 😬

Copy link

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Already looks like a great improvement! Just a few comments

git diff --exit-code
package-name: ${{ github.event.repository.name }}
subdir: ${{ matrix.subdir }}
anaconda-org-channel: ctools
Copy link

Choose a reason for hiding this comment

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

Still TODO?

tests/test_examples.py Show resolved Hide resolved
_run_installer(input_path, installer, install_dir, request=request)


def test_example_shortcuts(tmp_path, request):
Copy link

@larsoner larsoner Jun 6, 2023

Choose a reason for hiding this comment

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

For these I would have expected a parametrize over the _example_paths. Assuming that function returns filenames quickly it seems fine to refactor this way and would give more complete failure reporting for example if a change breaks multiple examples. It also would allow selecting tests by the example filename because that would show up in the resulting test name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it but I would expect a future where different examples have different tests in pytest instead of those post_install tests we have right now (which are a bit hacky imo).

Some examples are not tested either, so we would have needed to explicitly write the example list (instead of the very attractive os.listdir), or implement the allow-list / deny-list we have in the current scripts/run_examples.py. I hope it's ok we leave it as it is now, even if a bit boilerplate-y 😬

I tried to use the example names in the function name precisely to allow easy selection but perhaps I missed some?

tests/test_examples.py Outdated Show resolved Hide resolved
marcoesters
marcoesters previously approved these changes Jun 15, 2023
Copy link
Contributor

@marcoesters marcoesters left a comment

Choose a reason for hiding this comment

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

I've been going back and forth on whether to change the boiler-plate code into paramatrized tests.

However, I think Jaime has a point that there is potential that the tests become more involved, especially if there are plans to replace the test_install.* scripts.

It's a good first step. However, I think my comment should be implemented before merging.

@jaimergp jaimergp mentioned this pull request Jun 19, 2023
31 tasks
@jaimergp jaimergp merged commit 3bb9c98 into conda:main Jun 19, 2023
14 of 15 checks passed
@github-actions github-actions bot added the locked [bot] locked due to inactivity label Jun 19, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed [bot] added once the contributor has signed the CLA locked [bot] locked due to inactivity
Projects
Archived in project
5 participants