Skip to content

Commit 22eff1e

Browse files
committed
Merge #21: Add support for running crate specific extra_lints.sh
7c6233a Update README (Jamil Lambert, PhD) 856e83d Add support for running crate specific extra_lints (Jamil Lambert, PhD) 943ca06 Remove workspace no-default-features clippy run (Jamil Lambert, PhD) 14e5c1e Fix indentation (Jamil Lambert, PhD) Pull request description: Some lints need to be run at the crate level, e.g. no-default-features dos not run correctly with clippy on a workspace. Other crate specific lints can also be useful in CI. - Fix indentation issues. - Remove the clippy run on workspace with no-default-features. - Add support for running crate specific extra_lints.sh scripts. This was all motivated by the issue rust-bitcoin/rust-bitcoin#5060 ACKs for top commit: apoelstra: utACK 7c6233a tcharding: ACK 7c6233a Tree-SHA512: 912f5d5988a27c477b0a34e3e2c525e2d353ccac3c3c1eaa01b283a8a379dad785c3227541afacca7445e10981d28b3e58225c8101b94f1bfce56309c66d3aab
2 parents c332402 + 7c6233a commit 22eff1e

File tree

2 files changed

+50
-43
lines changed

2 files changed

+50
-43
lines changed

ci/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ And for each crate there should exist a directory `REPO_DIR/CRATE/contrib/` cont
3131

3232
- `test_vars.sh`: Defines environment variables
3333
- Optional: `extra_tests.sh`: Additional test script.
34+
- Optional: `extra_lints.sh`: Additional lint script.
3435

3536
If the repository is not a workspace then per crate files go directly in `REPO_ROOT/contrib/`.
3637

ci/run_task.sh

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -72,40 +72,41 @@ main() {
7272
fi
7373

7474
case $task in
75-
stable)
76-
# Test, run examples, do feature matrix.
77-
# crate/contrib/test_vars.sh is sourced in this function.
78-
build_and_test
79-
;;
80-
81-
nightly)
82-
build_and_test
83-
;;
84-
85-
msrv)
86-
build_and_test
87-
;;
88-
89-
lint)
90-
do_lint
91-
do_dup_deps
92-
;;
93-
94-
docs)
95-
build_docs_with_stable_toolchain
96-
;;
97-
98-
docsrs)
99-
build_docs_with_nightly_toolchain
100-
;;
101-
102-
bench)
103-
do_bench
104-
;;
105-
106-
*)
107-
err "Error: unknown task $task"
108-
;;
75+
stable)
76+
# Test, run examples, do feature matrix.
77+
# crate/contrib/test_vars.sh is sourced in this function.
78+
build_and_test
79+
;;
80+
81+
nightly)
82+
build_and_test
83+
;;
84+
85+
msrv)
86+
build_and_test
87+
;;
88+
89+
lint)
90+
do_lint_workspace
91+
do_lint_crates
92+
do_dup_deps
93+
;;
94+
95+
docs)
96+
build_docs_with_stable_toolchain
97+
;;
98+
99+
docsrs)
100+
build_docs_with_nightly_toolchain
101+
;;
102+
103+
bench)
104+
do_bench
105+
;;
106+
107+
*)
108+
err "Error: unknown task $task"
109+
;;
109110
esac
110111
}
111112

@@ -228,17 +229,22 @@ loop_features() {
228229
}
229230

230231
# Lint the workspace.
231-
do_lint() {
232+
do_lint_workspace() {
232233
need_nightly
233-
234234
$cargo clippy --workspace --all-targets --all-features --keep-going -- -D warnings
235+
$cargo clippy --workspace --all-targets --keep-going -- -D warnings
236+
}
235237

236-
# Ugly hack to skip `corpec` because `node` does not build with no default features.
237-
if echo "$REPO_DIR" | grep -viq "corepc"; then
238-
# Lint various feature combinations to try and catch mistakes in feature gating.
239-
$cargo clippy --workspace --all-targets --keep-going -- -D warnings
240-
$cargo clippy --workspace --all-targets --no-default-features --keep-going -- -D warnings
241-
fi
238+
# Run extra crate specific lints, e.g. clippy with no-default-features.
239+
do_lint_crates() {
240+
need_nightly
241+
for crate in $CRATES; do
242+
pushd "$REPO_DIR/$crate" > /dev/null
243+
if [ -e ./contrib/extra_lints.sh ]; then
244+
./contrib/extra_lints.sh
245+
fi
246+
popd > /dev/null
247+
done
242248
}
243249

244250
# We should not have any duplicate dependencies. This catches mistakes made upgrading dependencies
@@ -332,7 +338,7 @@ say_err() {
332338

333339
verbose_say() {
334340
if [ "$flag_verbose" = true ]; then
335-
say "$1"
341+
say "$1"
336342
fi
337343
}
338344

0 commit comments

Comments
 (0)