Skip to content

Commit

Permalink
Merge branch 'main' into rename-internal-recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
jsangmeister committed Feb 13, 2024
2 parents a2554b2 + 7abac79 commit 85106e0
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
directory: "/dev"
schedule:
interval: "daily"
assignees:
Expand Down
30 changes: 27 additions & 3 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ env:

jobs:
validate-models:
name: Validate models.yml
name: CI
runs-on: ubuntu-latest
defaults:
run:
working-directory: dev/

steps:
- uses: actions/checkout@v4
Expand All @@ -23,7 +26,28 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install requirements
run: pip install -r models_validator/requirements.txt
run: pip install -r requirements.txt

- name: Check black
if: always()
run: make check-black

- name: Check isort
if: always()
run: make check-isort

- name: Check flake8
if: always()
run: make flake8

- name: Check mypy
if: always()
run: make mypy

- name: Check pyupgrade
if: always()
run: make pyupgrade

- name: Validate models.yml
run: python models_validator/validate.py models.yml
if: always()
run: make validate-models
11 changes: 11 additions & 0 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.10.13-slim-bookworm

RUN apt-get update && apt-get install --yes make bash-completion

WORKDIR /app/dev/

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

STOPSIGNAL SIGKILL
CMD sleep infinity
42 changes: 42 additions & 0 deletions dev/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Commands inside the container

all: pyupgrade black autoflake isort flake8 mypy

pyupgrade:
pyupgrade --py310-plus --exit-zero-even-if-changed $$(find . -name '*.py')

check-pyupgrade:
pyupgrade --py310-plus $$(find . -name '*.py')

black:
black src/

check-black:
black --check --diff src/

autoflake:
autoflake src/

isort:
isort src/

check-isort:
isort --check-only --diff src/

flake8:
flake8 src/

mypy:
mypy src/

validate-models:
python src/validate.py

# Docker manage commands

run-dev:
USER_ID=$$(id -u $${USER}) GROUP_ID=$$(id -g $${USER}) docker-compose up -d --build
docker-compose exec models bash --rcfile /etc/bash_completion

stop-dev:
docker-compose down
21 changes: 21 additions & 0 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3"
services:
models:
build: .
user: $USER_ID:$GROUP_ID
volumes:
- ..:/app
depends_on:
- postgres
networks:
- postgres
postgres:
image: postgres:15
environment:
- POSTGRES_USER=openslides
- POSTGRES_PASSWORD=openslides
- POSTGRES_DB=openslides
networks:
- postgres
networks:
postgres:
13 changes: 13 additions & 0 deletions dev/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
autoflake==2.2.1
black==24.1.1
flake8==7.0.0
isort==5.13.2
mypy==1.8.0
pytest==8.0.0
pyupgrade==3.15.0
pyyaml==6.0.1
simplejson==3.19.2

# typing
types-PyYAML==6.0.12.12
types-simplejson==3.19.0.2
19 changes: 19 additions & 0 deletions dev/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[autoflake]
verbose = true
in-place = true
remove-all-unused-imports = true
ignore-init-module-imports = true
recursive = true

[isort]
include_trailing_comma = true
multi_line_output = 3
force_grid_wrap = 0
use_parentheses = True
line_length = 88

[flake8]
extend-ignore = E203,E501

[mypy]
disallow_untyped_defs = true
5 changes: 2 additions & 3 deletions models_validator/validate.py → dev/src/validate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
import sys
from pathlib import Path
from typing import Any, cast

import simplejson as json
Expand All @@ -17,9 +18,7 @@
DECIMAL_REGEX = re.compile(r"^-?(\d|[1-9]\d+)\.\d{6}$")
COLOR_REGEX = re.compile(r"^#[0-9a-f]{6}$")

DEFAULT_FILES = [
"../models.yml",
]
DEFAULT_FILES = [str((Path(__file__).parent / ".." / ".." / "models.yml").resolve())]

RELATION_TYPES = (
"relation",
Expand Down
3 changes: 0 additions & 3 deletions models_validator/requirements.txt

This file was deleted.

0 comments on commit 85106e0

Please sign in to comment.