Fix pinning (schemars and MSRV)

Done as is single patch to make sure all the docs and CI are in sync and
correct.

We currently pin the `schemars` dependency using `<=0.8.3` as well as a
the `dyn-clone` transient dependency in the manifest (`hashes` and the
extended test crate). This is incorrect because it makes usage of the
crate klunky (or possibly impossible) if downstream users wish to use a
later version of `schemars`.

Observe also that we do not have to pin `schemars`, we do however have to pin
the `serde` crate if either `serde` or `schemars` features are enabled.
Do so in CI and document in the readme file within hashes.

Currently we have a pin remaining from the old MSRV (`syn` due to use
of `matches!`).

Fix pinning by:

- Remove pin in manifest for `schemars`
- Fix pinning for MSRV in CI and docs (this includes documenting pinning
  requirements for `schemars` feature because it is related to the other
  pin of `serde`) in both `hashes` readme and main repo readme.
This commit is contained in:
Tobin C. Harding 2023-03-07 09:39:20 +11:00
parent c8e38d6a5a
commit 6c61e1019e
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
8 changed files with 44 additions and 15 deletions

View File

@ -77,12 +77,16 @@ For more information please see `./CONTRIBUTING.md`.
This library should always compile with any combination of features on **Rust 1.48.0**.
To build with the MSRV you will need to pin some dependencies:
To build with the MSRV you will need to pin `serde` (if you have the feature enabled)
```
# serde 1.0.157 uses syn 2.0 which requires edition 2021
cargo update -p serde --precise 1.0.156
cargo update -p syn --precise 1.0.107
```
before building. (And if your code is a library, your downstream users will need to run these
commands, and so on.)
## Installing Rust
Rust can be installed using your package manager of choice or

View File

@ -27,8 +27,6 @@ fi
if cargo --version | grep "1\.48"; then
# 1.0.157 uses syn 2.0 which requires edition 2018
cargo update -p serde --precise 1.0.156
# 1.0.108 uses `matches!` macro so does not work with Rust 1.41.1, bad `syn` no biscuit.
cargo update -p syn --precise 1.0.107
fi
# We should not have any duplicate dependencies. This catches mistakes made upgrading dependencies

View File

@ -16,7 +16,6 @@ exclude = ["tests", "contrib"]
default = ["std"]
std = ["alloc", "internals/std"]
alloc = ["internals/alloc"]
schemars = ["actual-schemars", "dyn-clone"]
serde-std = ["serde/std"]
[package.metadata.docs.rs]
@ -27,13 +26,9 @@ rustdoc-args = ["--cfg", "docsrs"]
internals = { path = "../internals", package = "bitcoin-private", version = "0.1.0" }
core2 = { version = "0.3.0", default_features = false, optional = true }
schemars = { version = "0.8.3", optional = true }
# Only enable this if you explicitly do not want to use "std", otherwise enable "serde-std".
serde = { version = "1.0", default-features = false, optional = true }
# Do NOT use this as a feature! Use the `schemars` feature instead. Can only be used with "std" enabled.
actual-schemars = { package = "schemars", version = "<=0.8.3", optional = true }
# Do NOT enable this dependency, this is just to pin dyn-clone (transitive dep from schemars)
# because 1.0.8 does not build with Rust 1.41.1 (because of useage of `Arc::as_ptr`).
dyn-clone = { version = "<=1.0.7", default_features = false, optional = true }
[dev-dependencies]
serde_test = "1.0"

View File

@ -13,6 +13,18 @@ since these are needed to display hashes anway.
This library should always compile with any combination of features on **Rust 1.48.0**.
To build with the MSRV you will need to pin `serde` (if you have either the `serde` or the
`schemars` feature enabled)
```
# serde 1.0.157 uses syn 2.0 which requires edition 2021
cargo update -p serde --precise 1.0.156
```
before building. (And if your code is a library, your downstream users will need to run these
commands, and so on.)
## Contributions
Contributions are welcome, including additional hash function implementations.

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex
@ -17,6 +17,12 @@ if cargo --version | grep nightly >/dev/null; then
NIGHTLY=true
fi
# Pin dependencies as required if we are using MSRV toolchain.
if cargo --version | grep "1\.48"; then
# 1.0.157 uses syn 2.0 which requires edition 2021
cargo update -p serde --precise 1.0.156
fi
# Make all cargo invocations verbose
export CARGO_TERM_VERBOSE=true
@ -52,8 +58,12 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
cargo test --no-default-features --features="std,schemars"
fi
REPO_DIR=$(git rev-parse --show-toplevel)
if [ "$DO_SCHEMARS_TESTS" = true ]; then
(cd extended_tests/schemars && cargo test)
pushd "$REPO_DIR/hashes/extended_tests/schemars" > /dev/null
cargo test
popd > /dev/null
fi
# Build the docs if told to (this only works with the nightly toolchain)

View File

@ -13,8 +13,8 @@ path = "../.."
features = ['schemars', 'serde']
[dependencies]
jsonschema-valid = "^0.4.0"
jsonschema-valid = "0.4.0"
serde = { version = "1.0", default-features = false}
schemars = { version = "<=0.8.3"}
schemars = "0.8.3"
serde_test = "1.0"
serde_json = "1.0"

View File

@ -0,0 +1,10 @@
# Test crate for the schemars feature
Run as usual with `cargo test`.
## Minimum Supported Rust Version (MSRV)
To run the tests with the MSRV you will need to pin some dependencies:
- `cargo update -p serde --precise 1.0.156`
- `cargo update -p syn --precise 1.0.107`

View File

@ -113,7 +113,7 @@ pub mod _export {
}
#[cfg(feature = "schemars")]
extern crate actual_schemars as schemars;
extern crate schemars;
mod internal_macros;
#[macro_use]