Skip to content

Commit 67c90dc

Browse files
committed
chore: run cargo update for patched crates in ci
1 parent d3978e6 commit 67c90dc

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

.github/workflows/test-with-openzeppelin-stellar-contracts.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,31 @@ jobs:
105105
run: |
106106
# Crates such as soroban-poseidon are pulled from crates.io and depend on
107107
# soroban-sdk from crates.io. The [workspace.dependencies] path rewrite above
108-
# cannot redirect those transitive copies, so two soroban-sdk crates get
109-
# linked, producing duplicate `panic_impl` lang item errors (E0152, #1723).
110-
# A [patch.crates-io] table redirects transitive copies to the local checkout
111-
# (valid while the local version is semver-compatible with the required one).
112-
# Reuse the crate list collected in the "Patch workspace dependencies" step.
108+
# only redirects directly named dependency edges, so those transitive copies
109+
# stay on crates.io and two soroban-sdk crates get linked -> duplicate
110+
# `panic_impl` lang item (E0152, #1723). Collapse them in two moves, both over
111+
# the crate list collected in "Patch workspace dependencies":
112+
# 1. Add a [patch.crates-io] table pointing each crate at the local checkout.
113+
# A [patch] entry adds the path crate's version to crates.io resolution,
114+
# but on its own it leaves a transitive edge the lock pinned to a
115+
# different registry version untouched.
116+
# 2. cargo update each crate so that edge re-resolves onto the patched
117+
# version, leaving a single local copy in the graph. (Can't rescue an
118+
# incompatible-major transitive dep; that would need the remedy in #1723.)
113119
if [ -s "$RUNNER_TEMP/sdk-crates.tsv" ]; then
114120
# Don't emit a second [patch.crates-io] header if one already exists upstream.
115121
grep -q '^\[patch\.crates-io\]' Cargo.toml || printf '\n[patch.crates-io]\n' >> Cargo.toml
116122
while IFS=$'\t' read -r crate dir; do
117123
rel_path=$(realpath --relative-to="." "$dir")
118124
echo "$crate = { path = \"$rel_path\" }" >> Cargo.toml
119125
done < "$RUNNER_TEMP/sdk-crates.tsv"
126+
# Re-resolve only the patched crates that are actually in the graph.
127+
graph=$(cargo metadata --format-version 1 | jq -r '.packages[].name')
128+
while IFS=$'\t' read -r crate dir; do
129+
if grep -qxF "$crate" <<< "$graph"; then
130+
cargo update -p "$crate"
131+
fi
132+
done < "$RUNNER_TEMP/sdk-crates.tsv"
120133
fi
121134
122135
- name: Diff

.github/workflows/test-with-soroban-examples.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,19 @@ jobs:
129129
- name: Patch transitive crates.io dependencies
130130
run: |
131131
# Crates such as soroban-poseidon are pulled from crates.io and depend on
132-
# soroban-sdk from crates.io. The path rewrites above cannot redirect those
133-
# transitive copies, so two soroban-sdk crates get linked, producing duplicate
134-
# `panic_impl` lang item errors (E0152, #1723). A [patch.crates-io] table in
135-
# the workspace root redirects transitive copies to the local checkout (valid
136-
# while the local version is semver-compatible with the required one).
137-
# Reuse the crate list collected in the "Patch SDK versions" step.
132+
# soroban-sdk from crates.io. The path rewrites above only redirect directly
133+
# named dependency edges, so those transitive copies stay on crates.io and two
134+
# soroban-sdk crates get linked -> duplicate `panic_impl` lang item (E0152,
135+
# #1723). Collapse them in two moves, both over the crate list collected in
136+
# "Patch SDK versions":
137+
# 1. Add a [patch.crates-io] table pointing each crate at the local checkout.
138+
# A [patch] entry adds the path crate's version to crates.io resolution,
139+
# but on its own it leaves a transitive edge the lock pinned to a
140+
# different registry version untouched.
141+
# 2. cargo update each crate so that edge re-resolves onto the patched
142+
# version, leaving a single local copy in the graph. (Can't rescue an
143+
# incompatible-major transitive dep, so the matrix exclusion is still
144+
# needed.)
138145
workspace_root=$(cargo metadata --format-version 1 --no-deps | jq -r '.workspace_root')
139146
if [ -s "$RUNNER_TEMP/sdk-crates.tsv" ]; then
140147
# Don't emit a second [patch.crates-io] header if one already exists upstream.
@@ -143,6 +150,13 @@ jobs:
143150
rel_path=$(realpath --relative-to="$workspace_root" "$crate_dir")
144151
echo "$crate = { path = \"$rel_path\" }" >> "$workspace_root/Cargo.toml"
145152
done < "$RUNNER_TEMP/sdk-crates.tsv"
153+
# Re-resolve only the patched crates that are actually in the graph.
154+
graph=$(cargo metadata --format-version 1 | jq -r '.packages[].name')
155+
while IFS=$'\t' read -r crate crate_dir; do
156+
if grep -qxF "$crate" <<< "$graph"; then
157+
cargo update -p "$crate"
158+
fi
159+
done < "$RUNNER_TEMP/sdk-crates.tsv"
146160
fi
147161
148162
- name: Diff

0 commit comments

Comments
 (0)