Skip to content

Commit 66b85b7

Browse files
authored
Better error messages for lockfile conflicts (#6489)
A bit more verbose error messages for when the public API changes. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent e18f6c5 commit 66b85b7

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,19 @@ jobs:
348348
run: bash scripts/public-api.sh
349349
- name: Verify lock files are up to date
350350
run: |
351-
git diff --name-only
352-
git diff --exit-code '**/public-api.lock'
351+
if ! git diff --quiet '**/public-api.lock'; then
352+
git diff -U0 '**/public-api.lock'
353+
echo ""
354+
echo ""
355+
echo "Changed files:"
356+
git diff --name-only '**/public-api.lock'
357+
echo ""
358+
echo ""
359+
echo "Public API lock files are out of date."
360+
echo "Run './scripts/public-api.sh' locally to"
361+
echo "regenerate them, then commit the changes."
362+
exit 1
363+
fi
353364
354365
rust-coverage:
355366
name: "Rust tests (coverage) (${{ matrix.suite }})"

scripts/public-api.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44

55
set -Eeu -o pipefail
66

7+
if ! rustup run nightly rustc --version &>/dev/null; then
8+
echo "Error: nightly toolchain is not installed."
9+
echo "`cargo-public-api` requires nightly to build rustdoc JSON."
10+
echo ""
11+
echo "Install it with:"
12+
echo " rustup install nightly --profile minimal"
13+
echo ""
14+
echo "See https://crates.io/crates/cargo-public-api"
15+
exit 1
16+
fi
17+
18+
if ! cargo +nightly public-api --version &>/dev/null; then
19+
echo "Error: `cargo-public-api` is not installed."
20+
echo ""
21+
echo "Install it with:"
22+
echo " cargo +stable install cargo-public-api --locked"
23+
echo ""
24+
echo "See https://crates.io/crates/cargo-public-api"
25+
exit 1
26+
fi
27+
728
# Regenerate public-api.lock files for all published crates.
829
# Uses cargo-public-api to dump the public API surface of each crate.
930
#

0 commit comments

Comments
 (0)