Skip to content

Commit

Permalink
Add many nice tools
Browse files Browse the repository at this point in the history
  • Loading branch information
GereonV committed Nov 27, 2024
1 parent e198119 commit c2692ec
Show file tree
Hide file tree
Showing 15 changed files with 242 additions and 168 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# https://editorconfig.org

root = true

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

[Makefile]
indent_style = tab

[*.{yml,yaml}]
indent_size = 2
158 changes: 62 additions & 96 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,122 +1,88 @@
name: Python
on:
push:
on: [push]

Check warning on line 2 in .github/workflows/python.yml

View workflow job for this annotation

GitHub Actions / pre-commit

2:1 [truthy] truthy value should be one of [false, true]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build project
run: make build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.python-version }}
path: dist
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Test project
run: make test
mypy:
pre-commit:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run mypy
run: make mypy
flake8:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit 'manual' hooks
run: pre-commit run --color=always
--all-files
--hook-stage manual
--show-diff-on-failure
--verbose
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Run flake8
run: make flake8
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build project
run: make build
- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.python-version }}
path: dist
run:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.python-version }}
- name: Install package
run: pip install *.whl
- name: Run package
run: python -m template
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.python-version }}
- name: Install package
run: pip install *.whl
- name: Run project
run: python -m template
run-windows:
needs: [build]
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.python-version }}
- name: Install package
run: pip install (get-item .\*.whl)
- name: Run package
run: python -m template
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.python-version }}
- name: Install package
run: pip install (get-item .\*.whl)
- name: Run package
run: python -m template
run-macos:
needs: [build]
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.python-version }}
- name: Install package
run: pip install *.whl
- name: Run package
run: python -m template
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.python-version }}
- name: Install package
run: pip install *.whl
- name: Run package
run: python -m template
36 changes: 18 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
default:
image: ubuntu:latest
before_script: |
apt-get update
apt-get install -y python3-venv make
image: alpine:latest
before_script: apk add python3 make

build:
stage: build
script: make build
artifacts:
paths:
- dist/

test:
stage: test
script: make test
needs: []
mypy:
stage: test
script: make mypy
needs: []
flake8:
- dist/
pre-commit:
image: python:latest
stage: test
script: make flake8
needs: []
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
cache:
key: pre-commit
paths: ["${PRE_COMMIT_HOME}"]
before_script: pip install pre-commit
script: pre-commit run --color=always
--all-files
--hook-stage manual
--show-diff-on-failure
--verbose
install:
stage: test
script:
- python3 -m venv .venv
- .venv/bin/pip install dist/*.whl
- python3 -m venv .venv
- .venv/bin/pip install dist/*.whl
15 changes: 15 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[general]
ignore=body-is-missing
verbosity=3

[title-max-length]
line-length=80

[title-min-length]
min-length=5

[body-max-line-length]
line-length=120

[body-min-length]
min-length=5
84 changes: 84 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
default_install_hook_types: [commit-msg, pre-commit, pre-merge-commit, pre-push]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: [--maxkb=100]
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-illegal-windows-names
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
args: [--fix=lf]
- id: name-tests-test
- id: pretty-format-json
args: [--autofix, --ident=4, --no-sort-keys]
- id: requirements-txt-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 3.0.3
hooks:
- id: editorconfig-checker
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
- id: gitlint-ci
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.43.0
hooks:
- id: markdownlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.4
hooks:
- id: rstcheck
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: [--filter-files, --profile=black, --verbose, --color, --jobs=-1]
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
args: [--ignore=E203, --color=always] # spacing around ':' slicing-syntax
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
args: [--strict, --show-error-context, --pretty]
files: ^src/
- repo: local
hooks:
- id: pytest
name: pytest
entry: pytest --color=yes tests
language: python
additional_dependencies: [pytest]
pass_filenames: false
types: [python]
16 changes: 16 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends: default
rules:
document-end:
present: false
document-start:
present: false
indentation:
spaces: 2
indent-sequences: false
key-duplicates: {}
line-length:
max: 80
level: warning
quoted-strings:
required: only-when-needed
trailing-spaces: {}
Loading

0 comments on commit c2692ec

Please sign in to comment.