Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ink_e2e] utilize contract-build crate #1523

Merged
merged 12 commits into from
Dec 7, 2022
Merged

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Nov 29, 2022

use-ink/cargo-contract#787 introduces the new contract-build library, which we can utilize here instead of depending on a user installed version of cargo-contract.

@codecov-commenter
Copy link

codecov-commenter commented Nov 30, 2022

Codecov Report

Merging #1523 (937cf24) into master (40e872a) will increase coverage by 6.61%.
The diff coverage is 0.00%.

❗ Current head 937cf24 differs from pull request most recent head 6580c3b. Consider uploading reports for the commit 6580c3b to get more accurate results

@@            Coverage Diff             @@
##           master    #1523      +/-   ##
==========================================
+ Coverage   65.08%   71.69%   +6.61%     
==========================================
  Files         204      204              
  Lines        6315     6321       +6     
==========================================
+ Hits         4110     4532     +422     
+ Misses       2205     1789     -416     
Impacted Files Coverage Δ
crates/e2e/macro/src/codegen.rs 0.00% <0.00%> (ø)
crates/allocator/src/bump.rs 86.77% <0.00%> (-3.14%) ⬇️
crates/ink/codegen/src/generator/dispatch.rs 94.19% <0.00%> (-0.43%) ⬇️
crates/metadata/src/layout/mod.rs 77.50% <0.00%> (+1.66%) ⬆️
crates/ink/ir/src/ir/attrs.rs 82.27% <0.00%> (+3.60%) ⬆️
crates/ink/ir/src/ir/item_impl/callable.rs 91.91% <0.00%> (+4.04%) ⬆️
crates/ink/ir/src/ir/trait_def/item/mod.rs 88.61% <0.00%> (+4.87%) ⬆️
crates/ink/ir/src/ir/selector.rs 87.75% <0.00%> (+8.16%) ⬆️
crates/ink/ir/src/ir/idents_lint.rs 71.42% <0.00%> (+9.52%) ⬆️
crates/storage/traits/src/layout/impls.rs 10.00% <0.00%> (+10.00%) ⬆️
... and 23 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ascjones ascjones changed the title E2E: utilize contract-build crate [ink_e2e] utilize contract-build crate Dec 1, 2022
@ascjones ascjones marked this pull request as ready for review December 1, 2022 12:52
Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you had a bigger vision in mind already with use-ink/cargo-contract#787 👌

I'd approve, but I haven't been able to build this locally on my Mac or using Docker wit the latest production CI image. I keep running into the following issue

error: custom attribute panicked
  --> lib.rs:57:9
   |
57 |         #[ink_e2e::test]
   |         ^^^^^^^^^^^^^^^^
   |
   = help: message: contract build for Cargo.toml failed: Mismatching versions of `parity-scale-codec` were found!
           Please ensure that your contract and your ink! dependencies use a compatible version of this package.

error: custom attribute panicked
   --> lib.rs:109:9
    |
109 |         #[ink_e2e::test]
    |         ^^^^^^^^^^^^^^^^
    |
    = help: message: Once instance has previously been poisoned

CI passes and local output from cargo-tree looks okay, so not sure what's up, but worth looking into before we merge this

Comment on lines 186 to 187
let manifest_path =
ManifestPath::new(path_to_cargo_toml).expect("Invalid manifest path");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention what path we tried to use

optimization_passes: Default::default(),
keep_debug_symbols: false,
lint: false,
output_type: Default::default(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was OutputType::Json before, I guess changing this is fine now since we don't manually need to parse the build output, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on this observation I've made all options explicit instead of relying on Default::default() which could yield some invisible breaking changes, e.g. I recently changed OptimizationPasses to an Option.

@ascjones
Copy link
Collaborator Author

ascjones commented Dec 2, 2022

I see you had a bigger vision in mind already with paritytech/cargo-contract#787 ok_hand

I'd approve, but I haven't been able to build this locally on my Mac or using Docker wit the latest production CI image. I keep running into the following issue

error: custom attribute panicked
  --> lib.rs:57:9
   |
57 |         #[ink_e2e::test]
   |         ^^^^^^^^^^^^^^^^
   |
   = help: message: contract build for Cargo.toml failed: Mismatching versions of `parity-scale-codec` were found!
           Please ensure that your contract and your ink! dependencies use a compatible version of this package.

error: custom attribute panicked
   --> lib.rs:109:9
    |
109 |         #[ink_e2e::test]
    |         ^^^^^^^^^^^^^^^^
    |
    = help: message: Once instance has previously been poisoned

CI passes and local output from cargo-tree looks okay, so not sure what's up, but worth looking into before we merge this

It's a misleading error, it is in fact because of using cargo +nightly test. See this issue use-ink/cargo-contract#746.

The difference now is that previously we invoked cargo +stable contract, now it uses the lib the cargo invocation inherits the +nightly so we get this error.

So the question is how to handle this. We could:

  1. Force stable toolchain on underlying contract build, even if the parent cargo invocation has a different toolchain
  2. Inherit the parent toolchain but throw a proper error ("must use stable" instead of "mismatching dependencies")
  3. Inherit the parent toolchain and allow to build with nightly (just check the minimum version)

3. is the most cargo like way to do it, but I can't remember exactly why we are enforcing using the stable toolchain.

Update: I've done 3. in use-ink/cargo-contract#848. So we can either wait for that to be merged/released, or merge this one as is and accept that it doesn't allow cargo +nightly test for now.

@HCastano
Copy link
Contributor

HCastano commented Dec 5, 2022

Sidenote, I remember why I was running the E2E tests with nightly. You can't do cargo contract test --features e2e-tests since the --features flag isn't supported by cargo-contract. I opted to run with cargo +nightly test instead (although cargo +stable test also would've worked)

Copy link
Contributor

@HCastano HCastano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -21,10 +21,11 @@ proc-macro = true

[dependencies]
ink_ir = { version = "4.0.0-beta", path = "../../ink/ir" }
contract-build = "2.0.0-beta"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can either pull in a Git dep here so that we can use +nightly again, or wait until a new version of cargo-contract is released. I'm okay with waiting for a new version of cargo-contract

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to the latest 2.0.0-beta.1 release which allows +nightly. Also --features can be passed through now anyway from the command line so you can also do cargo contract test --features e2e-tests

@ascjones
Copy link
Collaborator Author

ascjones commented Dec 6, 2022

Sidenote, I remember why I was running the E2E tests with nightly. You can't do cargo contract test --features e2e-tests since the --features flag isn't supported by cargo-contract. I opted to run with cargo +nightly test instead (although cargo +stable test also would've worked)

We should definitely pass the features through then (update see use-ink/cargo-contract#853). For me cargo test --features e2e-tests works though (without nightly), curious what requires the nightly features in this case.

@ascjones ascjones merged commit bf2de8f into master Dec 7, 2022
@ascjones ascjones deleted the aj/contract-build-lib branch December 7, 2022 10:35
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