Skip to content

Commit e566dc0

Browse files
authored
Merge pull request #10 from CocoRoF/main
chore: update version to 1.0.3 in Cargo.toml and pyproject.toml; enha…
2 parents 86fd479 + 7166769 commit e566dc0

6 files changed

Lines changed: 94 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# ──────────────────────────────────────────────────────────────
22
# f2a CI — Lint, build, test on every push / PR
33
# Based on CocoRoF/googer proven workflow pattern.
4+
#
5+
# Optimised for speed:
6+
# - Rust target + registry cached (Swatinem/rust-cache)
7+
# - pip cached
8+
# - lint & test run in parallel
9+
# - matrix trimmed: full OS × Python only on main; PR = Linux-only
410
# ──────────────────────────────────────────────────────────────
511
name: CI
612

@@ -10,7 +16,29 @@ on:
1016
pull_request:
1117
branches: [main]
1218

19+
env:
20+
CARGO_INCREMENTAL: "1"
21+
CARGO_NET_RETRY: "10"
22+
RUSTUP_MAX_RETRIES: "10"
23+
1324
jobs:
25+
# ── Version consistency check (fast, no build) ────────────
26+
check-versions:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Verify pyproject.toml == Cargo.toml versions
32+
run: |
33+
PY_VER=$(grep -oP '^version\s*=\s*"\K[^"]+' pyproject.toml)
34+
RS_VER=$(grep -oP '^version\s*=\s*"\K[^"]+' Cargo.toml)
35+
echo "pyproject.toml = $PY_VER"
36+
echo "Cargo.toml = $RS_VER"
37+
if [ "$PY_VER" != "$RS_VER" ]; then
38+
echo "::error::Version mismatch! pyproject.toml=$PY_VER vs Cargo.toml=$RS_VER — update both files."
39+
exit 1
40+
fi
41+
1442
# ── Lint (Rust + Python) ──────────────────────────────────
1543
lint:
1644
runs-on: ubuntu-latest
@@ -22,6 +50,11 @@ jobs:
2250
with:
2351
components: clippy, rustfmt
2452

53+
- name: Rust cache
54+
uses: Swatinem/rust-cache@v2
55+
with:
56+
cache-on-failure: true
57+
2558
- name: cargo fmt --check
2659
run: cargo fmt --all -- --check
2760

@@ -30,24 +63,44 @@ jobs:
3063

3164
# ── Test (cross-platform × multi-Python) ──────────────────
3265
test:
33-
needs: lint
66+
# Run in parallel with lint (no 'needs')
3467
strategy:
3568
fail-fast: false
3669
matrix:
37-
os: [ubuntu-latest, macos-14, windows-latest]
38-
python-version: ["3.10", "3.11", "3.12", "3.13"]
70+
os: [ubuntu-latest]
71+
python-version: ["3.10", "3.12"]
72+
include:
73+
# Spot-check other platforms with one Python version
74+
- os: macos-14
75+
python-version: "3.12"
76+
- os: windows-latest
77+
python-version: "3.12"
3978
runs-on: ${{ matrix.os }}
4079
steps:
4180
- uses: actions/checkout@v4
4281

4382
- name: Install Rust toolchain
4483
uses: dtolnay/rust-toolchain@stable
4584

85+
- name: Rust cache
86+
uses: Swatinem/rust-cache@v2
87+
with:
88+
key: ${{ matrix.os }}-py${{ matrix.python-version }}
89+
cache-on-failure: true
90+
4691
- name: Set up Python ${{ matrix.python-version }}
4792
uses: actions/setup-python@v5
4893
with:
4994
python-version: ${{ matrix.python-version }}
5095

96+
- name: Pip cache
97+
uses: actions/cache@v4
98+
with:
99+
path: ~/.cache/pip
100+
key: pip-${{ matrix.os }}-py${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
101+
restore-keys: |
102+
pip-${{ matrix.os }}-py${{ matrix.python-version }}-
103+
51104
- name: Install package and test deps
52105
run: |
53106
python -m pip install --upgrade pip

.github/workflows/publish.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
strategy:
6868
fail-fast: false
6969
matrix:
70-
python-version: ["3.10", "3.11", "3.12", "3.13"]
70+
python-version: ["3.10", "3.13"]
7171
steps:
7272
- uses: actions/checkout@v4
7373

@@ -79,6 +79,20 @@ jobs:
7979
- name: Install Rust toolchain
8080
uses: dtolnay/rust-toolchain@stable
8181

82+
- name: Rust cache
83+
uses: Swatinem/rust-cache@v2
84+
with:
85+
key: publish-py${{ matrix.python-version }}
86+
cache-on-failure: true
87+
88+
- name: Pip cache
89+
uses: actions/cache@v4
90+
with:
91+
path: ~/.cache/pip
92+
key: pip-publish-py${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
93+
restore-keys: |
94+
pip-publish-py${{ matrix.python-version }}-
95+
8296
- name: Install package and test deps
8397
run: |
8498
python -m pip install --upgrade pip

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "f2a"
3-
version = "1.0.2"
3+
version = "1.0.3"
44
edition = "2021"
55
description = "f2a computation core -- Rust engine with PyO3 bindings"
66
license = "Apache-2.0"
@@ -58,6 +58,11 @@ indexmap = { version = "2", features = ["serde"] }
5858

5959
[profile.release]
6060
opt-level = 3
61+
62+
# Faster dev/test builds (used by `pip install .` which defaults to debug)
63+
[profile.dev]
64+
opt-level = 1 # enough optimisation to keep tests realistic
65+
debug = false # skip DWARF → faster link
6166
lto = "fat"
6267
codegen-units = 1
6368
strip = true

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "f2a"
7-
version = "1.0.2"
7+
version = "1.0.3"
88
description = "File to Analysis -- Automatically perform statistical analysis from any data source (Rust-powered)"
99
license = { text = "Apache-2.0" }
1010
readme = "README.md"

python/f2a/_version.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
__version__ = "1.0.0"
1+
from importlib.metadata import version, PackageNotFoundError
2+
3+
try:
4+
__version__: str = version("f2a")
5+
except PackageNotFoundError:
6+
# Fallback for editable / dev installs where metadata isn't available yet
7+
__version__ = "0.0.0-dev"

tests/test_core.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ def test_import():
1616
def test_version():
1717
import f2a
1818

19-
assert f2a.__version__ == "1.0.0"
19+
# Version must be a valid semver-like string, not the dev fallback
20+
assert f2a.__version__ != "0.0.0-dev"
21+
parts = f2a.__version__.split(".")
22+
assert len(parts) >= 2, f"Unexpected version format: {f2a.__version__}"
2023

2124

2225
def test_rust_core_version():
2326
from f2a._core import version
27+
import f2a
2428

25-
assert version() == "1.0.0"
29+
# Rust core version (from Cargo.toml) must match Python package version (from pyproject.toml)
30+
assert version() == f2a.__version__, (
31+
f"Version mismatch: Rust core={version()}, Python package={f2a.__version__}"
32+
)
2633

2734

2835
def test_rust_core_configs():

0 commit comments

Comments
 (0)