Skip to content

Commit ea331ec

Browse files
ia0exzachlyvv
andauthored
Merge the CI part of dev/changelog into main (#647)
Part of #448 and #208. --------- Co-authored-by: Zachary Vander Velden <[email protected]>
1 parent 7d5d944 commit ea331ec

File tree

13 files changed

+807
-15
lines changed

13 files changed

+807
-15
lines changed

crates/cli-tools/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Minor
1212

13+
- Add `cargo` and `changelog` modules and features
1314
- Handle more errors during platform discovery and `action::PlatformReboot`
1415
- Extend `fs::write()` first parameter to set the `OpenOptions` too
1516
- Add `error::root_cause_is()` to check the `anyhow::Error` root cause
@@ -34,4 +35,4 @@
3435

3536
## 0.1.0
3637

37-
<!-- Increment to skip CHANGELOG.md test: 6 -->
38+
<!-- Increment to skip CHANGELOG.md test: 7 -->

crates/cli-tools/Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cli-tools/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ humantime = { version = "2.1.0", default-features = false, optional = true }
2222
indicatif = { version = "0.17.8", default-features = false, optional = true }
2323
log = { version = "0.4.21", default-features = false }
2424
rusb = { version = "0.9.4", default-features = false, optional = true }
25+
semver = { version = "1.0.23", default-features = false, optional = true }
2526
serde = { version = "1.0.202", default-features = false, features = ["derive"] }
2627
toml = { version = "0.8.13", default-features = false, features = ["display", "parse"] }
2728
wasefire-wire = { version = "0.1.1-git", path = "../wire", optional = true }
@@ -57,7 +58,7 @@ optional = true
5758

5859
[features]
5960
action = [
60-
"dep:cargo_metadata",
61+
"cargo",
6162
"dep:clap",
6263
"dep:data-encoding",
6364
"dep:humantime",
@@ -69,6 +70,8 @@ action = [
6970
"dep:wasefire-wire",
7071
"tokio/time",
7172
]
73+
cargo = ["dep:cargo_metadata"]
74+
changelog = ["cargo", "dep:clap", "dep:semver"]
7275

7376
[lints]
7477
clippy.unit-arg = "allow"

crates/cli-tools/src/action.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ use std::path::{Path, PathBuf};
1717
use std::time::Duration;
1818

1919
use anyhow::{bail, ensure, Result};
20-
use cargo_metadata::{Metadata, MetadataCommand};
2120
use clap::{ValueEnum, ValueHint};
2221
use rusb::GlobalContext;
2322
use tokio::process::Command;
2423
use wasefire_protocol::{self as service, applet, Connection, ConnectionExt};
2524
use wasefire_wire::{self as wire, Yoke};
2625

26+
use crate::cargo::metadata;
2727
use crate::error::root_cause_is;
2828
use crate::{cmd, fs};
2929

@@ -633,15 +633,6 @@ pub async fn optimize_wasm(applet: impl AsRef<Path>, opt_level: Option<OptLevel>
633633
Ok(())
634634
}
635635

636-
async fn metadata(dir: impl Into<PathBuf>) -> Result<Metadata> {
637-
let dir = dir.into();
638-
let metadata =
639-
tokio::task::spawn_blocking(|| MetadataCommand::new().current_dir(dir).no_deps().exec())
640-
.await??;
641-
ensure!(metadata.packages.len() == 1, "not exactly one package");
642-
Ok(metadata)
643-
}
644-
645636
fn wasefire_feature(
646637
package: &cargo_metadata::Package, feature: &str, cargo: &mut Command,
647638
) -> Result<()> {

crates/cli-tools/src/cargo.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use std::path::PathBuf;
16+
17+
use anyhow::{ensure, Result};
18+
use cargo_metadata::{Metadata, MetadataCommand};
19+
20+
pub async fn metadata(dir: impl Into<PathBuf>) -> Result<Metadata> {
21+
let dir = dir.into();
22+
let metadata =
23+
tokio::task::spawn_blocking(|| MetadataCommand::new().current_dir(dir).no_deps().exec())
24+
.await??;
25+
ensure!(metadata.packages.len() == 1, "not exactly one package");
26+
Ok(metadata)
27+
}

0 commit comments

Comments
 (0)