Skip to content

Use workspace inheritance feature for common fields#1413

Closed
HCastano wants to merge 6 commits intomasterfrom
hc-workspace-inheritance
Closed

Use workspace inheritance feature for common fields#1413
HCastano wants to merge 6 commits intomasterfrom
hc-workspace-inheritance

Conversation

@HCastano
Copy link
Copy Markdown
Contributor

@HCastano HCastano commented Sep 23, 2022

This is a feature that was added in Rust 1.64.0
and allows us to reduce a bit of duplication that exists across our crates.

We may also want to do this for the examples, but we should sort out #1410 first.

Ah, looks like the Rust version in the CI isn't up to date yet 😆

I've also updated the nightly version used by the dylint step in order to have the workspace inheritance
feature enabled.

@HCastano
Copy link
Copy Markdown
Contributor Author

Right now this is failing during the linting step of the example contract build due to an
old nightly which doesn't support workspace inheritance.

I noticed thatcargo-contract builds the dylint driver using the ink! 4.0.0-alpha.3
release, as seen here.

pub fn with_dylint(&mut self) -> Result<&mut Self> {
    let ink_dylint = {
        let mut map = value::Table::new();
        map.insert("git".into(), "https://github.com/paritytech/ink/".into());
        map.insert("tag".into(), "v4.0.0-alpha.3".into());
        map.insert("pattern".into(), "linting/".into());
        value::Value::Table(map)
    };
...

The release is still using an old toolchain file which points to nightly-2022-06-30 which explains
the build failure.

In order to work around this I've patched cargo-contract to instead use the hc-workspace-inheritance
branch (so this PR) which has been updated to use a more recent nightly.

map.insert("branch".into(), "hc-workspace-inheritance".into());

However, when trying to use that patched cargo-contract the example build ends up failing unexpectedly.

❯ cargo clean && RUST_LOG=trace cargo contract build
2022-09-27T21:21:45.578309Z DEBUG cargo_contract::crate_metadata: Fetching cargo metadata for Cargo.toml
2022-09-27T21:21:46.159917Z DEBUG cargo_contract::cmd::build: Contract version: Version { major: 4, minor: 0, patch: 0, pre: Prerelease("alpha.3") }
 [1/6] Checking ink! linting rules
... snip ...
[2022-09-27T21:21:46Z TRACE cargo::sources::git::source] getting packages for package ID `trait-incrementer v4.0.0-alpha.3 (https://github.com/paritytech/ink/?branch=hc-workspace-inheritance#d60a0dc6)` from `GitRemote { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("github.com")), port: None, path: "/paritytech/ink/", query: None, fragment: None } }`
[2022-09-27T21:21:46Z TRACE cargo::sources::path] getting packages; id=trait-incrementer v4.0.0-alpha.3 (https://github.com/paritytech/ink/?branch=hc-workspace-inheritance#d60a0dc6)
[2022-09-27T21:21:46Z DEBUG dylint_internal::command] [("RUSTC", None), ("RUSTUP_TOOLCHAIN", None)]
[2022-09-27T21:21:46Z DEBUG dylint_internal::command] Some("/Users/hcastano/.cargo/git/checkouts/ink-1add513eda8f5a89/d60a0dc/linting")
[2022-09-27T21:21:46Z DEBUG dylint_internal::command] "rustup" "show" "active-toolchain"
[2022-09-27T21:21:46Z DEBUG dylint_internal::command] [("RUSTC", None), ("RUSTUP_TOOLCHAIN", None)]
[2022-09-27T21:21:46Z DEBUG dylint_internal::command] Some("/Users/hcastano/.cargo/git/checkouts/ink-1add513eda8f5a89/d60a0dc/linting")
[2022-09-27T21:21:46Z DEBUG dylint_internal::command] "cargo" "build" "--release" "--target-dir" "/Users/hcastano/Workspace/ParityTech/ink/examples/contract-terminate/target/ink/dylint/libraries/nightly-2022-08-11-aarch64-apple-darwin"
[2022-09-27T21:21:52Z DEBUG dylint_internal::command] [("RUSTC", None), ("RUSTUP_TOOLCHAIN", None)]
[2022-09-27T21:21:52Z DEBUG dylint_internal::command] Some("/var/folders/g9/_vhwpplx0jv_07rh238bvjw80000gn/T/.tmpmJwSWt")
[2022-09-27T21:21:52Z DEBUG dylint_internal::command] "rustup" "which" "rustc"
[2022-09-27T21:21:52Z DEBUG dylint_internal::command] [("RUSTC", None), ("RUSTFLAGS", Some("-C link-args=-Wl,-rpath,/Users/hcastano/.rustup/toolchains/nightly-2022-08-11-aarch64-apple-darwin/lib")), ("RUSTUP_TOOLCHAIN", None)]
[2022-09-27T21:21:52Z DEBUG dylint_internal::command] Some("/var/folders/g9/_vhwpplx0jv_07rh238bvjw80000gn/T/.tmpmJwSWt")
[2022-09-27T21:21:52Z DEBUG dylint_internal::command] "cargo" "build"
Error: command failed: "cargo" "build"
ERROR: `"/Users/hcastano/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo" "dylint" "--lib=ink_linting" "--quiet"` failed with exit code: Some(1)

@ascjones, @athei do you guys have any idea about what's going wrong here?

@ascjones
Copy link
Copy Markdown
Collaborator

ascjones commented Jan 3, 2023

@HCastano lmk when this is ready for review again

@HCastano HCastano marked this pull request as draft January 17, 2023 02:15
@HCastano HCastano closed this Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants