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

Restructure project by flattening directories and add CI which runs tests with pytest #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

EwoutH
Copy link

@EwoutH EwoutH commented Sep 19, 2022

This PR does two things, in two commits:

  1. The first commit restructures the project by flattening the directory structure. This follows the best practice as documented in Structuring Your Project. This practically means:
    • src/pydsol/core becomes pydsol
    • tests/pydsol/core becomes tests
  2. This adds a continous integration (CI) configuration for GitHub Actions that runs all tests with Python. Currently Python 3.8, 3.9 and 3.10 are tested on Ubuntu, as wel as 3.10 on macOS and Windows, on each push and pull request as well as once a week.

This makes running pytest as easy as running python -m pytest. The CI configuration worked on the first try, which I can tell you rarely happens. Using a wide-adopted project structure also makes packaging (to PyPI for example) also a lot easier.

Note that the CI already catched an interesting error: While Python 3.9 and 3.10 passes the tests perfectly fine, 3.8 won't work because a lot of TypeError: 'type' object is not subscriptable errors. As you probably know this has to do with Python 3.8 and earlier not supporting this type hinting functionality (link).

This is not documented in the docs and not specified in a python_requires variable, and can keep less experienced users stuck wondering why their code keeps producing errors and tests don't pass.

Anyway, just a quick proof of concept, please let me know what you think of it and if you would like any changes.

src/pydsol/core/ becomes pydsol
tests/pydsol/core becomes tests

This follows the best practice as documented in https://docs.python-guide.org/writing/structure/ and https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html
Creates an initial CI configuration that runs the tests on Python 3.8, 3.9 and 3.10 and on Ubuntu, macOS and Windows in a sparse configuration. It uses pytests running the tests and the job is triggered on each push, pull request, weekly at Monday 06:00 UTC and when manually triggered.
@EwoutH
Copy link
Author

EwoutH commented Sep 26, 2022

@averbraeck What do you think?

@EwoutH
Copy link
Author

EwoutH commented Mar 1, 2023

@averbraeck Congratulations on the 4.0 release!

Let me know if you find any of these changes useful. If so, I will open a new PR with them, otherwise I will close this PR.

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.

1 participant