paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.85k stars 670 forks source link

pallet-fast-unstake fails to compile during publish #145

Open Morganamilo opened 1 year ago

Morganamilo commented 1 year ago

Is there an existing issue?

Experiencing problems? Have you tried our Stack Exchange first?

Description of bug

pallet-fast-unstake fails to compile during publish

The macro seems to use some path that changes when cargo publish is running the build compared to a normal build.

Steps to reproduce

You can't publish the crate normally. As Path deps are used. Use the following frame/fast-unstake/Cargo.toml if trying to reproduce:

[package]
name = "pallet-fast-unstake"
version = "20.1.0-dev.2"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "FRAME fast unstake pallet"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }

frame-support = { version = "21.1.0-dev.2", default-features = false, path = "../support" }
frame-system = { version = "21.1.0-dev.2", default-features = false, path = "../system" }

sp-io = { version = "23.1.0-dev.2", default-features = false, path = "../../primitives/io" }
sp-runtime = { version = "24.1.0-dev.2", default-features = false, path = "../../primitives/runtime" }
sp-std = { version = "8.1.0-dev.2", default-features = false, path = "../../primitives/std" }
sp-staking = { default-features = false, path = "../../primitives/staking", version = "19.1.0-dev.2" }
frame-election-provider-support = { default-features = false, path = "../election-provider-support", version = "21.1.0-dev.2" }

frame-benchmarking = { version = "21.1.0-dev.2", default-features = false, optional = true, path = "../benchmarking" }

docify = "0.1.13"

[dev-dependencies]
pallet-staking-reward-curve = { path = "../staking/reward-curve" }
sp-core = { default-features = false, path = "../../primitives/core" }
substrate-test-utils = { path = "../../test-utils" }
sp-tracing = { path = "../../primitives/tracing" }
pallet-staking = { path = "../staking" }
pallet-balances = { path = "../balances" }
pallet-timestamp = { path = "../timestamp" }

[features]
default = ["std"]
std = [
    "codec/std",
    "log/std",
    "scale-info/std",

    "frame-support/std",
    "frame-system/std",

    "sp-io/std",
    "sp-staking/std",
    "sp-runtime/std",
    "sp-std/std",

    "frame-election-provider-support/std",

    "frame-benchmarking/std",
]
runtime-benchmarks = [
    "frame-benchmarking/runtime-benchmarks",
    "frame-system/runtime-benchmarks",
    "sp-staking/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]

I'm basing this off the last monthly tag. I'm unable to check if this also happens on master as the publish prep has not been ran on that branch.

% git checkout monthly-2023-07
% cargo build -p  pallet-fast-unstake                
    Finished dev [unoptimized + debuginfo] target(s) in 0.39s
% cargo publish -p  pallet-fast-unstake --allow-dirty --dry-run
    Updating crates.io index
   Packaging pallet-fast-unstake v20.1.0-dev.2 (/Users/morganamilo/git/parity/substrate/frame/fast-unstake)
   Verifying pallet-fast-unstake v20.1.0-dev.2 (/Users/morganamilo/git/parity/substrate/frame/fast-unstake)
    Updating crates.io index
   Compiling pallet-fast-unstake v20.1.0-dev.2 (/Users/morganamilo/rust/target/package/pallet-fast-unstake-20.1.0-dev.2)
error: Could not read the specified path '/Users/morganamilo/rust/target/package/pallet-fast-unstake-20.1.0-dev.2/frame/fast-unstake/src/tests.rs'.
  --> src/lib.rs:74:25
   |
74 | #![doc = docify::embed!("frame/fast-unstake/src/tests.rs", successful_multi_queue)]
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Could not read the specified path '/Users/morganamilo/rust/target/package/pallet-fast-unstake-20.1.0-dev.2/frame/fast-unstake/src/tests.rs'.
  --> src/lib.rs:77:25
   |
77 | #![doc = docify::embed!("frame/fast-unstake/src/tests.rs", exposed_nominator_cannot_unstake)]
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `pallet-fast-unstake` (lib) due to 2 previous errors
error: failed to verify package tarball
kianenigma commented 1 year ago

@sam0x17

kianenigma commented 1 year ago

I think we need to bump the version of docify.

Morganamilo commented 1 year ago

After more testing, this issue applies to pallet-fast-unstake too.

sam0x17 commented 1 year ago

This needs to be updated to use crate-relative paths as outlined in https://github.com/sam0x17/docify/releases/tag/v0.2.0

ggwpez commented 1 year ago

Master branch already does this https://github.com/paritytech/substrate/blob/6d19bc2d15f96fe513671568ec66e8b21aaed031/frame/fast-unstake/src/lib.rs#L74

Would it be possible to have a cargo publish --dry-run CI to ensure that all our crates are always in a releseable state?

sam0x17 commented 1 year ago

Would it be possible to have a cargo publish --dry-run CI to ensure that all our crates are always in a releseable state?

I think that would be a really good idea

That said, the crate-relative paths thing like above should fail even in a normal build