Unverified Commit 4111385f authored by Michael Müller's avatar Michael Müller Committed by GitHub

Bring `test-ci-only` back (#180)

* Revert "Revert me: Remove `--all-features` (#114)"

This reverts commit 4a0d352b.

* Pass verbosity flag

* Format use

* Run tests without `binaryen-as-dependency`

* Update to `scale-info` 0.6

* Fix `value used after move`

* Do not continue processing wasm on `check`

Results in `No such file` otherwise, since
no *.wasm is generated on `check`.

* Make casing consistent for `log` messages

* Clarify behavior of `check`

* Revert me: add debug output

* Upgrade `cargo_metadata` to 0.13.1

* Fix assert for target path `target/ink`

* Revert "Revert me: add debug output"

This reverts commit d2bf1dd9.

* Revert "Upgrade `cargo_metadata` to 0.13.1"

This reverts commit 723c9b29.

* Run tests only with `binaryen-as-dependency`

* Upgrade cargo-metadata and fix usages (#210)

* Only allow new contract names beginning with an alphabetic character (#219)

* Only allow contract names beginning with an alphabetic character

* Add test for contract name beginning with a number

* Add test for contract name beginning with a number

* Run tests only with `binaryen-as-dependency`

* Refactor

* Revert "Refactor"

This reverts commit defe20db.
Co-authored-by: Andrew Jones's avatarAndrew Jones <ascjones@gmail.com>
parent d4891aae
Pipeline #128965 passed with stages
in 7 minutes and 39 seconds
......@@ -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)
......
......@@ -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(())
})
......
......@@ -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(),
)?
......
......@@ -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 `<name>.contract` artifact to the `target/` directory
#[structopt(name = "check")]
Check(CheckCommand),
/// Test the smart contract off-chain
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment