Skip to content

Commit 8f0679b

Browse files
committed
feat: comprehensive project update with tests, docs, and config
1 parent 439e0d3 commit 8f0679b

27 files changed

+3101
-9
lines changed

.flake8

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[flake8]
2+
max-line-length = 127
3+
extend-ignore = E203, W503
4+
exclude =
5+
.git,
6+
__pycache__,
7+
venv,
8+
.venv,
9+
build,
10+
dist,
11+
*.egg-info,
12+
.github
13+
14+
per-file-ignores =
15+
__init__.py:F401
16+
17+
max-complexity = 10

.github/workflows/ci.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.11', '3.12', '3.13']
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install system dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y g++ build-essential
28+
29+
- name: Cache pip packages
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
37+
- name: Install Python dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
pip install -r requirements.txt
41+
pip install pytest pytest-cov flake8 black mypy
42+
43+
- name: Compile C++ modules
44+
run: |
45+
cd src
46+
g++ -shared -fPIC -O3 -o libcollatz.so collatz_core.cpp
47+
g++ -shared -fPIC -O3 -std=c++11 -pthread -o libloop_searcher.so loop_searcher.cpp
48+
cd ..
49+
50+
- name: Run tests
51+
run: |
52+
pytest tests/ -v --cov=src --cov-report=xml --cov-report=term
53+
54+
- name: Upload coverage to Codecov
55+
uses: codecov/codecov-action@v4
56+
with:
57+
file: ./coverage.xml
58+
flags: unittests
59+
name: codecov-umbrella
60+
fail_ci_if_error: false
61+
62+
lint:
63+
runs-on: ubuntu-latest
64+
65+
steps:
66+
- uses: actions/checkout@v4
67+
68+
- name: Set up Python
69+
uses: actions/setup-python@v5
70+
with:
71+
python-version: '3.13'
72+
73+
- name: Install linting tools
74+
run: |
75+
python -m pip install --upgrade pip
76+
pip install flake8 black
77+
78+
- name: Run flake8
79+
run: |
80+
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
81+
flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
82+
83+
- name: Check formatting with black
84+
run: |
85+
black --check src/ tests/ *.py
86+
87+
type-check:
88+
runs-on: ubuntu-latest
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Set up Python
94+
uses: actions/setup-python@v5
95+
with:
96+
python-version: '3.13'
97+
98+
- name: Install dependencies
99+
run: |
100+
python -m pip install --upgrade pip
101+
pip install -r requirements.txt
102+
pip install mypy
103+
104+
- name: Run mypy
105+
run: |
106+
mypy src/ --ignore-missing-imports --check-untyped-defs
107+
continue-on-error: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ __pycache__/
2222
*.so
2323
analysis_embeddings.png
2424
last_result.txt
25+
config.py

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
args: ['--maxkb=5000']
10+
- id: check-merge-conflict
11+
- id: check-toml
12+
- id: mixed-line-ending
13+
14+
- repo: https://github.com/psf/black
15+
rev: 23.12.1
16+
hooks:
17+
- id: black
18+
language_version: python3.11
19+
20+
- repo: https://github.com/pycqa/flake8
21+
rev: 7.0.0
22+
hooks:
23+
- id: flake8
24+
args: ['--max-line-length=127', '--extend-ignore=E203,W503']
25+
additional_dependencies: [flake8-docstrings]
26+
27+
- repo: https://github.com/pycqa/isort
28+
rev: 5.13.2
29+
hooks:
30+
- id: isort
31+
args: ["--profile", "black"]

0 commit comments

Comments
 (0)