Skip to content

Commit e7ad5b2

Browse files
committed
Merge #22: Quiet mode and doc fixes
b2329b8 Fail the script if duplicate deps found (Nick Johnson) d588d4b Source instead of subshell extra scripts (Nick Johnson) 21b4554 Add log level environment variable (Nick Johnson) 27b9138 docs: clean up out of date docs and spelling (Nick Johnson) Pull request description: First patch cleans up some docs, the second adds a `MAINTAINER_TOOLS_LOG_LEVEL` environment variable to run the tasks in quiet mode. Went with an env var over a flag to avoid parsing. While testing this locally with rust-bitcoin, I noticed that the `do_dup_deps` test is actually failing right now. Is that by design? Here I have updated the task to `err` instead of just `say_err` to be more noticeable. But tbh, I am not quite sure the best way to "fix" rust-bitcoin in its current state. ACKs for top commit: apoelstra: utACK b2329b8 tcharding: ACK b2329b8 Tree-SHA512: 6e6293368c3bbd0061ac2a050691c6154de32eeed58499319ef3004a45f053c45fe03005e70de93563e05722477a7a09f7c9507e1da4d024876a3a8a5c7305ec
2 parents 22eff1e + b2329b8 commit e7ad5b2

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

ci/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ And for each crate there should exist a directory `REPO_DIR/CRATE/contrib/` cont
3535

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

38-
(See [Crates`](#crates) below.)
38+
(See [Crates](#crates) below.)
3939

4040
## Lock file
4141

@@ -102,22 +102,22 @@ EXAMPLES=""
102102
#### The `EXAMPLES` variable
103103

104104
```bash
105-
EXAPMLES="example:feature"
105+
EXAMPLES="example:feature"
106106
```
107107

108108
```bash
109-
EXAPMLES="example:feature1,feature2"
109+
EXAMPLES="example:feature1,feature2"
110110
```
111111

112112
```bash
113-
EXAPMLES="example_a:feature1,feature2 example_b:feature1"
113+
EXAMPLES="example_a:feature1,feature2 example_b:feature1"
114114
```
115115

116116

117117
Tip: if your example does not require any features consider using "default".
118118

119119
```bash
120-
EXAPMLES="example_a:default"
120+
EXAMPLES="example_a:default"
121121
```
122122

123123
### Additional crate specific tests
@@ -212,8 +212,7 @@ jobs:
212212
- name: "Checkout maintainer tools"
213213
uses: actions/checkout@v4
214214
with:
215-
repository: tcharding/rust-bitcoin-maintainer-tools
216-
ref: 05-02-ci
215+
repository: rust-bitcoin/rust-bitcoin-maintainer-tools
217216
path: maintainer-tools
218217
- name: "Select toolchain"
219218
uses: dtolnay/rust-toolchain@v1

ci/run_task.sh

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
# Shellcheck can't search dynamic paths
66
# shellcheck source=/dev/null
77

8-
set -euox pipefail
8+
set -euo pipefail
99

1010
REPO_DIR=$(git rev-parse --show-toplevel)
1111

12-
# Make all cargo invocations verbose.
13-
export CARGO_TERM_VERBOSE=true
14-
15-
# Set to false to turn off verbose output.
16-
flag_verbose=true
12+
# Make cargo invocations verbose unless in quiet mode.
13+
# Also control bash debug output based on log level.
14+
case "${MAINTAINER_TOOLS_LOG_LEVEL:-verbose}" in
15+
quiet)
16+
export CARGO_TERM_VERBOSE=false
17+
export CARGO_TERM_QUIET=true
18+
;;
19+
*)
20+
export CARGO_TERM_VERBOSE=true
21+
export CARGO_TERM_QUIET=false
22+
set -x
23+
;;
24+
esac
1725

1826
# Use the current `Cargo.lock` file without updating it.
1927
cargo="cargo --locked"
@@ -22,7 +30,7 @@ usage() {
2230
cat <<EOF
2331
Usage:
2432
25-
./run_task.sh CRATE TASK
33+
./run_task.sh TASK
2634
2735
TASK
2836
- stable Run tests with stable toolchain.
@@ -32,6 +40,11 @@ TASK
3240
- docs Build docs with stable toolchain.
3341
- docsrs Build docs with nightly toolchain.
3442
- bench Run the bench tests.
43+
44+
Environment Variables:
45+
MAINTAINER_TOOLS_LOG_LEVEL Control script and cargo output verbosity.
46+
verbose (default) Show all script and cargo messages.
47+
quiet Suppress script messages, reduce cargo output.
3548
EOF
3649
}
3750

@@ -161,7 +174,7 @@ do_test() {
161174

162175
if [ -e ./contrib/extra_tests.sh ];
163176
then
164-
./contrib/extra_tests.sh
177+
. ./contrib/extra_tests.sh
165178
fi
166179
}
167180

@@ -241,7 +254,7 @@ do_lint_crates() {
241254
for crate in $CRATES; do
242255
pushd "$REPO_DIR/$crate" > /dev/null
243256
if [ -e ./contrib/extra_lints.sh ]; then
244-
./contrib/extra_lints.sh
257+
. ./contrib/extra_lints.sh
245258
fi
246259
popd > /dev/null
247260
done
@@ -285,7 +298,7 @@ do_dup_deps() {
285298

286299
if [ "$duplicate_dependencies" -ne 0 ]; then
287300
cargo tree --target=all --all-features --duplicates
288-
say_err "Dependency tree is broken, contains duplicates"
301+
err "Dependency tree is broken, contains duplicates"
289302
fi
290303

291304
set -o pipefail
@@ -332,14 +345,15 @@ say() {
332345
echo "run_task: $1"
333346
}
334347

335-
say_err() {
336-
say "$1" >&2
337-
}
338-
339348
verbose_say() {
340-
if [ "$flag_verbose" = true ]; then
341-
say "$1"
342-
fi
349+
case "${MAINTAINER_TOOLS_LOG_LEVEL:-verbose}" in
350+
quiet)
351+
# Suppress verbose output.
352+
;;
353+
*)
354+
say "$1"
355+
;;
356+
esac
343357
}
344358

345359
err() {

0 commit comments

Comments
 (0)