diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f20beebc2c23a95472efc423ec2e4e4369b8d46..4ea682d3cd0f236349f771d5b3d5279c93188f71 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,9 +79,7 @@ test: stage: test <<: *docker-env script: - # We are temporarily removing `--all-features` here for the build to succeed - # until our substrate dependencies are released in newer versions. - - cargo test --verbose --workspace + - cargo test --verbose --workspace --all-features #### stage: build (default features) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 85ec744d0a63493c542f69e55595f26b34b505c5..b5fe972b1fe4c4656e5cbb7801fd67dbcb16badf 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -430,6 +430,9 @@ pub(crate) fn execute_with_crate_metadata( "Building cargo project".bright_green().bold() ); build_cargo_project(&crate_metadata, build_artifact, verbosity, unstable_flags)?; + if build_artifact == BuildArtifacts::CheckOnly { + return Ok((None, None)); + } maybe_println!( verbosity, " {} {}", @@ -456,7 +459,9 @@ pub(crate) fn execute_with_crate_metadata( #[cfg(feature = "test-ci-only")] #[cfg(test)] mod tests_ci_only { - use crate::{cmd, util::tests::with_tmp_dir, BuildArtifacts, ManifestPath, UnstableFlags}; + use crate::{ + cmd, util::tests::with_tmp_dir, BuildArtifacts, ManifestPath, UnstableFlags, Verbosity, + }; #[test] fn build_template() { @@ -466,30 +471,33 @@ mod tests_ci_only { ManifestPath::new(&path.join("new_project").join("Cargo.toml")).unwrap(); let res = super::execute( &manifest_path, - None, + Verbosity::Default, true, BuildArtifacts::All, UnstableFlags::default(), ) .expect("build failed"); - // we can't use `/target/ink` here, since this would match - // for `/target` being the root path. but since `ends_with` - // always matches whole path components we can be sure - // the path can never be e.g. `foo_target/ink` -- the assert - // would fail for that. - assert!(res.target_directory.ends_with("target/ink")); - assert!(res.optimization_result.unwrap().optimized_size > 0.0); + // our ci has set `CARGO_TARGET_DIR` to cache artifacts. + // this dir does not include `/target/` as a path, hence + // we can't match for e.g. `foo_project/target/ink`. + // + // we also can't match for `/ink` here, since this would match + // for `/ink` being the root path. + assert!(res.target_directory.ends_with("ink")); + + let optimized_size = res.optimization_result.unwrap().optimized_size; + assert!(optimized_size > 0.0); // our optimized contract template should always be below 3k. - assert!(res.optimization_result.unwrap().optimized_size < 3.0); + assert!(optimized_size < 3.0); Ok(()) }) } #[test] - fn check_must_not_create_target_in_project_dir() { + fn check_must_not_output_contract_artifacts_in_project_dir() { with_tmp_dir(|path| { // given cmd::new::execute("new_project", Some(path)).expect("new project creation failed"); @@ -499,7 +507,7 @@ mod tests_ci_only { // when super::execute( &manifest_path, - None, + Verbosity::Default, true, BuildArtifacts::CheckOnly, UnstableFlags::default(), @@ -508,8 +516,12 @@ mod tests_ci_only { // then assert!( - !project_dir.join("target").exists(), - "found target folder in project directory!" + !project_dir.join("target/ink/new_project.contract").exists(), + "found contract artifact in project directory!" + ); + assert!( + !project_dir.join("target/ink/new_project.wasm").exists(), + "found wasm artifact in project directory!" ); Ok(()) }) diff --git a/src/cmd/metadata.rs b/src/cmd/metadata.rs index 387e16bc6571766643f016f5d39dcea2b90288f5..18135149899aa8c7e0aa0cc5860269eca028b400 100644 --- a/src/cmd/metadata.rs +++ b/src/cmd/metadata.rs @@ -283,7 +283,7 @@ mod tests { use crate::cmd::metadata::blake2_hash; use crate::{ cmd, crate_metadata::CrateMetadata, util::tests::with_tmp_dir, BuildArtifacts, - ManifestPath, UnstableFlags, + ManifestPath, UnstableFlags, Verbosity, }; use contract_metadata::*; use serde_json::{Map, Value}; @@ -379,7 +379,7 @@ mod tests { let crate_metadata = CrateMetadata::collect(&test_manifest.manifest_path)?; let dest_bundle = cmd::metadata::execute( &test_manifest.manifest_path, - None, + Verbosity::Default, BuildArtifacts::All, UnstableFlags::default(), )? diff --git a/src/main.rs b/src/main.rs index 445d488645686d6f695f010d6fc21746dc43c33d..34188abcea623455734b4d6cb191c153e6166f0f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -315,7 +315,7 @@ enum Command { /// Command has been deprecated, use `cargo contract build` instead #[structopt(name = "generate-metadata")] GenerateMetadata {}, - /// Check that the code builds as Wasm; does not output any build artifact to the top level `target/` directory + /// Check that the code builds as Wasm; does not output any `.contract` artifact to the `target/` directory #[structopt(name = "check")] Check(CheckCommand), /// Test the smart contract off-chain diff --git a/src/util.rs b/src/util.rs index ece7a0c0b134c9a35c685593749e3ae1d8912101..c701f0abff4069fc4c8d35154bc39f9aad313246 100644 --- a/src/util.rs +++ b/src/util.rs @@ -64,7 +64,7 @@ where Verbosity::Default => &mut cmd, }; - log::info!("invoking cargo: {:?}", cmd); + log::info!("Invoking cargo: {:?}", cmd); let child = cmd // capture the stdout to return from this function as bytes