Skip to content

Commit ad5eff1

Browse files
chore(ci): install vdev via --manifest-path; drop VDEV_VERSION pin (#25456)
Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
1 parent 1821290 commit ad5eff1

3 files changed

Lines changed: 45 additions & 13 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ inputs:
7373
vdev:
7474
required: false
7575
default: true
76-
description: "Install vdev CLI tool via cargo binstall (uses VDEV_VERSION pinned in prepare.sh)."
76+
description: "Install vdev CLI tool via cargo binstall (version from vdev/Cargo.toml)."
7777

7878
# prepare.sh - npm
7979
markdownlint-cli2:
@@ -239,7 +239,7 @@ runs:
239239
~/.cargo/bin/dd-rust-license-tool
240240
~/.cargo/bin/wasm-pack
241241
~/.cargo/bin/vdev
242-
key: ${{ runner.os }}-cargo-binaries-${{ hashFiles('scripts/environment/*.sh') }}
242+
key: ${{ runner.os }}-cargo-binaries-${{ hashFiles('scripts/environment/*.sh', 'vdev/Cargo.toml') }}
243243
restore-keys: |
244244
${{ runner.os }}-cargo-binaries-
245245

scripts/environment/prepare.sh

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ CARGO_LLVM_COV_VERSION="0.8.4"
3939
WASM_PACK_VERSION="0.13.1"
4040
# npm tool versions are defined in scripts/environment/npm-tools/package.json
4141
# and pinned (including transitive deps) in npm-tools/package-lock.json.
42-
VDEV_VERSION="0.3.3"
4342

4443
ALL_MODULES=(
4544
rustup
@@ -122,11 +121,13 @@ contains_module() {
122121
}
123122

124123
# Helper function to check version and install if needed
125-
# Usage: maybe_install_cargo_tool <tool-name> <version> [<version-check-pattern>]
124+
# Usage: maybe_install_cargo_tool <tool-name> [<version> [<version-check-pattern>]]
126125
# Note: cargo-* tools are invoked as "cargo <subcommand>", not as direct binaries
126+
# vdev omits the version argument: binstall reads it from vdev/Cargo.toml via
127+
# --manifest-path, which also provides the pkg-url so crates.io is not consulted.
127128
maybe_install_cargo_tool() {
128129
local tool="$1"
129-
local version="$2"
130+
local version="${2:-}"
130131
local version_pattern="${3:-${tool} ${version}}" # Default to "tool version"
131132

132133
if ! contains_module "$tool"; then
@@ -139,11 +140,42 @@ maybe_install_cargo_tool() {
139140
version_cmd="cargo ${tool#cargo-}"
140141
fi
141142

142-
# vdev fails fast on missing prebuilts so a cache/asset miss can't
143-
# reintroduce the source-compile path that previously stalled a release.
144-
local installer=("${install[@]}")
145-
if [[ "$tool" == "vdev" && "${installer[0]}" == "binstall" ]]; then
146-
installer+=(--disable-strategies compile)
143+
# vdev: binstall reads the version and pkg-url from vdev/Cargo.toml via
144+
# --manifest-path, so vdev/Cargo.toml is the single source of truth.
145+
# `--disable-strategies compile` skips binstall's own crates.io compile
146+
# fallback (which would fail anyway on an unpublished version, and
147+
# silently slow-paths a cache flake into a multi-minute build). If
148+
# binstall fails for any reason — missing prebuilt for a freshly bumped
149+
# version, or a transient cache/network issue — we fall back to building
150+
# from the working tree. That gives PRs that bump vdev's version a
151+
# working binary built from their own changes, and keeps master CI green
152+
# in the gap between merging a vdev version bump and pushing the tag.
153+
if [[ "$tool" == "vdev" ]]; then
154+
# Skip the install entirely when the cached binary already matches the
155+
# version in vdev/Cargo.toml (the setup workflow restores ~/.cargo/bin/vdev
156+
# from cache, but not binstall's resolution metadata, so without this check
157+
# every job with `vdev: true` would re-hit GitHub releases).
158+
local cargo_toml_version
159+
cargo_toml_version=$(grep -E '^version = ' vdev/Cargo.toml | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
160+
if vdev --version 2>/dev/null | grep -q "^vdev ${cargo_toml_version}$"; then
161+
echo "vdev ${cargo_toml_version} already installed"
162+
return 0
163+
fi
164+
165+
local installer=("${install[@]}")
166+
if [[ "${installer[0]}" == "binstall" ]]; then
167+
installer+=(--disable-strategies compile)
168+
if ! cargo "${installer[@]}" --manifest-path vdev/Cargo.toml vdev; then
169+
echo "binstall failed; building vdev from the working tree..."
170+
cargo install -f --path vdev --locked
171+
fi
172+
else
173+
# binstall unavailable. `cargo install vdev` (no version) would resolve
174+
# against crates.io and could pick an older version than the checkout
175+
# declares; install from the working tree to match vdev/Cargo.toml.
176+
cargo install -f --path vdev --locked
177+
fi
178+
return 0
147179
fi
148180

149181
if ! $version_cmd --version 2>/dev/null | grep -q "^${version_pattern}"; then
@@ -163,7 +195,7 @@ maybe_install_cargo_tool() {
163195
fi
164196
fi
165197
if [[ "$should_install" == "true" ]]; then
166-
cargo "${installer[@]}" "$tool" --version "$version" --force --locked
198+
cargo "${install[@]}" "$tool" --version "$version" --force --locked
167199
fi
168200
fi
169201

@@ -289,6 +321,6 @@ maybe_install_cargo_tool cargo-hack "${CARGO_HACK_VERSION}"
289321
maybe_install_cargo_tool cargo-llvm-cov "${CARGO_LLVM_COV_VERSION}"
290322
maybe_install_cargo_tool dd-rust-license-tool "${DD_RUST_LICENSE_TOOL_VERSION}"
291323
maybe_install_cargo_tool wasm-pack "${WASM_PACK_VERSION}"
292-
maybe_install_cargo_tool vdev "${VDEV_VERSION}"
324+
maybe_install_cargo_tool vdev
293325

294326
maybe_install_npm_tools

vdev/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CI installs vdev from a published binary release via [cargo-binstall](https://gi
3939
./scripts/environment/prepare.sh --modules=vdev
4040
```
4141

42-
This pins the vdev version defined in `prepare.sh` and fetches the matching pre-compiled binary.
42+
This installs the vdev version declared in `vdev/Cargo.toml` by fetching the matching pre-compiled binary from the GitHub release. If no matching release exists yet — e.g. you're on a branch that bumped the version but hasn't been tagged — `prepare.sh` falls back to building vdev from your working tree (`cargo install --path vdev`), which is slower but ensures the installed binary reflects your branch's vdev source.
4343

4444
For a quick install of the latest published vdev (not pinned):
4545

0 commit comments

Comments
 (0)