Skip to content

Commit

Permalink
[fix] hyperledger-iroha#2215: Make nightly-2022-04-20 optional for `c…
Browse files Browse the repository at this point in the history
…argo build`

Signed-off-by: Aleksandr Petrosyan <a-p-petrosyan@yandex.ru>
  • Loading branch information
appetrosyan committed May 17, 2022
1 parent 00b0722 commit 1512289
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-dev-pr-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Run tests
run: mold --run cargo test -p iroha_client --tests unstable_network --quiet
run: mold --run cargo +nightly-2022-04-20 test -p iroha_client --tests unstable_network --quiet
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-dev-pr-wasm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:

# Tests
- name: Run tests
run: mold --run cargo test --tests --quiet --no-fail-fast
run: mold --run cargo +nightly-2022-04-20 test --tests --quiet --no-fail-fast
81 changes: 45 additions & 36 deletions client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,58 @@ use std::{env, path::Path, process::Command};

#[allow(clippy::expect_used)]
fn main() {
let manifest_dir =
env::var("CARGO_MANIFEST_DIR").expect("Expected `CARGO_MANIFEST_DIR` environment variable");
let smartcontract_path =
Path::new(&manifest_dir).join("tests/integration/create_nft_for_every_user_smartcontract");
let out_dir = env::var_os("OUT_DIR").expect("Expected `OUT_DIR` environment variable");
// Build and format the smartcontract if and only if the tests are
// invoked with the nightly toolchain. We should not force our
// users to have the `nightly` if we don't use any `nightly`
// features in the actual binary.
if env::var("RUSTUP_TOOLCHAIN")
.expect("Should be defined")
.contains("nightly")
{
let manifest_dir = env::var("CARGO_MANIFEST_DIR")
.expect("Expected `CARGO_MANIFEST_DIR` environment variable");
let smartcontract_path = Path::new(&manifest_dir)
.join("tests/integration/create_nft_for_every_user_smartcontract");
let out_dir = env::var_os("OUT_DIR").expect("Expected `OUT_DIR` environment variable");

// TODO: check if this was causing the recursive loop.
// println!("cargo:rerun-if-changed=..");
// TODO: check if this was causing the recursive loop.
// println!("cargo:rerun-if-changed=..");

let fmt = Command::new("rustfmt")
.current_dir(smartcontract_path.clone())
.args(&[smartcontract_path
.join("src/lib.rs")
.to_str()
.expect("Can't convert smartcontract path to str")])
.status()
.expect("Failed to run `rustfmt` on smartcontract");
assert!(fmt.success(), "Can't format smartcontract");
let fmt = Command::new("rustfmt")
.current_dir(smartcontract_path.clone())
.args(&[smartcontract_path
.join("src/lib.rs")
.to_str()
.expect("Can't convert smartcontract path to str")])
.status()
.expect("Failed to run `rustfmt` on smartcontract");
assert!(fmt.success(), "Can't format smartcontract");

// TODO: Remove cargo invocation (#2152)
let build = Command::new("cargo")
// TODO: Remove cargo invocation (#2152)
let build = Command::new("cargo")
// Removing environment variable to avoid
// `error: infinite recursion detected` when running `cargo lints`
.env_remove("RUST_RECURSION_COUNT")
.env_remove("RUST_RECURSION_COUNT")
// Removing environment variable to avoid
// `error: `profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]``
// when running with `-C instrument-coverage`
// TODO: Check if there are no problems with that
.env_remove("CARGO_ENCODED_RUSTFLAGS")
.env("CARGO_TARGET_DIR", out_dir)
.current_dir(smartcontract_path)
.args(&[
"+nightly-2022-04-20",
"build",
"--release",
"-Z",
"build-std",
"-Z",
"build-std-features=panic_immediate_abort",
"--target",
"wasm32-unknown-unknown",
])
.status()
.expect("Failed to run `cargo build` on smartcontract");
assert!(build.success(), "Can't build smartcontract")
.env_remove("CARGO_ENCODED_RUSTFLAGS")
.env("CARGO_TARGET_DIR", out_dir)
.current_dir(smartcontract_path)
.args(&[
"+nightly-2022-04-20",
"build",
"--release",
"-Z",
"build-std",
"-Z",
"build-std-features=panic_immediate_abort",
"--target",
"wasm32-unknown-unknown",
])
.status()
.expect("Failed to run `cargo build` on smartcontract");
assert!(build.success(), "Can't build smartcontract")
}
}

0 comments on commit 1512289

Please sign in to comment.