Skip to content
Closed
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
74 changes: 74 additions & 0 deletions .github/workflows/scripts/patch_semver_build_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash

set -euo pipefail

# cargo-semver-checks resolves outside the workspace lock file. Repair dependency
# build failures in both current and published-baseline builds through an isolated
# Cargo home; the compared Zakura sources and API checks are unchanged.
readonly tinyvec_version=1.13.0
readonly original_cargo_home="${CARGO_HOME:-$HOME/.cargo}"
patch_root=$(mktemp -d "$RUNNER_TEMP/dependencies-semver.XXXXXX")
readonly patch_root
readonly patched_cargo_home="$patch_root/cargo-home"
readonly patched_source="$patch_root/tinyvec-$tinyvec_version"

copy_registry_source() {
local package="$1" version="$2"
cargo info "$package@$version" >/dev/null
local -a sources
mapfile -t sources < <(
find "$original_cargo_home/registry/src" -mindepth 2 -maxdepth 2 -type d \
-name "$package-$version"
)
if (( ${#sources[@]} != 1 )); then
echo "expected one $package $version source directory, found ${#sources[@]}" >&2
exit 1
fi
cp -a "${sources[0]}" "$patch_root/$package-$version"
}

copy_registry_source tinyvec "$tinyvec_version"
# Published Zakura versions cannot inherit the workspace's RocksDB feature fix.
# Give their bindgen 0.72 instance its own libclang loader, even when another
# bindgen version enables clang-sys runtime loading in the same dependency graph.
readonly rocksdb_sys_version=0.17.3+10.4.2
readonly patched_rocksdb_sys="$patch_root/librocksdb-sys-$rocksdb_sys_version"
copy_registry_source librocksdb-sys "$rocksdb_sys_version"

python3 - "$patched_source" "$patched_rocksdb_sys" <<'PYTHON'
from pathlib import Path
import sys


def replace_once(path, before, after):
text = path.read_text()
if text.count(before) != 1:
raise SystemExit(f"{path} no longer matches the expected dependency source")
path.write_text(text.replace(before, after))


# tinyvec 1.13.0 omits the alloc::vec macro import in its alloc-only build.
replace_once(
Path(sys.argv[1]) / "src/tinyvec.rs",
"use alloc::vec::{self, Vec};",
"use alloc::{vec, vec::Vec};",
)
replace_once(
Path(sys.argv[2]) / "Cargo.toml",
'[build-dependencies.bindgen]\nversion = "0.72"\ndefault-features = false\n',
'[build-dependencies.bindgen]\nversion = "0.72"\nfeatures = ["runtime"]\ndefault-features = false\n',
)
PYTHON

mkdir -p "$patched_cargo_home"
ln -s "$original_cargo_home/registry" "$patched_cargo_home/registry"
if [[ -d "$original_cargo_home/git" ]]; then
ln -s "$original_cargo_home/git" "$patched_cargo_home/git"
fi
cat > "$patched_cargo_home/config.toml" <<EOF
[patch.crates-io]
tinyvec = { path = "$patched_source" }
librocksdb-sys = { path = "$patched_rocksdb_sys" }
EOF

echo "CARGO_HOME=$patched_cargo_home" >> "$GITHUB_ENV"
44 changes: 0 additions & 44 deletions .github/workflows/scripts/patch_tinyvec_for_rustdoc.sh

This file was deleted.

16 changes: 8 additions & 8 deletions .github/workflows/semver-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ on:
- "**/Cargo.lock"
- .github/workflows/semver-checks.yml
- .github/workflows/scripts/affected_semver_packages.py
- .github/workflows/scripts/patch_tinyvec_for_rustdoc.sh
- .github/workflows/scripts/patch_semver_build_dependencies.sh
- .github/workflows/scripts/test_affected_semver_packages.py
push:
branches: [main]
Expand All @@ -49,7 +49,7 @@ on:
- "**/Cargo.lock"
- .github/workflows/semver-checks.yml
- .github/workflows/scripts/affected_semver_packages.py
- .github/workflows/scripts/patch_tinyvec_for_rustdoc.sh
- .github/workflows/scripts/patch_semver_build_dependencies.sh
- .github/workflows/scripts/test_affected_semver_packages.py

# Run in the merge queue so queued changes are revalidated against the latest
Expand Down Expand Up @@ -204,8 +204,8 @@ jobs:

- uses: ./.github/actions/setup-zakura-build

- name: Patch tinyvec for alloc-only rustdoc builds
run: .github/workflows/scripts/patch_tinyvec_for_rustdoc.sh
- name: Repair dependencies for semver builds
run: .github/workflows/scripts/patch_semver_build_dependencies.sh

- name: Check package against its stable crates.io baseline
env:
Expand Down Expand Up @@ -257,8 +257,8 @@ jobs:

- uses: ./.github/actions/setup-zakura-build

- name: Patch tinyvec for alloc-only rustdoc builds
run: .github/workflows/scripts/patch_tinyvec_for_rustdoc.sh
- name: Repair dependencies for semver builds
run: .github/workflows/scripts/patch_semver_build_dependencies.sh

- name: Install nightly rustdoc toolchain
run: rustup toolchain install nightly --profile minimal
Expand Down Expand Up @@ -307,8 +307,8 @@ jobs:

- uses: ./.github/actions/setup-zakura-build

- name: Patch tinyvec for alloc-only rustdoc builds
run: .github/workflows/scripts/patch_tinyvec_for_rustdoc.sh
- name: Repair dependencies for semver builds
run: .github/workflows/scripts/patch_semver_build_dependencies.sh

- name: Check all crates and warm published release baselines
id: warm
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ regex = "1.11"
reqwest = { version = "0.12", default-features = false }
ripemd = "0.1"
rlimit = "0.10"
rocksdb = { version = "0.24", default-features = false }
# Load libclang without relying on another crate enabling the same bindgen version.
rocksdb = { version = "0.24", default-features = false, features = ["bindgen-runtime"] }
secp256k1 = "0.29"
semver = "1.0.26"
sentry = { version = "0.47", default-features = false }
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/unreleased/905.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Fixed

- Fixed isolated state and RPC library builds that could fail to load libclang
when dependencies resolve multiple bindgen versions
([#905](https://github.com/zakura-core/zakura/pull/905)).
Loading