Open joao-paulo-parity opened 2 years ago
@joao-paulo-parity
I suggest trying cargo-hack we are using it in jsonrpsee for instance but I reckon that it's quite slow and not sure if that is "acceptable" in substrate.
https://github.com/paritytech/jsonrpsee/blob/master/.github/workflows/ci.yml#L68-#L92
I suggest trying cargo-hack we are using it in jsonrpsee for instance
Thanks for the hint. I also found a similar one at https://github.com/frewsxcv/cargo-all-features#usage.
I reckon that it's quite slow and not sure if that is "acceptable" in substrate.
I think we could use something that just prints the crates and their features, then process that output to generate the commands for a given execution strategy. Perhaps contributing a --print
feature to those projects for this purpose would be worthwhile.
I've played a bit with a script for that idea
cargo metadata --quiet --format-version=1 | jq -r '
. as $in |
paths | select(
.[0]=="packages" and
.[-1]=="source" and
(. | length == 3) and
. as $p | $in | getpath($p)==null # .source == null for workspace crates
) as $crate_path |
del($crate_path[-1]) as $crate_path |
$in | getpath($crate_path) |
.features | if type == "array" then
$in | getpath($crate_path) | .name, [$in | getpath($crate_path + ["features"]) | .[]]
else
$in | getpath($crate_path) | .name, [$in | getpath($crate_path + ["features"]) | keys | .[]]
end
'
I don't know if that is enough (looks like there's some special handling in https://github.com/taiki-e/cargo-hack/blob/4ccbb89b4f91e8d79a999280d3b0c22c3d30df24/src/features.rs#L46-L60) or if it's correct, but it could be a starting point.
I don't know if that is enough (looks like there's some special handling in https://github.com/taiki-e/cargo-hack/blob/4ccbb89b4f91e8d79a999280d3b0c22c3d30df24/src/features.rs#L46-L60) or if it's correct, but it could be a starting point.
oh didn't know that then it makes sense not to use it for substrate where not all crates are published on crates.io
Problem: feature checks are hardcoded at the moment
https://github.com/paritytech/substrate/blob/eb1a2a8e8d1a84724cdcb80f706c9b17bed6d4a7/scripts/ci/gitlab/pipeline/test.yml#L159
https://github.com/paritytech/substrate/blob/eb1a2a8e8d1a84724cdcb80f706c9b17bed6d4a7/scripts/ci/gitlab/pipeline/test.yml#L173
The current approach has at least two problems
Solution: come up with a way of automatically testing all the features provided by Substrate.
The general idea of https://github.com/paritytech/substrate/pull/12709 could be used for reference.