chore: add pre-commit

This commit is contained in:
cătălin 2023-12-08 17:08:03 +01:00
commit 72ee09b064
Signed by: catalin
GPG key ID: 0178DF42F43E5FD2
8 changed files with 40 additions and 13 deletions

28
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,28 @@
files: ^secretsanta|apps|tests$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
args: [ --markdown-linebreak-ext=md ]
- id: end-of-file-fixer
- id: check-ast
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
- id: check-toml
- id: debug-statements
- id: mixed-line-ending
args: [ --fix=lf ]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
- id: ruff-format

View file

@ -1,14 +1,14 @@
install:
@echo "Installing pdm packages"
@. pdm install
@echo "Installing node packages"
@. cd apps/http/sls npm i
run--sls: run--sls:
@echo "Activating virtual environment and starting serverless offline" @echo "Activating virtual environment and starting serverless offline"
@. .venv/bin/activate && cd apps/http/sls && npx sls offline @. .venv/bin/activate && cd apps/http/sls && npx sls offline
deploy--sls: deploy--sls:
@echo "Deploying via serverless framework" @echo "Deploying via serverless framework"
@. cd apps/http/sls && pdm export -G sls -f requirements --prod > requirements.txt && npx sls deploy @. cd apps/http/sls && pdm export -G sls -f requirements --prod > requirements.txt && npx sls deploy
lint:
pre-commit run --all-files --color always
tests--unit:
pdm run pytest --cov secretsanta tests
coverage html

View file

@ -109,4 +109,4 @@ components:
type: object type: object
properties: properties:
pair: pair:
type: string type: string

View file

@ -5,4 +5,4 @@
"dev": { "dev": {
} }
} }
} }

View file

@ -241,4 +241,3 @@ yarl==1.9.4 \
--hash=sha256:e23a6d84d9d1738dbc6e38167776107e63307dfc8ad108e580548d1f2c587f42 \ --hash=sha256:e23a6d84d9d1738dbc6e38167776107e63307dfc8ad108e580548d1f2c587f42 \
--hash=sha256:ea65804b5dc88dacd4a40279af0cdadcfe74b3e5b4c897aa0d81cf86927fee78 \ --hash=sha256:ea65804b5dc88dacd4a40279af0cdadcfe74b3e5b4c897aa0d81cf86927fee78 \
--hash=sha256:ee04010f26d5102399bd17f8df8bc38dc7ccd7701dc77f4a68c5b8d733406958 --hash=sha256:ee04010f26d5102399bd17f8df8bc38dc7ccd7701dc77f4a68c5b8d733406958

View file

@ -70,4 +70,4 @@ functions:
events: events:
- httpApi: - httpApi:
path: /api/v1/groups/{group_uuid}/pair/{participant} path: /api/v1/groups/{group_uuid}/pair/{participant}
method: get method: get

View file

@ -33,6 +33,7 @@ chalice = [
sls = [ sls = [
"anyio>=4.1.0", "anyio>=4.1.0",
] ]
[build-system] [build-system]
requires = ["pdm-backend"] requires = ["pdm-backend"]
build-backend = "pdm.backend" build-backend = "pdm.backend"

View file

@ -2,7 +2,6 @@ import json
from contextlib import asynccontextmanager from contextlib import asynccontextmanager
import aioboto3 import aioboto3
import botocore
from botocore.exceptions import ClientError from botocore.exceptions import ClientError
from secretsanta.domain import Group, IRepo from secretsanta.domain import Group, IRepo