Skip to content

Commit

Permalink
Merge pull request #3 from MarkusSagen/feat-remove-upper-bound-and-cl…
Browse files Browse the repository at this point in the history
…ean-up

Feat remove upper bound and clean up
  • Loading branch information
MarkusSagen authored Jul 13, 2024
2 parents 63b3a3d + cc941f4 commit f35d643
Show file tree
Hide file tree
Showing 15 changed files with 1,897 additions and 950 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf
indent_size = 2

[*.{rs,py,pyi,toml,justfile}]
indent_size = 4

[*.{md,snap}]
max_line_length = 100
trim_trailing_whitespace = false
103 changes: 54 additions & 49 deletions .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,73 @@ on:

env:
PROJECT_NAME: rejx
PYTHON_VERSION: "3.10.10"
PYTHON_VERSION: 3.10.10
POETRY_VERSION: 1.7.1

jobs:
install_dependencies:
name: Install Dependencies
test_and_lint:
name: Lint and Test
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-keys.outputs.cache-key }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
###################################################################
# #
# Setup Project #
# #
###################################################################
- name: Setup Justfile
uses: extractions/setup-just@v1
- name: Check justfile linting
run: 'just --unstable --fmt --check || "justfile is not formatted!\nrun: `just fmt` and commit again"'

- name: Install dependencies
run: |
pip install pytest-cov==4.1.0 pytest==7.4.3 \
poetry==1.7.1 poetry-plugin-export==1.6.0 \
pre-commit==3.5.0 ruff==0.1.6
linting:
name: Code Linting
needs: install_dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
cache: pip

- name: Install dependencies
- name: Setup Poetry for Python
uses: abatilo/actions-poetry@v2
with:
python-version: ${{ env.POETRY_VERSION }}
- name: Setup a local virtual environment (if no poetry.toml file)
run: |
pip install pytest-cov==4.1.0 pytest==7.4.3 \
poetry==1.7.1 poetry-plugin-export==1.6.0 \
pre-commit==3.5.0 ruff==0.1.6
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}

- name: Run Code Linting
run: |
ruff --fix --preview --unsafe-fixes src
make lint
- name: Install the project dependencies
run: just setup

unit_tests:
name: Unit Tests
needs: install_dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
###################################################################
# #
# Linting and Format #
# #
###################################################################
- name: Lint code
run: just lint

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
###################################################################
# #
# Testing #
# #
###################################################################
- name: Run unit test
run: just test

- name: Install dependencies
run: |
pip install pytest-cov==4.1.0 pytest==7.4.3 \
poetry==1.7.1 poetry-plugin-export==1.6.0 \
pre-commit==3.5.0 ruff==0.1.6
###################################################################
# #
# CI/CD Bots #
# #
###################################################################

- name: Run unit tests
run: |
pip install -e .
make test
# https://pypi.org/project/pytest-md-report/
- name: Run tests with reports
run: poetry run pytest --md-report --md-report-flavor gfm --md-report-output report.md
32 changes: 32 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# default to true for all rules
default: true

# MD007/unordered-list-indent
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md007---unordered-list-indentation
MD007:
indent: 4

# MD013/line-length
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013---line-length
MD013: false

# MD024/no-duplicate-heading
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md024---multiple-headings-with-the-same-content
MD024:
# Allow when nested under different parents e.g. CHANGELOG.md
siblings_only: true

# MD029/ordered-list-item-prefix
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md029---ordered-list-item-prefix
MD029:
# This makes reviewing changes of ordered list easier
# https://mdformat.readthedocs.io/en/stable/users/style.html#ordered-lists
style: one

# MD033/no-inline-html
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md033---inline-html
MD033: false

# MD041/first-line-h1
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md041---first-line-in-a-file-should-be-a-top-level-heading
MD041: false
85 changes: 59 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,100 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

exclude: ^(profiling/|tests/data/)

default_language_version:
python: python3.10

default_stages: [ commit, manual ]
default_stages: [commit, manual]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: [ --maxkb=55000 ]
args: [--maxkb=55000]
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: pretty-format-json
args: [ --no-ensure-ascii, --autofix ]
args: [--no-ensure-ascii, --autofix]
- id: check-toml
- id: check-yaml
exclude: k8s-helm
args: [ --unsafe ]
- id: check-case-conflict
args: [--unsafe]
- id: check-case-conflict # Check for files that would conflict in case-insensitive filesystems
- id: check-merge-conflict
- id: debug-statements
- id: debug-statements # Check for debugger imports and py37+ `breakpoint()` calls in python source.
- id: mixed-line-ending
args: [ --fix=auto ]
args: [--fix=auto]
- id: name-tests-test
args: [ --pytest-test-first ]
args: [--pytest-test-first]
- id: requirements-txt-fixer
- id: trailing-whitespace
args: ["--markdown-linebreak-ext=md"]
- id: end-of-file-fixer

# isort
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
args: [ --filter-files, --profile, "black" ]

- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma

# black
- repo: https://github.com/ambv/black
rev: 23.1.0
hooks:
- id: black

# black styling in docs:
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [ black==23.1.0 ] # Dependency on broken click (see black)
additional_dependencies: [black==24.4.0]
entry: blacken-docs --skip-errors

# ruff
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.3
hooks:
- id: pydocstringformatter

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
- id: validate-pyproject

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
- mdformat-mkdocs
- mdformat-admon
exclude: |
(?x)^(
docs/formatter/black\.md
| docs/\w+\.md
)$
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint-fix
exclude: |
(?x)^(
docs/formatter/black\.md
| docs/\w+\.md
)$
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.6
rev: v0.4.10
hooks:
- id: ruff
args: [ "--fix", "--preview", "--unsafe-fixes" ]
exclude: "scripts/.*"
args: [--fix, --preview, --unsafe-fixes, --exit-non-zero-on-fix]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
additional_dependencies:
- tomli
exclude: '^poetry\.lock$'

ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
Expand Down
62 changes: 0 additions & 62 deletions Makefile

This file was deleted.

Loading

0 comments on commit f35d643

Please sign in to comment.