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

Standardize development dependencies / refactor GHA workflow #153

Merged
merged 6 commits into from
Jun 18, 2024

Conversation

tillprochaska
Copy link
Contributor

@tillprochaska tillprochaska commented Feb 1, 2024

This PR contains a few changes loosely related to the management of development dependencies and the CI setup.

I initially started out trying to install development dependencies locally, but neither pip install -e .[dev] nor pip install -r requirements-dev.txt alone were enough as some dependencies are only specified in the dev extra and others only in the requirements file.

As there seems to be a preference towards using requirements-dev.txt vs. a dev extra for development dependencies, I’ve added any dependencies listed in the dev extra to requirements-dev.txt and removed the dev extra so that we only have one list of dev dependencies to maintain.

Along the way I noticed a few quirks with the setup of the GitHub Actions workflow which made it difficult to reproduce and debug issues so I’ve tried to clean up the setup a little bit by removing unnecessary steps (see commit messages for details). Some of these changes are probably a little opinionated, so feel free to object if you don't like them.

Pointing out two changes here explicitly as they might impact your preferred workflows:

  • I’ve changed the Docker base image to a Python slim image -- this helps bring down CI run times from ~3 mins to ~1 min, but it means that some CLI utils will not be installed by default. Not sure if this is an issue?

  • The make test target doesn’t run pytest in a new container by default. Instead you’d have to run docker compose run --rm shell make test (or something like dcr shell make test if you set up an alias). Or you just keep a container shell session open while developing and run make test inside of that.

@tillprochaska tillprochaska force-pushed the fix/dev-dependencies branch 3 times, most recently from 9ae3dbf to ba5f314 Compare February 1, 2024 11:42
@tillprochaska tillprochaska marked this pull request as ready for review February 1, 2024 11:43
@tillprochaska tillprochaska requested review from catileptic and stchris and removed request for catileptic February 1, 2024 11:43
@tillprochaska tillprochaska marked this pull request as draft February 1, 2024 11:49
@tillprochaska tillprochaska force-pushed the fix/dev-dependencies branch 9 times, most recently from 27c61ed to ed8d2a5 Compare February 2, 2024 11:57
@tillprochaska tillprochaska marked this pull request as ready for review February 2, 2024 11:59
@tillprochaska tillprochaska changed the title Standardize development dependencies Standardize development dependencies / refactor GHA workflow Feb 2, 2024

dev:
python3 -m pip install --upgrade pip setuptools
python3 -m pip install -q -r requirements.txt
python3 -m pip install -q -r requirements-dev.txt

test:
docker-compose run --rm shell pytest --cov=servicelayer
pytest --cov=servicelayer
Copy link
Contributor

Choose a reason for hiding this comment

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

test:
	docker-compose run --rm shell pytest --cov=servicelayer
test-local:
	pytest --cov=servicelayer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

There seems to be a preference towards using `requirements-dev.txt` vs. a `dev` extra for development dependencies, but right now neither `pip install -r requirements-dev.txt` nor `pip install -e ".[dev]" is enough to install all development dependencies.

I’ve added any dependencies listed in the `dev` extra to `requirements-dev.txt` and removed the `dev` extra so that we only have one list of dev dependencies to maintain.

This also pins the `moto` package (used to mock S3 in tests) to version 4.x as version 5 release a few days ago contains breaking changes.
This seems to be left over from when we still used to run tests directly in GHA runners.
Tests in `test_extensions.py` rely on `servicelayer` being installed as they ultimately read information from the egg info that is created during installation.

This is basically equivalent to the previous setup which executed `pip install -e .` outside of the container. As the entire directory is mounted into the container, the egg info subsequently was also available inside of the container. While that worked I found the fact that installing something outside of the container could make the tests fail or pass quite confusing. This should be a little more explicit.
Running some steps outside and some inside of the container leads to weird behavior, e.g. when file permissions/owners do not match across steps.
This uses a pre-built Python image based on Debian as this should be much faster than building a custom image on top of a full-feature Ubuntu.
@tillprochaska tillprochaska merged commit d242b89 into main Jun 18, 2024
1 check passed
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