Skip to content

Commit afd397c

Browse files
committed
feat: Initial commit
0 parents  commit afd397c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+9108
-0
lines changed

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.11"
15+
- name: Install Poetry
16+
run: pip install poetry
17+
- name: Cache dependencies
18+
uses: actions/cache@v4
19+
with:
20+
path: |
21+
~/.cache/pypoetry
22+
~/.local/share/pypoetry
23+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
24+
restore-keys: ${{ runner.os }}-poetry-
25+
- name: Install dependencies
26+
run: poetry install
27+
- name: Run pre-commit
28+
run: poetry run pre-commit run --show-diff-on-failure --all-files
29+
30+
test:
31+
runs-on: ${{ matrix.os }}
32+
strategy:
33+
matrix:
34+
os: [ubuntu-latest, windows-latest, macos-latest]
35+
python-version: ["3.10", "3.11", "3.12"]
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
- name: Install Poetry
42+
run: pip install poetry
43+
- name: Cache dependencies
44+
uses: actions/cache@v4
45+
with:
46+
path: |
47+
~/.cache/pypoetry
48+
~/.local/share/pypoetry
49+
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
50+
restore-keys: ${{ runner.os }}-poetry-${{ matrix.python-version }}-
51+
- name: Install dependencies
52+
run: poetry install
53+
- name: Run tests
54+
run: poetry run pytest
55+
56+
docs:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: actions/setup-python@v5
61+
with:
62+
python-version: "3.11"
63+
- name: Install Poetry
64+
run: pip install poetry
65+
- name: Cache dependencies
66+
uses: actions/cache@v4
67+
with:
68+
path: |
69+
~/.cache/pypoetry
70+
~/.local/share/pypoetry
71+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
72+
restore-keys: ${{ runner.os }}-poetry-
73+
- name: Install dependencies
74+
run: poetry install
75+
- name: Build docs
76+
run: poetry run sphinx-build -b html docs docs/_build/html
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Performance Regression Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
benchmark:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 2
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.11"
18+
- name: Install Poetry
19+
run: pip install poetry
20+
- name: Cache dependencies
21+
uses: actions/cache@v4
22+
with:
23+
path: |
24+
~/.cache/pypoetry
25+
~/.local/share/pypoetry
26+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
27+
restore-keys: ${{ runner.os }}-poetry-
28+
- name: Install dependencies
29+
run: poetry install
30+
- name: Run benchmarks on current commit
31+
run: poetry run pytest tests/test_performance.py --benchmark-json current.json
32+
- name: Run benchmarks on previous commit
33+
run: |
34+
git checkout HEAD~1
35+
poetry lock
36+
poetry install
37+
poetry run pytest tests/test_performance.py --benchmark-json previous.json
38+
- name: Compare performance
39+
run: |
40+
poetry run python - <<'PY'
41+
import json, sys
42+
with open('previous.json') as f: prev = json.load(f)
43+
with open('current.json') as f: curr = json.load(f)
44+
def mean(data):
45+
return data['benchmarks'][0]['stats']['mean']
46+
prev_mean = mean(prev)
47+
curr_mean = mean(curr)
48+
if curr_mean > prev_mean * 1.10:
49+
print(f"Performance regression detected: {curr_mean} > {prev_mean}")
50+
sys.exit(1)
51+
print("No significant performance regression")
52+
PY

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
test-matrix:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, windows-latest, macos-latest]
14+
python-version: ["3.10", "3.11", "3.12"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install Poetry
21+
run: pip install poetry
22+
- name: Cache dependencies
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cache/pypoetry
27+
~/.local/share/pypoetry
28+
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
29+
restore-keys: ${{ runner.os }}-poetry-${{ matrix.python-version }}-
30+
- name: Install dependencies
31+
run: poetry install
32+
- name: Run tests
33+
run: poetry run pytest
34+
35+
build:
36+
needs: test-matrix
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: "3.11"
43+
- name: Install Poetry
44+
run: pip install poetry
45+
- name: Cache dependencies
46+
uses: actions/cache@v4
47+
with:
48+
path: |
49+
~/.cache/pypoetry
50+
~/.local/share/pypoetry
51+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
52+
restore-keys: ${{ runner.os }}-poetry-
53+
- name: Install dependencies
54+
run: poetry install
55+
- name: Build package
56+
run: poetry build
57+
- name: Publish to PyPI
58+
env:
59+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
60+
run: poetry publish

.github/workflows/security.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Security Scan
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * 0' # Weekly
8+
9+
jobs:
10+
security:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Run Bandit security scan
16+
run: |
17+
pip install bandit
18+
bandit -r min_ratio_cycle/
19+
20+
- name: Run Safety check
21+
run: |
22+
pip install safety
23+
safety check
24+
25+
- name: Dependency vulnerability scan
26+
uses: pypa/[email protected]

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python cache
2+
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
*.so
7+
.hypothesis/
8+
9+
# Build artifacts
10+
*.egg-info/
11+
dist/
12+
build/
13+
14+
# Environments
15+
.env
16+
.venv
17+
18+
# Poetry
19+
poetry.lock

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- repo: https://github.com/psf/black
10+
rev: 23.9.1
11+
hooks:
12+
- id: black
13+
- repo: https://github.com/PyCQA/isort
14+
rev: 5.12.0
15+
hooks:
16+
- id: isort
17+
- repo: https://github.com/PyCQA/bandit
18+
rev: 1.7.5
19+
hooks:
20+
- id: bandit
21+
args: ["-ll"]
22+
files: ^min_ratio_cycle/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Diogo Ribeiro
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)