Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ jobs:
if: steps.release.outputs.prs_created == 'true'
env:
RELEASE_BRANCH: ${{ steps.release_branch.outputs.name }}
# Release Please only bumps workspace versions, so updating the workspace entries of
# Cargo.lock is enough and needs no compile; metadata --locked proves the lock is complete.
# Release Please only bumps the sqlbuild-cli and sqlbuild-python crate versions, so updating
# the workspace entries of Cargo.lock is enough and needs no compile; metadata --locked
# proves the lock is complete.
run: |
cargo update --workspace
cargo metadata --locked --format-version 1 > /dev/null
Expand Down Expand Up @@ -198,7 +199,7 @@ jobs:

# Keep this allowlist in sync with the release metadata check in verify.yml.
unexpected_files="$(gh pr view "${RELEASE_PR}" --repo "${GITHUB_REPOSITORY}" \
--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")')"
--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")')"
if [[ -n "${unexpected_files}" ]]; then
echo "Release pull request contains non-metadata changes:" >&2
echo "${unexpected_files}" >&2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
changed_any=true
case "${path}" in
.release-please-manifest.json|CHANGELOG.md) ;;
Cargo.toml|Cargo.lock|pyproject.toml|uv.lock)
crates/sqlbuild-cli/Cargo.toml|crates/sqlbuild-python/Cargo.toml|Cargo.lock|pyproject.toml|uv.lock)
diff="$(git diff -U0 --text --no-color --no-renames "${BASE_SHA}...${HEAD_SHA}" -- "${path}")" \
|| return 1
offending="$(awk '/^@@/ { hunk = 1; next } hunk && /^[-+]/' <<< "${diff}" \
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ python-boundary = "sqlbuild-python"
polyglot-floor = "sqlbuild-analysis"

[workspace.package]
version = "0.187.3"
# Fixed on purpose: a crate's version is part of its Cargo build identity, so a shared release
# version would recompile every crate after each release. The release version lives in the
# sqlbuild-cli and sqlbuild-python manifests; see crates/README.md.
version = "0.0.0"
edition = "2024"
license = "Apache-2.0"
publish = false
Expand Down
13 changes: 8 additions & 5 deletions crates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ in `[workspace.metadata.native-layers]` in the workspace `Cargo.toml`, and
- any crate other than `sqlbuild-python` reaches `pyo3`, directly or through another package;
- a crate below `sqlbuild-analysis` reaches polyglot.

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

