Skip to content

Commit 8f6d5d9

Browse files
committed
Merge #88: Improve "infrastructure" crate wide
c691a83 Add githooks directory (Tobin C. Harding) d4191cc Improve CI pipeline (Tobin C. Harding) ef35d89 Enable build of docs with doc_auto_cfg (Tobin C. Harding) a37819b Remove default lint config options (Tobin C. Harding) 81b8201 Remove allow(bare_trait_objects) (Tobin C. Harding) 7fb1755 Remove allow(unknown_lints) (Tobin C. Harding) f5cd60e Bump MSRV to Rust 1.48.0 (Tobin C. Harding) 5962169 Do trivial cleanup to readme (Tobin C. Harding) ded35fe Use SPDX license ID (Tobin C. Harding) Pull request description: Improve various things around the crate (infrastructure for want of a better word) **Please note:** Includes bump of MSRV to 1.48.0 because arrayvec was failing with 1.41 after improving CI. EDIT: Oooooh, now I get it, arrayvec feature breaks the MSRV, regardless of if its 1.41 or 1.48 - I forgot that. I"m totally sick of rebasing this so I'm leaving the MSRV bump in there. - CI - github actions - linting - docs - githooks Patch 7 `ef35d89 Enable build of docs with doc_auto_cfg` fixes #75 ACKs for top commit: apoelstra: ACK c691a83 Tree-SHA512: 6b9f684c72e72972c8ba319bd8f2337acac3563418a0f25f9f99abbc58107c0fbd8662d8afd41ee6adec9cb81996ba439f693e12c9d61e139315261d4ce48056
2 parents d566ec4 + c691a83 commit 8f6d5d9

File tree

8 files changed

+262
-130
lines changed

8 files changed

+262
-130
lines changed

.github/workflows/rust.yml

+38-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
- name: Running test script
1818
env:
1919
DO_LINT: true
20+
DO_DOCS: true
21+
DO_FEATURE_MATRIX: true
2022
run: ./contrib/test.sh
2123

2224
Beta:
@@ -44,19 +46,20 @@ jobs:
4446
uses: dtolnay/rust-toolchain@nightly
4547
- name: Running test script
4648
env:
49+
DO_DOCSRS: true
4750
DO_FMT: true
4851
run: ./contrib/test.sh
4952

5053
MSRV:
51-
name: Test - 1.41.1 toolchain
54+
name: Test - 1.48.0 toolchain
5255
runs-on: ubuntu-latest
5356
strategy:
5457
fail-fast: false
5558
steps:
5659
- name: Checkout Crate
5760
uses: actions/checkout@v3
5861
- name: Checkout Toolchain
59-
uses: dtolnay/rust-toolchain@1.41.1
62+
uses: dtolnay/rust-toolchain@1.48.0
6063
- name: Running test script
6164
run: ./contrib/test.sh
6265

@@ -99,3 +102,36 @@ jobs:
99102
RUSTFLAGS: "-C link-arg=-Tlink.x"
100103
CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER: "qemu-system-arm -cpu cortex-m3 -machine mps2-an385 -nographic -semihosting-config enable=on,target=native -kernel"
101104
run: cd embedded/no-allocator && cargo run --target thumbv7m-none-eabi
105+
106+
Arch32bit:
107+
name: Test 32-bit version
108+
runs-on: ubuntu-latest
109+
steps:
110+
- name: Checkout Crate
111+
uses: actions/checkout@v3
112+
- name: Checkout Toolchain
113+
uses: dtolnay/rust-toolchain@stable
114+
- name: Add architecture i386
115+
run: sudo dpkg --add-architecture i386
116+
- name: Install i686 gcc
117+
run: sudo apt-get update -y && sudo apt-get install -y gcc-multilib
118+
- name: Install target
119+
run: rustup target add i686-unknown-linux-gnu
120+
- name: Run tests on i686
121+
run: cargo test --target i686-unknown-linux-gnu
122+
123+
Cross:
124+
name: Cross test
125+
if: ${{ !github.event.act }}
126+
runs-on: ubuntu-latest
127+
steps:
128+
- name: Checkout Crate
129+
uses: actions/checkout@v3
130+
- name: Checkout Toolchain
131+
uses: dtolnay/rust-toolchain@stable
132+
- name: Install target
133+
run: rustup target add s390x-unknown-linux-gnu
134+
- name: install cross
135+
run: cargo install cross --locked
136+
- name: run cross test
137+
run: cross test --target s390x-unknown-linux-gnu

Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ default = ["std"]
1616
std = ["alloc"]
1717
alloc = []
1818

19-
# Only for CI to make all warnings errors, do not activate otherwise (may break forward compatibility)
20-
strict = []
21-
2219
[dependencies.arrayvec]
2320
version = "0.7.1"
2421
default-features = false

LICENSE-MIT

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2017 Clark Moody
2+
3+
Permission is hereby granted, free of charge, to any
4+
person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the
6+
Software without restriction, including without
7+
limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software
10+
is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice
14+
shall be included in all copies or substantial portions
15+
of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.

