From 9b105f553d84902d9ab5d11c9d9e45f79dd5ad7a Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 11 May 2022 16:23:52 -0700 Subject: [PATCH] Verify that `cargo xtask publish` will work This change allows us to perform a `publish --dry-run` for each of the crates to make sure this still works. Note that `cargo xtask publish --dry-run` will use, by default, the `dynamic-linking` feature of `openvino-sys` which requires an OpenVINO installation to compile against. --- .github/workflows/main.yml | 8 ++++++-- README.md | 2 +- crates/xtask/src/publish.rs | 32 ++++++++++++++++++++------------ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f365801..72453f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,8 +66,12 @@ jobs: - uses: abrown/install-openvino-action@v3 - name: Build and run tests run: | - source /opt/intel/openvino_2022/setupvars.sh - cargo test --features openvino-sys/runtime-linking + source /opt/intel/openvino_2022/setupvars.sh + cargo test --features openvino-sys/runtime-linking + - name: Verify publish + run: | + source /opt/intel/openvino_2022/setupvars.sh + RUST_LOG=debug cargo xtask publish --dry-run # Build and test from an existing OpenVINO installation inside a Docker image (i.e. download the # binaries, then compile against these). diff --git a/README.md b/README.md index 8a7904c..3a4eec2 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Some important notes about the path passed in `OPENVINO_BUILD_DIR`: the limitations on [`cargo:rustc-link-search`]). The various OpenVINO libraries and dependencies are found using the [openvino-finder] crate. Turn on -logging to troubleshoot any issues finding the right libraries, e.g., `RUST_LOG=info +logging to troubleshoot any issues finding the right libraries, e.g., `RUST_LOG=debug OPENVINO_BUILD_DIR=... cargo build -vv`. [openvino]: https://github.com/openvinotoolkit/openvino diff --git a/crates/xtask/src/publish.rs b/crates/xtask/src/publish.rs index dcd7f5f..40f6711 100644 --- a/crates/xtask/src/publish.rs +++ b/crates/xtask/src/publish.rs @@ -42,22 +42,30 @@ impl PublishCommand { let crates_dir = path_to_crates()?; for krate in PUBLICATION_ORDER { println!("> publish {}", krate); - if !self.dry_run { - let krate_dir = crates_dir.clone().join(krate); - let exec_result = exec( - Command::new("cargo") - .arg("publish") - .arg("--no-verify") - .current_dir(&krate_dir), - ); + let krate_dir = crates_dir.clone().join(krate); + let mut command = Command::new("cargo"); + command.current_dir(&krate_dir).arg("publish"); + if self.dry_run { + command.arg("--dry-run"); + } else { + command.arg("--no-verify"); + } + + let exec_result = exec(&mut command); - // We want to continue even if a crate does not publish: this allows us to re-run - // the `publish` command if uploading one or more crates fails. - if let Err(e) = exec_result { + // We want to continue even if a crate does not publish: this allows us to re-run the + // `publish` command if uploading one or more crates fails. In `--dry-run` mode, + // however, we do want to fail the process immediately to identify any issues. + if let Err(e) = exec_result { + if self.dry_run { + panic!("Failed to publish crate {}:\n {}", krate, e); + } else { println!("Failed to publish crate {}, continuing:\n {}", krate, e); } + } - // Hopefully this gives crates.io enough time for subsequent publications to work. + // Hopefully this gives crates.io enough time for subsequent publications to work. + if !self.dry_run { sleep(Duration::from_secs(20)); } }