39 Commits

Author SHA1 Message Date
ce671f4b10 🐛 Enable virtual env before running poetry
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-14 23:28:49 +01:00
94d87c1c0e 🐛 Fix invalid running directory (part 2)
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-14 23:24:16 +01:00
71f7519b2f 🐛 Fix invalid running directory
Some checks failed
ci/woodpecker/pr/lint Pipeline failed
2024-02-14 23:10:26 +01:00
99aeaae9f2 🚧 Skip the PATH update
Some checks failed
ci/woodpecker/pr/lint Pipeline failed
2024-02-14 23:06:43 +01:00
06d446c3f9 🚧 Edit PATH before loading python virtual env
Some checks failed
ci/woodpecker/pr/lint Pipeline failed
2024-02-14 22:58:04 +01:00
001c7330c6 🎨 Prepare linters environment once
Some checks failed
ci/woodpecker/pr/lint Pipeline failed
2024-02-14 22:49:55 +01:00
d4d24d13d2 🐛 Install poetry for each step
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-13 23:39:46 +01:00
f1cafc7484 🚧 Add dummy commit
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-13 23:05:45 +01:00
30020d17cc 🐛 Fix typo 2024-02-13 23:02:40 +01:00
85bdf2656c 🚧 Comment temporary the backend linter when conditions 2024-02-13 22:56:45 +01:00
fe67cd0d98 🚧 Dummy commit 2024-02-13 22:36:34 +01:00
221125198d 🐛 Image shall be set for each CI step 2024-02-13 22:09:09 +01:00
fe05e2a2c5 🎨 Factorize backend linters steps 2024-02-13 20:57:18 +01:00
f964ba9027 🚧 Add dummy commit to check the reviewdog filter mode
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-12 23:38:34 +01:00
117d549ea7 🚧 Redirect reviewdog stderr to stdout
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 21:38:46 +01:00
529315bf50 🚧 Disable reviewdog filter and create empty .reviewdog.yml file
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 21:31:23 +01:00
35882bda31 🔊 Increase reviewdog logs
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 21:04:22 +01:00
688ffeb7f8 🚧 Add the sqlalchemy dep to the linters poetry group
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 20:14:44 +01:00
0993c42557 🚧 Poetry shell -> poetry run
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 20:02:47 +01:00
2b0eb40ab1 🚧 Run linters in poetry virtual environment
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 19:59:10 +01:00
8082f7f012 🚧 Remove the deps installation and disable mypy caching
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 19:56:18 +01:00
2d9d7c51b5 🚧 Add gcc to the CI image
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 19:52:34 +01:00
63cdbcb46e 🚧 Install dependencies before running the linters
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 19:46:12 +01:00
825a852c67 🚧 Fix reviewdog path
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 19:34:51 +01:00
812d7c0a61 🚧 Format reviewdog command and use temp file
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 19:31:47 +01:00
63abb677cb 🚧 Try to run linters on pull_request event
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 19:13:13 +01:00
a089bbbf78 🔊 Print env variables
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
2024-02-11 19:09:06 +01:00
55401dcd0c 🚧 Add gitea_address secret
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
2024-02-11 19:05:15 +01:00
58c18a0479 🚧 Enable REVIEWDOG_GITEA_API_TOKEN
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 18:54:05 +01:00
2eb8d59a0e 🚧 Fix typo
All checks were successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/push/lint Pipeline was successful
2024-02-11 18:38:47 +01:00
137c28387c 🚧 Fix eviewdog path
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 18:37:23 +01:00
0cddf9dc7e 🚧 Fix reviewdog version and setup ruff
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 18:34:51 +01:00
bccbfe0ff3 🚧 First reviewdog try
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 18:30:43 +01:00
10ecd40ef5 💚 Force the linters to run even if the previous one fails.
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 17:52:28 +01:00
6687c2de15 💚 Run backend linters on commits only
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/pr/lint Pipeline failed
Try to force the linters to run even if the previous one fails.
2024-02-11 17:48:01 +01:00
c8732a0375 Run Mypy linter on backend pull requests
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/pr/lint Pipeline failed
2024-02-11 17:40:06 +01:00
ff808e7c8f 💚 Don't run linters on master, develop and release/* branches
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/pr/lint Pipeline was successful
2024-02-11 17:24:24 +01:00
7ac719db24 👷 Run Ruff linter on back-end pull requests
All checks were successful
ci/woodpecker/manual/lint Pipeline was successful
2024-02-11 17:06:04 +01:00
a8277fd018 👷 First try
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/manual/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
2024-02-03 18:04:09 +01:00
4 changed files with 74 additions and 11 deletions

View File

