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

Change GH actions linting to use pyinvoke #41

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 100
extend-ignore = E203
7 changes: 6 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- name: "Upgrade pip"
run: "pip install --upgrade pip"
- name: "Install package"
run: pip install ".[dev]"
- name: "Run lint checks"
run: invoke lint
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM python:3.11-bullseye

WORKDIR /opt/meshdb
COPY requirements.txt .
RUN pip install -r requirements.txt

# FIXME: This probably isn't the file structure we want.
COPY . .
RUN pip install .

ENTRYPOINT gunicorn api:app --bind=0.0.0.0:8080
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,31 @@ python3 -m venv .venv
source .venv/bin/activate
```

Next, install the project dependencies
Next, install the project dependencies, including dev dependencies
```sh
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -e ".[dev]"
```

Finally, run `pytest`:
```
pytest
```


## Invoke.py Commands

For convenience, this package uses [invoke](https://www.pyinvoke.org/) to wrap common
tasks into one-line commands. For example:

```sh
invoke format
```

Will automatically apply `black` formatting and `isort` import sorting in a single command.

You can also quickly peform all the relevant lint checks locally using
```sh
invoke lint
```

See `tasks.py` for a complete list of the tasks available.
54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[project]
name = "nycmesh-meshdb"
version = "0.1"
dependencies = [
"Flask==2.3.2",
"gunicorn==21.2.*",
"SQLAlchemy==2.0.20",
"SQLAlchemy_Utils==0.41.1",
"psycopg2-binary==2.9.*",
"python-dotenv==1.0.*",
"stringcase==1.2.*"
]


[project.optional-dependencies]
dev = [
"invoke == 2.2.*",
"pytest == 7.4.*",
"flake8 == 6.1.*",
"black == 23.7.*",
"isort == 5.12.*",
"mypy == 1.5.*"
]


[build-system]
requires = [ "setuptools >= 61", "wheel", "mypy" ]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = [ "meshdb" ]


[tool.mypy]
check_untyped_defs = true
show_error_codes = true
pretty = true
ignore_missing_imports = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
warn_unused_configs = true


[tool.black]
line-length = 100
include = '\.pyi?$'


[tool.isort]
profile = "black"
line_length = 100
known_first_party = [ "meshdb" ]

1 change: 0 additions & 1 deletion requirements-dev.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

20 changes: 20 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from invoke import task


@task
def format(context):
context.run("black .")
# context.run("isort .")


@task
def lint(context):
context.run("black . --check")
# context.run("isort . --check")
# context.run("flake8 meshdb tests unit_tests")
# context.run("mypy meshdb")


@task
def unit_test(context):
context.run("pytest unit_tests/")