Skip to content

Commit ca86eda

Browse files
authored
Merge pull request #21 from aeiwz/origin/dev/refactor-code
Origin/dev/refactor code
2 parents ece8767 + f38eac8 commit ca86eda

24 files changed

Lines changed: 5027 additions & 110 deletions

.github/workflows/ci.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, "dev/**", "feature/**", "fix/**"]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
# -------------------------------------------------------------------------
18+
# 1. Lint / static checks (fast, no deps)
19+
# -------------------------------------------------------------------------
20+
lint:
21+
name: Lint
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.12"
29+
cache: pip
30+
31+
- name: Install lint tools
32+
run: pip install ruff
33+
34+
- name: Ruff check (errors and imports)
35+
run: ruff check metbit/ tests/ --select E,F,I --ignore E501
36+
37+
# -------------------------------------------------------------------------
38+
# 2. Test matrix (Linux, Python 3.10-3.13, with C extension)
39+
# -------------------------------------------------------------------------
40+
test:
41+
name: "Test Python ${{ matrix.python-version }} on ${{ matrix.os }}"
42+
needs: lint
43+
runs-on: ${{ matrix.os }}
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
os: [ubuntu-latest, macos-latest]
48+
python-version: ["3.10", "3.11", "3.12", "3.13"]
49+
exclude:
50+
# macOS arm64 runner only reliably supports 3.11+
51+
- os: macos-latest
52+
python-version: "3.10"
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: actions/setup-python@v5
58+
with:
59+
python-version: ${{ matrix.python-version }}
60+
cache: pip
61+
62+
- name: Install build tools + dev deps
63+
run: |
64+
python -m pip install --upgrade pip setuptools wheel
65+
pip install -r requirements-dev.txt
66+
67+
- name: Build and install with C extension
68+
run: pip install -e . --no-build-isolation
69+
70+
- name: Run test suite (no slow/perf tests)
71+
run: |
72+
pytest -q --no-header \
73+
-m "not slow and not perf" \
74+
--cov=metbit \
75+
--cov-report=term-missing \
76+
--cov-report=xml:coverage.xml \
77+
--junitxml=test-results.xml
78+
79+
- name: Upload coverage to Codecov
80+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
81+
uses: codecov/codecov-action@v4
82+
with:
83+
files: coverage.xml
84+
fail_ci_if_error: false
85+
86+
- name: Upload test results
87+
if: always()
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }}
91+
path: test-results.xml
92+
93+
# -------------------------------------------------------------------------
94+
# 3. Verify the C extension builds on Windows too
95+
# -------------------------------------------------------------------------
96+
build-windows:
97+
name: Build C ext on Windows
98+
needs: lint
99+
runs-on: windows-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- uses: actions/setup-python@v5
104+
with:
105+
python-version: "3.12"
106+
107+
- name: Install build tools
108+
run: python -m pip install --upgrade pip setuptools wheel
109+
110+
- name: Build extension (without OpenMP on Windows)
111+
run: python setup.py build_ext --inplace
112+
113+
- name: Smoke test import
114+
run: python -c "import metbit; print(metbit.__version__); print(metbit.backend_info())"
115+
116+
# -------------------------------------------------------------------------
117+
# 4. Verify sdist can be installed clean (no in-tree sources)
118+
# -------------------------------------------------------------------------
119+
sdist-install:
120+
name: sdist install check
121+
needs: test
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/checkout@v4
125+
126+
- uses: actions/setup-python@v5
127+
with:
128+
python-version: "3.12"
129+
130+
- name: Build sdist
131+
run: |
132+
pip install build
133+
python -m build --sdist
134+
135+
- name: Install from sdist in clean venv
136+
run: |
137+
python -m venv /tmp/clean-venv
138+
/tmp/clean-venv/bin/pip install dist/*.tar.gz
139+
/tmp/clean-venv/bin/python -c "import metbit; print(metbit.__version__)"

0 commit comments

Comments
 (0)