@@ -0,0 +1,33 @@
when:
- event: pull_request
branch:
exclude: [master, release/*]
steps:
- name: prepare
image: python:3.12-alpine
commands: |
cd ./backend
python3 -m venv local
wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s latest -b ./local/bin/
source ./local/bin/activate
pip install poetry
poetry install --only=linters --no-root
- name: ruff
image: python:3.12-alpine
failure: ignore
secrets: ["reviewdog_gitea_api_token", "gitea_address"]
commands: |
cd ./backend
source ./local/bin/activate
poetry run ruff --output-format sarif . | ./local/bin/reviewdog -f sarif -reporter gitea-pr-review -filter-mode nofilter
- name: mypy
image: python:3.12-alpine
failure: ignore
secrets: ["reviewdog_gitea_api_token", "gitea_address"]
commands: |
cd ./backend
source ./local/bin/activate
poetry run mypy --no-incremental . | ./local/bin/reviewdog -f mypy -reporter gitea-pr-review -filter-mode nofilter

View File

@@ -35,6 +35,26 @@ if TYPE_CHECKING:
logger = getLogger(__name__) logger = getLogger(__name__)
# import cProfile
# import io
# import pstats
# import contextlib
# @contextlib.contextmanager
# def profiled():
# pr = cProfile.Profile()
# pr.enable()
# yield
# pr.disable()
# s = io.StringIO()
# ps = pstats.Stats(pr, stream=s).sort_stats("cumulative")
# ps.print_stats()
# # uncomment this to see who's calling what
# # ps.print_callers()
# print(s.getvalue())
class StopAreaStopAssociations(Base): class StopAreaStopAssociations(Base):
id = mapped_column(BigInteger, primary_key=True) id = mapped_column(BigInteger, primary_key=True)

View File

@@ -18,13 +18,14 @@ from api.routers import line, stop
@asynccontextmanager @asynccontextmanager
async def lifespan(app: FastAPI): async def lifespan(app: FastAPI) -> None:
FastAPICache.init(redis_backend, prefix="api", enable=settings.cache.enable) FastAPICache.init(redis_backend, prefix="api", enable=settings.cache.enable)
await db.connect(settings.db, settings.clear_static_data) await db.connect(settings.db, settings.clear_static_data)
if settings.clear_static_data: if settings.clear_static_data:
await idfm_interface.startup() await idfm_interface.startup()
print("OK")
yield yield
await db.disconnect() await db.disconnect()

View File

@@ -24,6 +24,7 @@ psycopg = "^3.1.9"
pyyaml = "^6.0" pyyaml = "^6.0"
fastapi-cache2 = {extras = ["redis"], version = "^0.2.1"} fastapi-cache2 = {extras = ["redis"], version = "^0.2.1"}
pydantic-settings = "^2.0.3" pydantic-settings = "^2.0.3"
ruff = "^0.2.1"
[tool.poetry.group.db_updater.dependencies] [tool.poetry.group.db_updater.dependencies]
aiofiles = "^22.1.0" aiofiles = "^22.1.0"
@@ -52,28 +53,36 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
pylsp-mypy = "^0.6.2" pylsp-mypy = "^0.6.2"
mccabe = "^0.7.0"
rope = "^1.3.0"
python-lsp-black = "^1.2.1" python-lsp-black = "^1.2.1"
black = "^22.10.0"
types-aiofiles = "^22.1.0.2"
wrapt = "^1.14.1" wrapt = "^1.14.1"
pydocstyle = "^6.2.2"
dill = "^0.3.6" dill = "^0.3.6"
python-lsp-ruff = "^1.0.5" python-lsp-ruff = "^1.0.5"
python-lsp-server = "^1.7.1" python-lsp-server = "^1.7.1"
autopep8 = "^2.0.1"
pyflakes = "^3.0.1"
yapf = "^0.32.0"
whatthepatch = "^1.0.4"
mypy = "^1.0.0"
icecream = "^2.1.3" icecream = "^2.1.3"
[tool.poetry.group.linters.dependencies]
autopep8 = "^2.0.1"
black = "^22.10.0"
mccabe = "^0.7.0"
mypy = "^1.0.0"
pydocstyle = "^6.2.2"
pyflakes = "^3.0.1"
rope = "^1.3.0"
ruff = "^0.2.1"
types-aiofiles = "^22.1.0.2"
types-sqlalchemy-utils = "^1.0.1" types-sqlalchemy-utils = "^1.0.1"
types-pyyaml = "^6.0.12.9" types-pyyaml = "^6.0.12.9"
types-tqdm = "^4.65.0.1" types-tqdm = "^4.65.0.1"
whatthepatch = "^1.0.4"
yapf = "^0.32.0"
sqlalchemy = "^2.0.26"
[tool.mypy] [tool.mypy]
plugins = "sqlalchemy.ext.mypy.plugin" plugins = "sqlalchemy.ext.mypy.plugin"
exclude = ['docker', 'docs']
strict = true
[tool.black] [tool.black]
target-version = ['py311'] target-version = ['py311']