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

Upgrade django and python versions #189

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
61 changes: 61 additions & 0 deletions .github/workflows/drip-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Django Drip Coverage

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
test:
runs-on: ubuntu-latest

env:
# Set the secret for the code coverage tool
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

strategy:
matrix:
python-version: ["3.12"]

steps:
# Check out the code from the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up Python environment
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install django==4.2
pip install -r requirements/github-actions-requirements.txt

# Prepare code coverage reporting
- name: Install Code Climate Test Reporter
run: |
pip install codeclimate-test-reporter

# Run tests
- name: Run tests with coverage
run: |
coverage run -m pytest .
coverage report --fail-under=90 -m
coverage xml

# Upload coverage data to Code Climate
- name: Setup Code Climate test-reporter
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
./cc-test-reporter after-build --coverage-input-type coverage.py --exit-code $?
85 changes: 0 additions & 85 deletions .github/workflows/drip-django.yaml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/drip-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Django Drips Tests

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
django-version: ["4.2", "5.0"]
# Exclude incompatible combinations (if Django 5.0 does not support older Python versions)
exclude:
- python-version: "3.8"
django-version: "5.0"
- python-version: "3.9"
django-version: "5.0"

steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3

# Set up the Python environment based on the matrix versions
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install django==${{ matrix.django-version }}
pip install -r requirements/github-actions-requirements.txt
# Run tests
- name: Install coverage codeclimate
run: |
pytest .
107 changes: 94 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,103 @@
*.pyc
MANIFEST
#pyenv
.python-version

dist/
.tox/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
docs/_build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.idea/
.installed.cfg
*.egg
MANIFEST

sqlite.db
settings.py
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

env*
# Installer logs
pip-log.txt
pip-delete-this-directory.txt

__pycache__
# Virtualenv
# If you use a virtualenv, it's better to ignore its directory.
venv/
ENV/
env/
.venv/
.pyenv/

*DS_Store
# tox
.tox/
.cache/
.coverage
nosetests.xml
coverage.xml
*.cover
.hypothesis/

.vscode
# mypy
.mypy_cache/
.dmypy.json
dmypy.json

#pyenv
.python-version
# Pytest cache
.pytest_cache/

# Django specific
*.log
db.sqlite3
media/
staticfiles/

# Ignore migrations files (optional, you might want to track migrations in OSS)
# **/migrations/

# Ignore Django secret key file (if it exists)
.env
.env.*

# celery beat schedule file
celerybeat-schedule

# macOS
.DS_Store

# System files
Thumbs.db
desktop.ini

# Jupyter Notebook
.ipynb_checkpoints/

# IDEs
.vscode/
.idea/
*.sublime-workspace
*.sublime-project

# Documentation artifacts
docs/_build/

# SQLite
sqlite.db
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,51 @@ People _love_ thorough bug reports. I'm not even kidding.
- ### How is this different from what you are currently doing?
- ### Possible implementation

## How to develop locally and run the tests

We recommend you to use:

- [pyenv](https://github.com/pyenv/pyenv): To easily install and manage different versions of Python.
- [pipenv](https://pipenv.pypa.io/en/latest/): To create and manage Python virtual environments.

The Python version we recommend to develop with: The latest (currently 3.12) but avoiding (if possible) to use elements
that are exclusively from that version and don't work in previous versions. This is because we want to be compatible
with older versions of Python.

### Python versions we are currently testing (Sept, 2024)

- 3.8.19
- 3.9.19
- 3.10.14
- 3.11.9
- 3.12.4

### Step by step to run the tests

1. Install with pyenv the different versions of Python, so you can use the latest to develop, and the other ones to
run the tests and check that the compatibility with older versions continues.
- `pyenv install <python version>`
- Run this for each version.
2. Go to the project folder in the terminal.
3. Set the versions of python to be locally available in the folder:
- `pyenv local 3.8.19 3.9.19 3.10.14 3.11.9 3.12.4`
- This will create a gitignored file called `.python-version` listing these versions.
4. Create the virtual environment using the latest version:
- `pipenv install --python 3.12.4`
- This will create and install in it the base and dev requirements. You can check this on the Pipfile.
5. Enter the virtual environment:
- `pipenv shell`
6. Run the tests:
- `pytest .`
- They should pass without errors.
7. Now run the tox command that will run the tests using different versions of python:
- `tox`
- This will run the tests with different Python versions using the `tox.ini` file.
- It will install the base requirements from the `install_requires` list in the `setup.py` file, and the dev requirements
from the `test-requirements.txt` file that has the list of the needed dev libraries.
- You will see the tests execution for each version of Python.
- You can run `tox -v` to see more details.

## Use a Consistent Coding Style

I'm again borrowing these from [Rootstrap Tech Guides](https://github.com/rootstrap/tech-guides/tree/master/python)
Expand Down
Loading
Loading