Skip to content

Commit

Permalink
Remove gradle and switch to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
dfitchett committed Dec 11, 2024
1 parent 5e234c7 commit fe13a68
Show file tree
Hide file tree
Showing 8 changed files with 1,201 additions and 49 deletions.
33 changes: 26 additions & 7 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,28 @@ jobs:
- name: "Install Python"
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
python-version: "3.10.12"

- name: "Install dependencies"
- name: Install Poetry
uses: snok/install-poetry@v1

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies if not in cached venv
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install project
run: poetry install --no-interaction

- name: "Source virtual environment"
run: |
python -m pip install --upgrade pip
pip install -r src/requirements.txt
pip install -r src/dev-requirements.txt
source .venv/bin/activate
- name: "Run ruff format"
run: |
Expand All @@ -36,6 +50,11 @@ jobs:
run: |
ruff check src/ tests/
- name: "Run mypy"
run: |
mypy .
- name: "Run tests"
run: |
pytest --cov=src --cov-report=xml
source .venv/bin/activate
pytest --cov=src --cov-report=html
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
hooks:
- id: validate-pyproject

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2

hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/python-poetry/poetry
rev: '1.8.5' # Must be updated manually (see https://python-poetry.org/docs/pre-commit-hooks/#why-does-pre-commit-autoupdate-not-update-to-the-latest-version
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-install

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.13.0'
hooks:
- id: mypy
pass_filenames: false # Pass all files in the repository except those excluded in pyproject.toml
args:
- '.' # Check all files in the repository
- "--config-file=pyproject.toml"
additional_dependencies:
- 'pydantic'
- 'fastapi'
28 changes: 0 additions & 28 deletions build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions gradle.properties

This file was deleted.

1,120 changes: 1,120 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

32 changes: 30 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
requires = ["setuptools >= 70.0.0"]
# pyproject.toml
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra --cov=./src --cov-fail-under=80 --no-cov-on-fail --cov-report=term:skip-covered --cov-report=html:build/reports/coverage --cov-branch"
testpaths = [
"tests"
Expand Down Expand Up @@ -38,5 +36,35 @@ skip-magic-trailing-comma = false

[tool.mypy]
python_version = "3.10"
plugins = ['pydantic.mypy']
strict = true
ignore_missing_imports = true
exclude = [
"scripts",
"tests",
]

[tool.poetry]
name = "disability-max-ratings-api"
version = "0.1.0"
description = "API to get the maximum rating for a collection of disabilities."
readme = "README.md"
license = "LICENSE.md"
package-mode = false

[tool.poetry.dependencies]
python = "3.10.12"
fastapi = "0.115.*"
httpx = "0.24.*"
uvicorn = {version = "0.20.*", extras = ["standard"]}

[tool.poetry.group.dev.dependencies]
mypy = "1.13.*"
pre-commit = "4.0.*"
ruff = "0.8.*"
pytest = "8.3.*"
pytest-cov = "6.0.*"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
6 changes: 0 additions & 6 deletions src/dev-requirements.txt

This file was deleted.

3 changes: 0 additions & 3 deletions src/requirements.txt

This file was deleted.

0 comments on commit fe13a68

Please sign in to comment.