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

chore: bump python to 3.12, bump linters #98

Merged
merged 1 commit into from
Oct 16, 2024
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
90 changes: 45 additions & 45 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,62 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.12'
# because pre-commit uses external mypy
- name: install mypy
run: |
pip install poetry
poetry config virtualenvs.create false
poetry install --only main,typecheck
- name: install mypy
run: |
pip install poetry
poetry config virtualenvs.create false
poetry install --only main,typecheck
# https://github.com/typeddjango/django-stubs/issues/458
- name: create .env file
run: cp example.env .env
- uses: pre-commit/action@v3.0.0
- name: create .env file
run: cp example.env .env
- uses: pre-commit/action@v3.0.0

unit_test:
needs: [ lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install poetry
poetry config virtualenvs.create false
poetry install --only main
- name: create .env file
run: cp example.env .env
- name: Run tests
env:
SECRET_KEY: secret
DB_ENGINE: django.db.backends.sqlite3
run: |
cd src
python manage.py makemigrations --check
python manage.py migrate
python manage.py test tests/
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
pip install poetry
poetry config virtualenvs.create false
poetry install --only main
- name: create .env file
run: cp example.env .env
- name: Run tests
env:
SECRET_KEY: secret
DB_ENGINE: django.db.backends.sqlite3
run: |
cd src
python manage.py makemigrations --check
python manage.py migrate
python manage.py test tests/

docker:
needs: [ lint, unit_test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build docker image
run: |
docker pull $IMAGE_NAME
docker build --pull --cache-from $IMAGE_NAME -t $IMAGE_NAME:latest .
- uses: actions/checkout@v4
- name: Build docker image
run: |
docker pull $IMAGE_NAME
docker build --pull --cache-from $IMAGE_NAME -t $IMAGE_NAME:latest .

- name: Log in into Docker Hub
if: ${{ github.event_name == 'push' }}
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Log in into Docker Hub
if: ${{ github.event_name == 'push' }}
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Push image to registry
if: ${{ github.event_name == 'push' }}
run: |
docker push $IMAGE_NAME
- name: Push image to registry
if: ${{ github.event_name == 'push' }}
run: |
docker push $IMAGE_NAME
29 changes: 14 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: ruff-format
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -24,12 +16,19 @@ repos:
exclude: >-
^.*.md$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format

# local mypy because of stub dependencies
- repo: local
hooks:
- id: typecheck
name: Typecheck
entry: mypy .
types: [python]
language: system
pass_filenames: false
- id: typecheck
name: Typecheck
entry: mypy .
types: [python]
language: system
pass_filenames: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-alpine3.19
FROM python:3.12-alpine3.20

# in order:
# proper stdout flushing for alpine
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Copy `example.env` to `.env` and customize it. You can then start development by

### Setting up python to run the project locally

You will need python 3.11+
You will need python 3.12+

<details>
<summary>Extra steps if don't want to install poetry globally for some reason</summary>
Expand Down
50 changes: 26 additions & 24 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 32 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
[tool.poetry]
name = "central-command"
version = "0.1.0"
description = "All-in-one backend application for Unitystation"
authors = ["Andrés Riquelme <andresfranco.rs@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.12"
Django = "^3.2.12"
djangorestframework = "^3.12.1"
psycopg2-binary = "2.9.9"
django-rest-knox = "^4.1.0"
gunicorn = "^20.1.0"
python-dotenv = "^0.19.2"
whitenoise = "^6.2.0"
django-post-office = "^3.8.0"
drf-spectacular = "^0.27.1"

[tool.poetry.group.lint.dependencies]
pre-commit = "4.0.1"
ruff = "0.6.9"

# typecheck is separate for CI
[tool.poetry.group.typecheck.dependencies]
mypy = "1.*"
django-stubs = {extras = ["compatible-mypy"], version = "4.*"}
djangorestframework-stubs = {extras = ["compatible-mypy"], version = "3.*"}

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
exclude = ["migrations"]
line-length = 121
Expand Down Expand Up @@ -83,35 +115,3 @@ module = [
"knox.*",
]
ignore_missing_imports = true

[tool.poetry]
name = "central-command"
version = "0.1.0"
description = "All-in-one backend application for Unitystation"
authors = ["Andrés Riquelme <andresfranco.rs@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.11"
Django = "^3.2.12"
djangorestframework = "^3.12.1"
psycopg2-binary = "2.9.9"
django-rest-knox = "^4.1.0"
gunicorn = "^20.1.0"
python-dotenv = "^0.19.2"
whitenoise = "^6.2.0"
django-post-office = "^3.8.0"
drf-spectacular = "^0.27.1"

[tool.poetry.group.lint.dependencies]
pre-commit = "3.*"
ruff = "0.3.*"

# typecheck is separate for CI
[tool.poetry.group.typecheck.dependencies]
mypy = "1.*"
django-stubs = {extras = ["compatible-mypy"], version = "4.*"}
djangorestframework-stubs = {extras = ["compatible-mypy"], version = "3.*"}

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Loading