ci: skip cross-target check for Cargo.lock removals (#8866)

A Cargo.lock change no longer forces the cross-target cargo check by
itself. The check runs when the lock diff adds lines, or when a removed
package is still referenced from Rust sources.

Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
Jeong, YunWon authored and GitHub committed 2026-09-28 00:03:51 +09:00
1 parent 31963fa767
commit 1bbcdad42e
1 file changed
+15 -1
+15 -1
View File
@@ -109,7 +109,6 @@ jobs:
fi
if ! git diff --quiet "${MERGE_BASE}...HEAD" -- \
':Cargo.lock' \
':rust-toolchain.toml' \
':.cargo/**' \
':.github/workflows/ci.yaml' \
@@ -163,6 +162,21 @@ jobs:
exit 0
fi
# Added or bumped packages bring new code to every target. Removed
# packages only matter while cfg-gated code still references them.
lock_diff=$(git diff -U0 "${MERGE_BASE}...HEAD" -- Cargo.lock)
if grep -Eq '^\+[^+]' <<< "${lock_diff}"; then
echo "changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
while IFS= read -r crate; do
crate=${crate//-/_}
if git grep -qE "(^|[^A-Za-z0-9_])${crate}::|(use|crate) ${crate}([^A-Za-z0-9_]|$)" -- '*.rs'; then
echo "changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
done < <(sed -n 's/^-name = "\(.*\)"$/\1/p' <<< "${lock_diff}")
# Platform cfg, or FFI crates that only exist on some targets.
platform_re='target_os|target_arch|target_family|target_env|target_vendor|target_pointer_width|target_endian|cfg\(windows\)|cfg\(unix\)|cfg\(wasi|not\(windows|not\(unix|\[target\.|\blibc::|\bnix::|windows_sys|winapi::|rustix::|std::os::'