README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Bech32 Rust
1+
Rust Bech32
2+
===========
3+
24
[![Docs.rs badge](https://docs.rs/bech32/badge.svg)](https://docs.rs/bech32/)
35
[![Continuous Integration](https://github.com/rust-bitcoin/rust-bech32/workflows/Continuous%20Integration/badge.svg)](https://github.com/rust-bitcoin/rust-bech32/actions?query=workflow%3A%22Continuous+Integration%22)
46

@@ -9,6 +11,19 @@ You can find some usage examples in the [documentation](https://docs.rs/bech32/)
911

1012
Bitcoin-specific address encoding is handled by the `bitcoin-bech32` crate.
1113

12-
# MSRV
13-
The minimum supported Rust version with the standard library is **1.41.1**.
1414

15+
## MSRV
16+
17+
This library should always compile with any combination of features excluding "arrayvec" on **Rust 1.48.0**.
18+
19+
20+
## Githooks
21+
22+
To assist devs in catching errors _before_ running CI we provide some githooks. If you do not
23+
already have locally configured githooks you can use the ones in this repository by running, in the
24+
root directory of the repository:
25+
```
26+
git config --local core.hooksPath githooks/
27+
```
28+
29+
Alternatively add symlinks in your `.git/hooks` directory to any of the githooks we provide.

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.41.1"
1+
msrv = "1.48.0"

contrib/test.sh

+32-28
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
#!/bin/sh
22
#
33
# CI test script for rust-bech32.
4-
#
5-
# The "strict" feature is used to configure cargo to deny all warnings, always use it in test runs.
64

75
set -eu
86
set -x
97

8+
# "arrayvec" feature breaks the MSRV, its added manually in DO_FEATURE_MATRIX loop below.
9+
FEATURES="std alloc"
10+
1011
# Some tests require certain toolchain types.
1112
NIGHTLY=false
12-
MIN_VERSION=false
13+
MSRV=false
1314
if cargo --version | grep nightly; then
1415
NIGHTLY=true
1516
fi
16-
if cargo --version | grep 1.41; then
17-
MIN_VERSION=true
17+
if cargo --version | grep "1\.48"; then
18+
MSRV=true
1819
fi
1920

21+
build_and_test () {
22+
cargo build --no-default-features --features="$1"
23+
cargo test --no-default-features --features="$1"
24+
}
25+
2026
# Sanity, check tools exist.
2127
cargo --version
2228
rustc --version
@@ -37,34 +43,32 @@ if [ "${DO_FMT-false}" = true ]; then
3743
cargo fmt --check
3844
fi
3945

40-
check () {
41-
cargo build --no-default-features --features="strict $1"
42-
cargo test --no-default-features --features="strict $1"
43-
}
46+
if [ "${DO_FEATURE_MATRIX-false}" = true ]; then
47+
# No features
48+
build_and_test ""
4449

45-
# Check without features ("strict" is a CI feature only, see above).
46-
check ""
47-
48-
# Check "arrayvec" feature alone.
49-
if [ "$MIN_VERSION" != true ]; then
50-
check "arrayvec"
50+
# Feature combos
51+
build_and_test "std"
52+
build_and_test "alloc"
53+
build_and_test "std alloc"
54+
# arrayvec breaks the MSRV
55+
if [ $MSRV = false
56+
]; then
57+
build_and_test "arrayvec"
58+
build_and_test "std arrayvec"
59+
build_and_test "alloc arrayvec"
60+
fi
5161
fi
5262

53-
# Check "alloc" feature alone.
54-
check "alloc"
55-
56-
# Check "alloc" & "arrayvec" features together.
57-
if [ "$MIN_VERSION" != true ]; then
58-
check "alloc arrayvec"
63+
# Build the docs if told to (this only works with the nightly toolchain)
64+
if [ "${DO_DOCSRS-false}" = true ]; then
65+
RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo +nightly doc --all-features
5966
fi
6067

61-
# Check "std" feature (implies "alloc", so this is equivalent to --all-features).
62-
cargo build --no-default-features --features="std"
63-
cargo test --no-default-features --features="std"
64-
65-
# Check "std" & "arrayvec" features together.
66-
if [ "$MIN_VERSION" != true ]; then
67-
check "std arrayvec"
68+
# Build the docs with a stable toolchain, in unison with the DO_DOCSRS command
69+
# above this checks that we feature guarded docs imports correctly.
70+
if [ "${DO_DOCS-false}" = true ]; then
71+
RUSTDOCFLAGS="-D warnings" cargo +stable doc --all-features
6872
fi
6973

7074
exit 0

githooks/pre-commit

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
#
3+
# Verify what is about to be committed. Called by "git commit" with no
4+
# arguments. The hook should exit with non-zero status after issuing an
5+
# appropriate message if it wants to stop the commit.
6+
7+
if git rev-parse --verify HEAD >/dev/null 2>&1
8+
then
9+
against=HEAD
10+
else
11+
# Initial commit: diff against an empty tree object
12+
against=$(git hash-object -t tree /dev/null)
13+
fi
14+
15+
# If you want to allow non-ASCII filenames set this variable to true.
16+
allownonascii=$(git config --bool hooks.allownonascii)
17+
18+
# Redirect output to stderr.
19+
exec 1>&2
20+
21+
# Cross platform projects tend to avoid non-ASCII filenames; prevent
22+
# them from being added to the repository. We exploit the fact that the
23+
# printable range starts at the space character and ends with tilde.
24+
if [ "$allownonascii" != "true" ] &&
25+
# Note that the use of brackets around a tr range is ok here, (it's
26+
# even required, for portability to Solaris 10's /usr/bin/tr), since
27+
# the square bracket bytes happen to fall in the designated range.
28+
test $(git diff --cached --name-only --diff-filter=A -z $against |
29+
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
30+
then
31+
cat <<\EOF
32+
Error: Attempt to add a non-ASCII file name.
33+
34+
This can cause problems if you want to work with people on other platforms.
35+
36+
To be portable it is advisable to rename the file.
37+
38+
If you know what you are doing you can disable this check using:
39+
40+
git config hooks.allownonascii true
41+
EOF
42+
exit 1
43+
fi
44+
45+
# If there are whitespace errors, print the offending file names and fail.
46+
git diff-index --check --cached $against -- || exit 1
47+
48+
# Check that code lints cleanly.
49+
cargo clippy --all-features -- -D warnings || exit 1

0 commit comments

Comments
 (0)