Skip to content

Commit

Permalink
refactor: Clean up the project structure
Browse files Browse the repository at this point in the history
- Set up linting and formatting using ruff
- Remove old linting and formatting tools
- Fix all linting issues (including adding a bunch of type defs)
- Set up more pre-commit tasks and remove old ones
- Add CI for pre-commit
- Fix REUSE issues
- Update some of the docs

Closes #32
Closes #2
  • Loading branch information
zusorio committed Dec 10, 2024
1 parent 6065090 commit 91305dc
Show file tree
Hide file tree
Showing 69 changed files with 4,931 additions and 2,663 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
frontend/node_modules
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: CC0-1.0

frontend/node_modules
103 changes: 0 additions & 103 deletions .github/workflows/build-test-publish.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/docs.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: CC0-1.0
name: lint

on:
push:
branches: ['**']
tags: ['v*.*.*']
pull_request:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
package_json_file: 'frontend/package.json'
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/setup-python@v5
with:
cache: pip
cache-dependency-path: ./pyproject.toml
python-version: '3.12'
- name: Install pre-commit
run: |-
python -m pip install pre-commit
- name: Install dependencies
run: |-
python -m pip install '.[dev]'
- name: Install dependencies (frontend)
working-directory: frontend/
run: |-
pnpm ci
- name: Run pre-commit
run: |-
pre-commit run --all-files
- name: Print changed files
if: failure()
run: |-
git add . && git status -vv
2 changes: 1 addition & 1 deletion .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ ipython_config.py
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# macOS
.DS_Store

# Celery stuff
celerybeat-schedule
celerybeat.pid
Expand Down Expand Up @@ -163,4 +166,4 @@ cython_debug/
workspace

project
training
training
63 changes: 41 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@ default_install_hook_types: [commit-msg, pre-commit]
default_stages: [commit, merge-commit]
minimum_pre_commit_version: 3.2.0
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
args: [ --config-file=./pyproject.toml ]
additional_dependencies:
- fastapi
- pydantic
- types-pyyaml
- capellambse
- httpx
- repo: local
hooks:
- id: tsc
name: tsc
entry: tsc -noEmit -p ./frontend
pass_filenames: false
language: node
types_or: [ts]
additional_dependencies:
- 'typescript@^5.7.2'
- repo: local
hooks:
- id: prettier
name: prettier
entry: cd ./frontend && prettier --write
language: node
types_or: [ts, tsx, css, html, markdown]
additional_dependencies:
- 'prettier-plugin-tailwindcss@^0.6.9'
- 'prettier@^3.4.2'
- 'tailwindcss@^3.4.16'
- repo: https://github.com/gitleaks/gitleaks.git
rev: v8.18.4
hooks:
Expand Down Expand Up @@ -64,8 +102,8 @@ repos:
- '<!--| ~| -->'
- id: insert-license
name: Insert Apache license headers (C-style comments)
files: '\.(?:s?css|js|ts)$'
exclude: '(?:^|/)\..+'
files: '\.(?:s?css|js|jsx|ts|tsx)$'
exclude: '(?:^|/)\..+|frontend/src/lib/api/v1\.d\.ts$'
args:
- --detect-license-in-X-top-lines=15
- --license-filepath
Expand All @@ -82,27 +120,8 @@ repos:
- LICENSES/.license_header_apache.txt
- --comment-style
- '..| |'
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
additional_dependencies:
- docformatter[tomli]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff-format
- id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
- repo: https://github.com/fsfe/reuse-tool
rev: v2.1.0
rev: v5.0.2
hooks:
- id: reuse
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
Expand Down
Loading

0 comments on commit 91305dc

Please sign in to comment.