`fensu check` applies the Rust structure rules inside each crate: other crates use items through
`main/` entry points, `models.rs`, `types.rs` and `constants.rs`, not through `_helpers/`.
Expand Down Expand Up @@ -113,5 +113,8 @@ playground project on Windows.
`cargo test -p <crate>` or for all crates with `cargo test --workspace`.
- The build identity (`sqlbuild._native.BUILD_IDENTITY`) hashes the sources of every crate in
this directory, so editing any crate invalidates the native caches keyed on it.
- maturin builds `crates/sqlbuild-python`; the release version lives in
`[workspace.package]` and is shared by every crate.
- maturin builds `crates/sqlbuild-python`; the release version lives in the `sqlbuild-cli` and
`sqlbuild-python` manifests. Every other crate inherits the fixed `[workspace.package]` version,
because a crate's version is part of its Cargo build identity: a shared release version would
recompile every crate after each release. Read the release version from those two crates, not
from `CARGO_PKG_VERSION` in a lower crate.
2 changes: 1 addition & 1 deletion crates/sqlbuild-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlbuild-cli"
version.workspace = true
version = "0.187.3"
description = "The native `sqb` executable: reused compiles and Python-free commands served without Python, every other command handed to the Python CLI."
edition.workspace = true
license-file = "LICENSE"
Expand Down
2 changes: 1 addition & 1 deletion crates/sqlbuild-python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sqlbuild-python"
version.workspace = true
version = "0.187.3"
description = "The sqlbuild._native Python extension module."
edition.workspace = true
license.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl ClickHouseLocation {
database: Some(database.to_owned()),
retention_days: retention,
cluster: None,
producer_version: env!("CARGO_PKG_VERSION").to_owned(),
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ fn run_schema_ddl(py: Python<'_>, settings: &RecallSettings) -> PyResult<i32> {
database: None,
retention_days: settings.retention_days,
cluster: None,
producer_version: env!("CARGO_PKG_VERSION").to_owned(),
};
let statements = if path.exists() {
open_sqlite_store(path, OpenMode::ReadOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ fn permission_notice(
database,
retention_days: settings.retention_days,
cluster: None,
producer_version: env!("CARGO_PKG_VERSION").to_owned(),
};
let database_missing: bool = options
.database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub fn store_state_sql(database: &str) -> StoreStateSql {
database: Some(database.to_owned()),
retention_days: 0,
cluster: None,
producer_version: String::new(),
};
StoreStateSql {
relations: format!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const OPTIONS: fn() -> DdlOptions = || DdlOptions {
database: Some("observability".to_owned()),
retention_days: 30,
cluster: None,
producer_version: "9.8.7".to_owned(),
};

#[test]
Expand Down
8 changes: 4 additions & 4 deletions crates/sqlbuild-recall/src/schema/_helpers/version_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ fn clickhouse_version_row(options: &DdlOptions) -> String {
'{RECALL_SCHEMA_VERSION}', now64(6), '{DDL_SCRIPT_INVOCATION}', now64(6), \
{RECALL_SCHEMA_VERSION}, '{version}', now64(6), ''",
meta = clickhouse_table(table_spec(Table::Meta).name, options),
version = env!("CARGO_PKG_VERSION"),
version = options.producer_version,
)
}

/// The SQLite `recall_meta` row recording the schema version.
fn sqlite_version_row() -> String {
fn sqlite_version_row(options: &DdlOptions) -> String {
let now = "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')";
format!(
"INSERT OR IGNORE INTO \"{meta}\" (component, key, value, recorded_at, invocation_id, \
Expand All @@ -30,15 +30,15 @@ fn sqlite_version_row() -> String {
'{RECALL_SCHEMA_VERSION}', {now}, '{DDL_SCRIPT_INVOCATION}', {now}, \
{RECALL_SCHEMA_VERSION}, '{version}', {now}, '')",
meta = table_spec(Table::Meta).name,
version = env!("CARGO_PKG_VERSION"),
version = options.producer_version,
)
}

/// The insert recording this build's schema version, which a writer allowed only `SELECT` and `INSERT` may also run.
#[must_use]
pub(crate) fn version_row_statement(dialect: Dialect, options: &DdlOptions) -> String {
match dialect {
Dialect::Sqlite => sqlite_version_row(),
Dialect::Sqlite => sqlite_version_row(options),
Dialect::ClickHouse => clickhouse_version_row(options),
}
}
1 change: 1 addition & 0 deletions crates/sqlbuild-recall/src/schema/main/view_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn view_columns() -> Result<BTreeMap<&'static str, BTreeSet<String>>, String
database: None,
retention_days: 1,
cluster: None,
producer_version: String::new(),
};
connection
.execute_batch(&ddl_script(Dialect::Sqlite, &options))
Expand Down
4 changes: 3 additions & 1 deletion crates/sqlbuild-recall/src/schema/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ pub enum Table {
Conflicts,
}

/// What DDL is rendered with: database (ClickHouse), retention and cluster.
/// What DDL is rendered with: database (ClickHouse), retention, cluster and producing release.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DdlOptions {
pub database: Option<String>,
pub retention_days: u32,
pub cluster: Option<String>,
/// The sqlbuild release the schema version row records; this crate's own version is fixed.
pub producer_version: String,
}

/// The statements SQLite maintenance runs, with their positional parameters.
Expand Down
1 change: 1 addition & 0 deletions crates/sqlbuild-recall/src/schema/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) fn options(cluster: Option<&str>) -> DdlOptions {
database: Some("observability".to_owned()),
retention_days: 14,
cluster: cluster.map(str::to_owned),
producer_version: "9.8.7".to_owned(),
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/sqlbuild-recall/src/schema/tests/test_ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn given_clickhouse_statement_sets_when_rendered_then_every_statement_has_the_sh
expected_count: VIEW_NAMES.len(),
},
StatementSetTestCase {
description: "the administrator's script ends by recording the schema version",
description: "the administrator's script ends by recording the schema version and the producing release",
statements: ddl_script(Dialect::ClickHouse, &options(None))
.rsplit(";\n\n")
.take(1)
Expand All @@ -155,6 +155,7 @@ fn given_clickhouse_statement_sets_when_rendered_then_every_statement_has_the_sh
required_fragments: &[
"INSERT INTO `observability`.`recall_meta`",
"SELECT 'schema', 'schema_version', '5'",
"5, '9.8.7', now64(6)",
],
expected_count: 1,
},
Expand Down
1 change: 1 addition & 0 deletions crates/sqlbuild-recall/src/store/_helpers/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub(crate) fn sqlite_options() -> DdlOptions {
database: None,
retention_days: 0,
cluster: None,
producer_version: String::new(),
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/sqlbuild-recall/src/writer/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ pub(crate) fn core_release_store(path: &std::path::Path) {
database: None,
retention_days: 30,
cluster: None,
producer_version: "9.8.7".to_owned(),
};
std::fs::create_dir_all(path.parent().expect("the store has a directory"))
.expect("the store directory can be created");
Expand Down
Loading
Loading