Skip to content

Commit 8b01441

Browse files
committed
feat: enhance package with improved typing, documentation, and automation
1 parent dbe6bbe commit 8b01441

File tree

12 files changed

+519
-63
lines changed

12 files changed

+519
-63
lines changed

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
charset = utf-8
12+
13+
# Python files
14+
[*.py]
15+
indent_style = space
16+
indent_size = 4
17+
max_line_length = 100
18+
19+
# YAML files
20+
[*.{yml,yaml}]
21+
indent_style = space
22+
indent_size = 2
23+
24+
# JSON files
25+
[*.json]
26+
indent_style = space
27+
indent_size = 2
28+
29+
# Markdown files
30+
[*.md]
31+
trim_trailing_whitespace = false
32+
33+
# Makefile
34+
[Makefile]
35+
indent_style = tab

.github/workflows/code-coverage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
branches: [ "main" ]
88
workflow_dispatch:
99

10+
# Add permissions block here
11+
permissions:
12+
contents: write # Needed to update the README.md file
13+
1014
jobs:
1115
coverage:
1216
runs-on: ubuntu-latest
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Security Scan
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '0 8 * * 1' # Run at 8:00 UTC every Monday
10+
workflow_dispatch:
11+
12+
jobs:
13+
bandit:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.12"
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install bandit
28+
29+
- name: Run bandit
30+
run: |
31+
bandit -r src/ -c pyproject.toml -f json -o bandit-results.json
32+
33+
- name: Upload bandit results
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: bandit-results
37+
path: bandit-results.json
38+
39+
trivy:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Run Trivy vulnerability scanner
46+
uses: aquasecurity/trivy-action@master
47+
with:
48+
scan-type: 'fs'
49+
format: 'table'
50+
exit-code: '1'
51+
ignore-unfixed: true
52+
severity: 'CRITICAL,HIGH'

.github/workflows/style-check.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Style Check
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
style:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install Poetry
23+
run: |
24+
curl -sSL https://install.python-poetry.org | python3 -
25+
echo "$HOME/.local/bin" >> $GITHUB_PATH
26+
27+
- name: Install dependencies
28+
run: |
29+
poetry install
30+
31+
- name: Run black
32+
run: |
33+
poetry run black --check --diff src tests
34+
35+
- name: Run isort
36+
run: |
37+
poetry run isort --check-only --diff src tests
38+
39+
- name: Run ruff
40+
run: |
41+
poetry run ruff check src tests

.pre-commit-config.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,46 @@ repos:
77
- id: check-yaml
88
- id: check-toml
99
- id: check-added-large-files
10+
- id: check-ast
11+
- id: check-json
12+
- id: check-merge-conflict
13+
- id: detect-private-key
14+
- id: mixed-line-ending
15+
args: [--fix=lf]
16+
17+
- repo: https://github.com/pycqa/isort
18+
rev: 5.13.2
19+
hooks:
20+
- id: isort
21+
args: [--profile, black, --filter-files]
22+
23+
- repo: https://github.com/psf/black
24+
rev: 24.2.0
25+
hooks:
26+
- id: black
27+
args: [--line-length=100]
1028

1129
- repo: https://github.com/astral-sh/ruff-pre-commit
1230
rev: v0.3.0
1331
hooks:
1432
- id: ruff
1533
args: [--fix]
16-
- id: ruff-format
1734

1835
- repo: https://github.com/pre-commit/mirrors-mypy
1936
rev: v1.9.0
2037
hooks:
2138
- id: mypy
2239
additional_dependencies: [types-all]
40+
41+
- repo: https://github.com/PyCQA/bandit
42+
rev: 1.7.7
43+
hooks:
44+
- id: bandit
45+
args: ["-c", "pyproject.toml"]
46+
exclude: "tests/"
47+
48+
- repo: https://github.com/asottile/pyupgrade
49+
rev: v3.15.1
50+
hooks:
51+
- id: pyupgrade
52+
args: [--py310-plus]

Makefile

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
1-
.PHONY: help install format lint type-check test test-cov clean build publish-test publish
1+
.PHONY: help install format lint type-check test test-cov clean build publish-test publish setup dev-install security docs tox
22

33
help:
44
@echo "Available commands:"
55
@echo " make install Install the package and dependencies"
6-
@echo " make format Format code with ruff"
6+
@echo " make dev-install Install the package and dev dependencies"
7+
@echo " make setup Install pre-commit hooks and dev dependencies"
8+
@echo " make format Format code with black, isort, and ruff"
79
@echo " make lint Lint code with ruff"
810
@echo " make type-check Type check with mypy"
911
@echo " make test Run tests"
1012
@echo " make test-cov Run tests with coverage"
13+
@echo " make tox Run tests in multiple Python environments"
14+
@echo " make security Run security checks with bandit"
15+
@echo " make docs Generate documentation"
1116
@echo " make clean Remove build artifacts"
1217
@echo " make build Build package"
1318
@echo " make publish-test Publish to TestPyPI"
1419
@echo " make publish Publish to PyPI"
1520

1621
install:
22+
poetry install --no-dev
23+
24+
dev-install:
25+
poetry install
26+
27+
setup:
1728
poetry install
29+
pre-commit install
1830

1931
format:
20-
poetry run ruff format .
32+
poetry run black src tests
33+
poetry run isort src tests
34+
poetry run ruff format src tests
2135

2236
lint:
23-
poetry run ruff check .
37+
poetry run ruff check src tests
2438

2539
type-check:
2640
poetry run mypy src tests
@@ -31,6 +45,15 @@ test:
3145
test-cov:
3246
poetry run pytest --cov=my_python_package --cov-report=term-missing
3347

48+
tox:
49+
poetry run tox
50+
51+
security:
52+
poetry run bandit -r src/
53+
54+
docs:
55+
poetry run python scripts/generate_docs.py
56+
3457
clean:
3558
rm -rf build/
3659
rm -rf dist/

0 commit comments

Comments
 (0)