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

Switch to pip-tools for managing dependencies #281

Merged
merged 8 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
python-version: 3.9
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/local.txt
requirements/requirements.txt
requirements/test-requirements.txt

# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
Expand Down Expand Up @@ -75,13 +75,14 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/local.txt
requirements/requirements.txt
requirements/test-requirements.txt

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/local.txt
pip install pip-tools
pip-sync requirements/requirements.txt requirements/test-requirements.txt

- name: Run tests
run: coverage run -p -m pytest
Expand All @@ -108,13 +109,14 @@ jobs:
python-version: 3.8
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/local.txt
requirements/requirements.txt
requirements/test-requirements.txt

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/local.txt
pip install pip-tools
pip-sync requirements/requirements.txt requirements/test-requirements.txt

- name: Run tests
run: coverage run -p -m pytest
Expand Down
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
- activate virtualenv: source venv/bin/activate
- clone repository
- cd into project root dir
- python -m pip install -r requirements/local.txt
- python -m pip install pip-tools
- pip-sync requirements/requirements.txt requirements/test-requirements.txt requirements/dev-requirements.txt
- python manage.py migrate
- python manage.py createsuperuser
- python manage.py runserver_plus
Expand Down Expand Up @@ -86,19 +87,31 @@ Running tests with pytest and unittest

1. git checkout -b \<feature_branch_name\> (Create and switch to
feature branch)
2. make changes, test changes, document changes, commit often
3. run tests: pytest, python manage.py test
4. test coverage: (see above)
5. type checks: mypy primed
6. git add your changes
7. manually run pre-commit if you did not install
8. git commit your changes
9. repeat steps 3-8
10. merge in any changes to main
2. sync requirements: `pip-sync requirements/requirements.txt test-requirements.txt dev-requirements.txt`
3. make changes, test changes, document changes, commit often
4. run tests: pytest, python manage.py test
5. test coverage: (see above)
6. type checks: mypy primed
7. git add your changes
8. manually run pre-commit if you did not install
9. git commit your changes
10. repeat steps 3-8
11. merge in any changes to main
1. git checkout main
2. git pull
3. git checkout \<feature_branch_name\>
4. git rebase main
10. git push origin \<feature_branch_name\>
11. review or request review of changes in github
12. submit pull request in github
12. git push origin \<feature_branch_name\>
13. review or request review of changes in github
14. submit pull request in github


### Compiling requirements files

Requriements files must be compiled in the correct order to handle layering.

```
pip-compile requirements/requirements.in
pip-compile requirements/test-requirements.in
pip-compile requirements/dev-requirements.in
```
49 changes: 0 additions & 49 deletions requirements/base.txt

This file was deleted.

33 changes: 33 additions & 0 deletions requirements/dev-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-c requirements.txt
-c test-requirements.txt

Werkzeug # https://github.com/pallets/werkzeug
ipdb # https://github.com/gotcha/ipdb

# Testing
# ------------------------------------------------------------------------------
mypy # https://github.com/python/mypy
django-stubs # https://github.com/typeddjango/django-stubs
types-requests

# Documentation
# ------------------------------------------------------------------------------
sphinx # https://github.com/sphinx-doc/sphinx
sphinx-autobuild # https://github.com/GaretJax/sphinx-autobuild

# Code quality
# ------------------------------------------------------------------------------
flake8 # https://github.com/PyCQA/flake8
flake8-isort # https://github.com/gforcada/flake8-isort
black # https://github.com/psf/black
pylint-django # https://github.com/PyCQA/pylint-django
pre-commit # https://github.com/pre-commit/pre-commit

# Security
# ------------------------------------------------------------------------------
safety # https://github.com/pyupio/safety
setuptools # https://github.com/pypa/setuptools

# Django
# ------------------------------------------------------------------------------
django-debug-toolbar # https://github.com/jazzband/django-debug-toolbar
Loading