Skip to content

Commit a6106f1

Browse files
committed
refactor
1 parent 112e334 commit a6106f1

42 files changed

Lines changed: 3621 additions & 1820 deletions

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 93 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,48 @@ on:
44
branches: [ "master", "main" ]
55
pull_request:
66
branches: [ "master", "main" ]
7+
78
permissions:
89
contents: read
10+
911
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v3
19+
with:
20+
enable-cache: true
21+
cache-dependency-glob: "pyproject.toml"
22+
23+
- name: Set up Python 3.11
24+
run: |
25+
uv python install 3.11
26+
uv venv
27+
28+
- name: Install dev dependencies
29+
run: |
30+
uv pip install -e .[dev]
31+
32+
- name: Run ruff linting
33+
run: |
34+
uv run ruff check allocator/
35+
36+
- name: Run ruff formatting check
37+
run: |
38+
uv run ruff format --check allocator/
39+
40+
- name: Run mypy type checking
41+
run: |
42+
uv run mypy allocator/
43+
1044
test:
1145
runs-on: ubuntu-latest
1246
strategy:
1347
matrix:
14-
python-version: ["3.10", "3.11", "3.12"]
48+
python-version: ["3.11", "3.12", "3.13"]
1549
steps:
1650
- uses: actions/checkout@v4
1751

@@ -26,26 +60,73 @@ jobs:
2660
uv python install ${{ matrix.python-version }}
2761
uv venv
2862
29-
- name: Install dependencies
63+
- name: Install core dependencies
3064
run: |
31-
uv pip install -e .
32-
uv pip install pytest pytest-cov flake8
65+
uv pip install -e .[test]
3366
34-
- name: Lint with flake8
67+
- name: Install optional dependencies for comprehensive testing
3568
run: |
36-
# stop the build if there are Python syntax errors or undefined names
37-
uv run flake8 allocator --count --select=E9,F63,F7,F82 --show-source --statistics
38-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
39-
uv run flake8 allocator --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
69+
uv pip install ortools scipy
4070
41-
- name: Test with pytest
71+
- name: Test with pytest (core functionality)
4272
run: |
43-
uv run pytest --cov=allocator --cov-report=xml --cov-report=term-missing -v
73+
uv run pytest allocator/tests/ --cov=allocator --cov-report=xml --cov-report=term-missing -v --tb=short
4474
4575
- name: Upload coverage to Codecov
4676
uses: codecov/codecov-action@v4
4777
if: matrix.python-version == '3.11'
4878
with:
4979
file: ./coverage.xml
5080
fail_ci_if_error: false
51-
token: ${{ secrets.CODECOV_TOKEN }}
81+
token: ${{ secrets.CODECOV_TOKEN }}
82+
83+
test-algorithms:
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v4
87+
88+
- name: Install uv
89+
uses: astral-sh/setup-uv@v3
90+
with:
91+
enable-cache: true
92+
cache-dependency-glob: "pyproject.toml"
93+
94+
- name: Set up Python 3.11
95+
run: |
96+
uv python install 3.11
97+
uv venv
98+
99+
- name: Install all optional dependencies
100+
run: |
101+
uv pip install -e .[test,algorithms,geo]
102+
103+
- name: Test advanced algorithms
104+
run: |
105+
uv run pytest allocator/tests/api/ -k "ortools or google" -v --tb=short
106+
107+
build:
108+
runs-on: ubuntu-latest
109+
needs: [lint, test]
110+
steps:
111+
- uses: actions/checkout@v4
112+
113+
- name: Install uv
114+
uses: astral-sh/setup-uv@v3
115+
116+
- name: Set up Python 3.11
117+
run: |
118+
uv python install 3.11
119+
uv venv
120+
121+
- name: Install build dependencies
122+
run: |
123+
uv pip install build
124+
125+
- name: Build package
126+
run: |
127+
python -m build
128+
129+
- name: Check package
130+
run: |
131+
uv pip install twine
132+
twine check dist/*

.github/workflows/docs.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ permissions:
1111
pages: write
1212
id-token: write
1313

14-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
15-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
1614
concurrency:
1715
group: "pages"
1816
cancel-in-progress: false
@@ -23,23 +21,27 @@ jobs:
2321
steps:
2422
- uses: actions/checkout@v4
2523

26-
- name: Set up Python
27-
uses: actions/setup-python@v5
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
2826
with:
29-
python-version: '3.11'
30-
cache: 'pip'
27+
enable-cache: true
28+
cache-dependency-glob: "pyproject.toml"
29+
30+
- name: Set up Python 3.11
31+
run: |
32+
uv python install 3.11
33+
uv venv
3134
3235
- name: Install dependencies
3336
run: |
34-
python -m pip install --upgrade pip
35-
pip install -e .[docs]
37+
uv pip install -e .[docs]
3638
3739
- name: Build documentation
3840
run: |
3941
cd docs
40-
make html
42+
uv run make html
4143
# Copy .nojekyll to build output for GitHub Pages
42-
cp .nojekyll build/html/
44+
touch build/html/.nojekyll
4345
4446
- name: Setup Pages
4547
uses: actions/configure-pages@v5
Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
4-
name: Publish Python Package to PyPI
1+
# Publish Python Package to PyPI when a release is created
2+
name: Publish to PyPI
53

64
on:
75
release:
@@ -19,25 +17,58 @@ permissions:
1917
id-token: write # Required for trusted publishing
2018

2119
jobs:
22-
deploy:
20+
test-before-publish:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v3
27+
with:
28+
enable-cache: true
29+
cache-dependency-glob: "pyproject.toml"
30+
31+
- name: Set up Python 3.11
32+
run: |
33+
uv python install 3.11
34+
uv venv
35+
36+
- name: Install and test package
37+
run: |
38+
uv pip install -e .[test]
39+
uv run pytest allocator/tests/ --tb=short -q
40+
41+
publish:
2342
runs-on: ubuntu-latest
43+
needs: test-before-publish
2444
environment:
25-
name: pypi
26-
url: https://pypi.org/p/allocator
45+
name: ${{ github.event.inputs.use_test_pypi == 'true' && 'test-pypi' || 'pypi' }}
46+
url: ${{ github.event.inputs.use_test_pypi == 'true' && 'https://test.pypi.org/p/allocator' || 'https://pypi.org/p/allocator' }}
2747

2848
steps:
2949
- uses: actions/checkout@v4
30-
- name: Set up Python
31-
uses: actions/setup-python@v5
32-
with:
33-
python-version: '3.11'
50+
51+
- name: Install uv
52+
uses: astral-sh/setup-uv@v3
53+
54+
- name: Set up Python 3.11
55+
run: |
56+
uv python install 3.11
57+
uv venv
58+
3459
- name: Install build dependencies
3560
run: |
36-
python -m pip install --upgrade pip
37-
pip install build
61+
uv pip install build twine
62+
3863
- name: Build package
39-
run: python -m build
40-
- name: Publish package distributions to PyPI
64+
run: |
65+
python -m build
66+
67+
- name: Check package quality
68+
run: |
69+
twine check dist/*
70+
71+
- name: Publish to PyPI
4172
uses: pypa/gh-action-pypi-publish@v1.13.0
4273
with:
43-
repository-url: ${{ github.event.inputs.use_test_pypi == 'true' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
74+
repository-url: ${{ github.event.inputs.use_test_pypi == 'true' && 'https://test.pypi.org/legacy/' || '' }}

0 commit comments

Comments
 (0)