Skip to content

Commit

Permalink
easy: ci & local tests for Move external crates (MystenLabs#10623)
Browse files Browse the repository at this point in the history
## Description 

Adds a CI step for test of Move crates in our new external crates.

## Test Plan 

CI tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
oxade authored Apr 9, 2023
1 parent a406caa commit f5a3c76
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ xclippy = [
"-Wclippy::disallowed_methods",
]
xlint = "run --package x --bin x -- lint"
xtest = "run --package x --bin x -- external-crates-tests"

[build]
rustflags = ["-C", "force-frame-pointers=yes", "-C", "force-unwind-tables=yes"]
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ jobs:
run: |
pip install pyopenssl --upgrade
if [ -f narwhal/benchmark/requirements.txt ]; then pip install -r narwhal/benchmark/requirements.txt; fi
- name: External crates tests
run: |
cargo xtest
- name: cargo test
run: |
cargo nextest run --profile ci
Expand Down
34 changes: 34 additions & 0 deletions crates/x/src/external_crates_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use anyhow::anyhow;
use std::{
path::PathBuf,
process::{Command, Stdio},
};

pub fn run() -> crate::Result<()> {
// change into the external-crates/move directory
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("../../external-crates/");
std::env::set_current_dir(&path).expect("Unable to change into `external-crates` directory");

// execute a command to cd to path and run the ls command
let mut cmd = Command::new("sh")
.arg("tests.sh")
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.spawn()
.unwrap();

match cmd.wait() {
Ok(status) => {
if status.success() {
Ok(())
} else {
Err(anyhow!("failed to wait on process"))
}
}
Err(err) => Err(anyhow!("failed to wait on process: {}", err)),
}
}
5 changes: 5 additions & 0 deletions crates/x/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use anyhow::Result;
use clap::Parser;

mod external_crates_tests;
mod lint;

/// Simple program to greet a person
Expand All @@ -19,12 +20,16 @@ enum Command {
#[clap(name = "lint")]
/// Run lints
Lint(lint::Args),
#[clap(name = "external-crates-tests")]
/// Run external crate tests
ExternalCratesTests,
}

fn main() -> Result<()> {
let args = Args::parse();

match args.cmd {
Command::Lint(args) => lint::run(args),
Command::ExternalCratesTests => external_crates_tests::run(),
}
}
5 changes: 5 additions & 0 deletions external-crates/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Run tests for external crates
echo "Running Move tests in external-crates"
cd move
echo "Excluding prover and evm Move tests"
cargo nextest run -E '!package(move-to-yul) and !package(move-prover) and !test(prove) and !test(simple_build_with_docs)'

0 comments on commit f5a3c76

Please sign in to comment.