Skip to content

Commit 8a07cae

Browse files
committed
build: pin internal crate versions so releases stop recompiling every crate
A crate's version is part of its Cargo build identity, so the shared release version in [workspace.package] recompiled all 21 crates after every release. Only sqlbuild-cli and sqlbuild-python now carry the release version; the others inherit a fixed 0.0.0. Lower crates that read CARGO_PKG_VERSION now take the release from the release crates: the built-in Rules fingerprint uses the native build identity, and the Recall schema version row records the producer version passed in through DdlOptions. The native layering check fails if a lower crate reads CARGO_PKG_VERSION again.
1 parent a7bc60e commit 8a07cae

30 files changed

Lines changed: 176 additions & 81 deletions

File tree

‎.github/workflows/release-please.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ jobs:
9292
if: steps.release.outputs.prs_created == 'true'
9393
env:
9494
RELEASE_BRANCH: ${{ steps.release_branch.outputs.name }}
95-
# Release Please only bumps workspace versions, so updating the workspace entries of
96-
# Cargo.lock is enough and needs no compile; metadata --locked proves the lock is complete.
95+
# Release Please only bumps the sqlbuild-cli and sqlbuild-python crate versions, so updating
96+
# the workspace entries of Cargo.lock is enough and needs no compile; metadata --locked
97+
# proves the lock is complete.
9798
run: |
9899
cargo update --workspace
99100
cargo metadata --locked --format-version 1 > /dev/null
@@ -198,7 +199,7 @@ jobs:
198199
199200
# Keep this allowlist in sync with the release metadata check in verify.yml.
200201
unexpected_files="$(gh pr view "${RELEASE_PR}" --repo "${GITHUB_REPOSITORY}" \
201-
--json files --jq '[.files[].path | select(. != ".release-please-manifest.json" and . != "CHANGELOG.md" and . != "pyproject.toml" and . != "uv.lock" and . != "Cargo.lock" and . != "Cargo.toml")] | join("\n")')"
202+
--json files --jq '[.files[].path | select(. != ".release-please-manifest.json" and . != "CHANGELOG.md" and . != "pyproject.toml" and . != "uv.lock" and . != "Cargo.lock" and . != "crates/sqlbuild-cli/Cargo.toml" and . != "crates/sqlbuild-python/Cargo.toml")] | join("\n")')"
202203
if [[ -n "${unexpected_files}" ]]; then
203204
echo "Release pull request contains non-metadata changes:" >&2
204205
echo "${unexpected_files}" >&2

‎.github/workflows/verify.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
changed_any=true
8888
case "${path}" in
8989
.release-please-manifest.json|CHANGELOG.md) ;;
90-
Cargo.toml|Cargo.lock|pyproject.toml|uv.lock)
90+
crates/sqlbuild-cli/Cargo.toml|crates/sqlbuild-python/Cargo.toml|Cargo.lock|pyproject.toml|uv.lock)
9191
diff="$(git diff -U0 --text --no-color --no-renames "${BASE_SHA}...${HEAD_SHA}" -- "${path}")" \
9292
|| return 1
9393
offending="$(awk '/^@@/ { hunk = 1; next } hunk && /^[-+]/' <<< "${diff}" \

‎Cargo.lock‎

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ python-boundary = "sqlbuild-python"
5555
polyglot-floor = "sqlbuild-analysis"
5656

5757
[workspace.package]
58-
version = "0.187.3"
58+
# Fixed on purpose: a crate's version is part of its Cargo build identity, so a shared release
59+
# version would recompile every crate after each release. The release version lives in the
60+
# sqlbuild-cli and sqlbuild-python manifests; see crates/README.md.
61+
version = "0.0.0"
5962
edition = "2024"
6063
license = "Apache-2.0"
6164
publish = false

‎crates/README.md‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ in `[workspace.metadata.native-layers]` in the workspace `Cargo.toml`, and
5454
- any crate other than `sqlbuild-python` reaches `pyo3`, directly or through another package;
5555
- a crate below `sqlbuild-analysis` reaches polyglot.
5656

57-
The same check fails when the workspace version, the `pyproject.toml` version and
58-
`.release-please-manifest.json` disagree, or when a workspace crate's `Cargo.lock` entry carries a
59-
version other than its manifest's, because the version is part of the build identity.
57+
The same check fails when the `sqlbuild-cli` and `sqlbuild-python` versions, the `pyproject.toml`
58+
version and `.release-please-manifest.json` disagree, or when a workspace crate's `Cargo.lock`
59+
entry carries a version other than its manifest's.
6060

6161
`fensu check` applies the Rust structure rules inside each crate: other crates use items through
6262
`main/` entry points, `models.rs`, `types.rs` and `constants.rs`, not through `_helpers/`.
@@ -113,5 +113,8 @@ playground project on Windows.
113113
`cargo test -p <crate>` or for all crates with `cargo test --workspace`.
114114
- The build identity (`sqlbuild._native.BUILD_IDENTITY`) hashes the sources of every crate in
115115
this directory, so editing any crate invalidates the native caches keyed on it.
116-
- maturin builds `crates/sqlbuild-python`; the release version lives in
117-
`[workspace.package]` and is shared by every crate.
116+
- maturin builds `crates/sqlbuild-python`; the release version lives in the `sqlbuild-cli` and
117+
`sqlbuild-python` manifests. Every other crate inherits the fixed `[workspace.package]` version,
118+
because a crate's version is part of its Cargo build identity: a shared release version would
119+
recompile every crate after each release. Read the release version from those two crates, not
120+
from `CARGO_PKG_VERSION` in a lower crate.

‎crates/sqlbuild-cli/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlbuild-cli"
3-
version.workspace = true
3+
version = "0.187.3"
44
description = "The native `sqb` executable: reused compiles and Python-free commands served without Python, every other command handed to the Python CLI."
55
edition.workspace = true
66
license-file = "LICENSE"

‎crates/sqlbuild-python/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sqlbuild-python"
3-
version.workspace = true
3+
version = "0.187.3"
44
description = "The sqlbuild._native Python extension module."
55
edition.workspace = true
66
license.workspace = true

‎crates/sqlbuild-python/src/bindings/_helpers/recall/clickhouse_store.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ impl ClickHouseLocation {
7474
database: Some(database.to_owned()),
7575
retention_days: retention,
7676
cluster: None,
77+
producer_version: env!("CARGO_PKG_VERSION").to_owned(),
7778
},
7879
}
7980
}

‎crates/sqlbuild-python/src/bindings/_helpers/recall/command.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ fn run_schema_ddl(py: Python<'_>, settings: &RecallSettings) -> PyResult<i32> {
338338
database: None,
339339
retention_days: settings.retention_days,
340340
cluster: None,
341+
producer_version: env!("CARGO_PKG_VERSION").to_owned(),
341342
};
342343
let statements = if path.exists() {
343344
open_sqlite_store(path, OpenMode::ReadOnly)

‎crates/sqlbuild-python/src/bindings/_helpers/recall/session.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ fn permission_notice(
348348
database,
349349
retention_days: settings.retention_days,
350350
cluster: None,
351+
producer_version: env!("CARGO_PKG_VERSION").to_owned(),
351352
};
352353
let database_missing: bool = options
353354
.database

0 commit comments

Comments
 (0)