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
5 changes: 3 additions & 2 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,9 @@ live in [`scripts/lib/rust-release.mjs`](../scripts/lib/rust-release.mjs) and ar
3. **Bump**: the workspace version and every sibling crate's version requirement move to the
release's, then `cargo update --workspace` updates the lockfile. The commit carries them
with npm's.
4. **Pack-verify**: `cargo publish --dry-run --workspace` packages each crate and builds it
against its siblings' tarballs, so a crate that builds only from a path in the checkout
4. **Pack-verify**: `scripts/rust-publish-dry-run.sh` runs `cargo publish --dry-run --workspace`
after clearing stale unpacked copies and builds of our own crates, so each crate packages and
builds against its siblings' tarballs and a crate that builds only from a path in the checkout
fails before the confirm.
5. **Publish**, after npm: `cargo publish -p <crate>` in dependency order (`metaobjects`,
`metaobjects-render`, `metaobjects-codegen`, `metaobjects-cli`). cargo waits for each crate
Expand Down
9 changes: 4 additions & 5 deletions scripts/ci-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -993,14 +993,13 @@ gate_rust_example() {
cargo test --locked -q --manifest-path examples/rust-service/Cargo.toml
}
# The crates are publishable (ADR-0065 Amendment 3), so a change that would make `cargo publish`
# refuse them fails here, not on the day somebody publishes: package all three, build each
# refuse them fails here, not on the day somebody publishes: package all four, build each
# from its packaged copy, and stop short of uploading. --allow-dirty because this checks the
# packaging, not the working tree; nothing is uploaded, ever, by this gate. Stale unpacked
# copies of our own crates are cleared first: cargo reuses them for the same version and would
# verify against old source (scripts/rust-clear-stale-publish-sources.sh says how).
# copies and stale builds of our own crates are cleared first: cargo reuses both for the same
# version and would verify against old source (scripts/rust-publish-dry-run.sh says how).
gate_rust_publish_dry_run() {
"$ROOT/scripts/rust-clear-stale-publish-sources.sh" "$PWD" \
&& cargo publish --dry-run --workspace --locked --allow-dirty
"$ROOT/scripts/rust-publish-dry-run.sh" "$PWD"
}
# Load time per phase and per validation pass on the 20x fitness model. Record only:
# it prints a table and never fails on a number, so a slowdown is read in the log and
Expand Down
6 changes: 4 additions & 2 deletions scripts/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,11 @@ ok(`packed deps verified: all @metaobjectsdev/* pinned to ${VERSION}`);
// --- pack-verify the crates: each packages and builds from its own tarball -------
// `--workspace` resolves the sibling crates from the tarballs it just made, so a crate that
// would only build against a path in this checkout fails here, not on crates.io.
// `--allow-dirty` because the version bump above is not committed yet.
// `--allow-dirty` because the version bump above is not committed yet. The script clears
// stale unpacked copies and stale builds of our crates first, which a re-run at the same
// version would otherwise verify against.
if (rust.publish) {
sh(`cd ${RUST_DIR} && cargo publish --dry-run --workspace --locked --allow-dirty`, { quiet: true });
sh(`scripts/rust-publish-dry-run.sh ${RUST_DIR}`, { quiet: true });
ok(`crates pack-verified: ${crates.join(", ")} @ ${VERSION}`);
}

Expand Down
44 changes: 44 additions & 0 deletions scripts/rust-publish-dry-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# `cargo publish --dry-run --workspace` that always verifies each crate against the sibling
# crates it has just packaged, whatever an earlier run left in the target directory or in
# CARGO_HOME. Nothing is uploaded. The `rust` lane (scripts/ci-local.sh) and the release
# pack-verify (scripts/release.mjs) both run it.
#
# Two kinds of stale state can make a dependency compile from old source. Both happen when
# the version stays the same while the source changes, which is every merge between releases:
#
# 1. Unpacked source. The dry run publishes each crate to a temporary overlay registry
# (<target>/package/tmp-registry) and unpacks the ones a later crate depends on into
# $CARGO_HOME/registry/src/-<hash>/<name>-<version>/. cargo never unpacks again once
# that directory is complete. scripts/rust-clear-stale-publish-sources.sh removes the
# copies that differ from the tree.
# 2. Compiled artifacts. cargo treats a registry crate as immutable for its version, so the
# fingerprint of `metaobjects v1.3.1` from the overlay registry does not look at its
# source files: a build of it left by an earlier run is reported `Fresh` and linked into
# the next crate's verify build. A hosted runner restores server/rust/target from its
# cache, so a build made before a new module landed in `metaobjects` broke
# `metaobjects-codegen`'s verify with E0432 on some runners and not others. The dry run
# therefore uses its own target directory and removes this workspace's crates from it
# first; third-party crates stay built.
#
# crates.io's copy of the same version is not involved: the overlay registry takes
# precedence for a version it holds ("Unpacking ... (registry .../tmp-registry)").
#
# Usage: scripts/rust-publish-dry-run.sh [workspace-dir] (default server/rust)
set -euo pipefail

root="$(cd "$(dirname "$0")/.." && pwd)"
ws="$(cd "${1:-$root/server/rust}" && pwd)"
cd "$ws"
target="$ws/target/publish-verify"

"$root/scripts/rust-clear-stale-publish-sources.sh" "$ws"

members=$(cargo metadata --no-deps --format-version 1 --locked | python3 -c '
import json, sys
print(" ".join("-p " + p["name"] for p in json.load(sys.stdin)["packages"]))
')
# shellcheck disable=SC2086 # one word per `-p <name>`
cargo clean -q --locked --target-dir "$target" $members

cargo publish --dry-run --workspace --locked --allow-dirty --target-dir "$target"
4 changes: 2 additions & 2 deletions spec/decisions/ADR-0065-rust-is-the-sixth-port.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ generator list fixed are replaced. Three things change.
1. **The crates are publishable.** `publish = false` is removed from `metaobjects`,
`metaobjects-codegen` and `metaobjects-cli`, and each carries a description, a README, the
licence text, keywords, categories, a homepage and authors. Decision 4 and Owner ruling 3 are
rewritten to say so. The `rust` lane runs `cargo publish --dry-run --workspace` (the
`gate_rust_publish_dry_run` step of `scripts/ci-local.sh`): it packages all three crates and
rewritten to say so. The `rust` lane runs `scripts/rust-publish-dry-run.sh` (the
`gate_rust_publish_dry_run` step of `scripts/ci-local.sh`), which runs `cargo publish --dry-run --workspace` with stale state cleared: it packages all three crates and
builds each from its package, so a change that would make publishing refuse them fails in
review. **Nothing is published.** Publishing, reserving a crate name and the renumbering of
the workspace onto the shared 1.3.0 line each wait for the owner's go; the one crates.io name
Expand Down
Loading