Skip to content

Commit ca175ec

Browse files
Add a gh-action and buildomat jobs to cargo check on no-default-features and feature-powerset
Includes: - fixes around feature-flagging, particularly in oxql, as well as uuid-kinds, sled-storage
1 parent a043275 commit ca175ec

File tree

16 files changed

+98
-19
lines changed

16 files changed

+98
-19
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# CI scripts:
99
# - .github/buildomat/build-and-test.sh
1010
# - .github/buildomat/jobs/clippy.sh
11+
# - .github/buildomat/jobs/check-features.sh
1112
# - .github/workflows/rust.yml
1213
#
1314
[build]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
#:
3+
#: name = "check-features (helios)"
4+
#: variety = "basic"
5+
#: target = "helios-2.0"
6+
#: rust_toolchain = true
7+
#: output_rules = []
8+
9+
# Run cargo check on illumos with feature-specifics like `no-default-features`.
10+
11+
set -o errexit
12+
set -o pipefail
13+
set -o xtrace
14+
15+
cargo --version
16+
rustc --version
17+
18+
#
19+
# Set up our PATH for use with this workspace.
20+
#
21+
source ./env.sh
22+
23+
banner prerequisites
24+
ptime -m bash ./tools/install_builder_prerequisites.sh -y
25+
26+
banner check
27+
export CARGO_INCREMENTAL=0
28+
ptime -m cargo check --workspace --bins --tests --no-default-features
29+
RUSTDOCFLAGS="--document-private-items -D warnings" ptime -m cargo doc --workspace --no-deps --no-default-features
30+
31+
#
32+
# `cargo-hack` check feature-powerset
33+
#
34+
banner hack
35+
cargo hack check --workspace --feature-powerset --no-dev-deps --exclude-features image-trampoline,image-standard

.github/buildomat/jobs/clippy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# (that we want to check) is conditionally-compiled on illumos only.
1111
#
1212
# Note that `cargo clippy` includes `cargo check, so this ends up checking all
13-
# of our code.
13+
# of our (default) code.
1414

1515
set -o errexit
1616
set -o pipefail

.github/workflows/rust.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
run: cargo run --bin omicron-package -- -t default check
5454

5555
# Note that `cargo clippy` includes `cargo check, so this ends up checking all
56-
# of our code.
56+
# of our (default) code.
5757
clippy-lint:
5858
runs-on: ubuntu-22.04
5959
env:
@@ -82,6 +82,38 @@ jobs:
8282
- name: Run Clippy Lints
8383
run: cargo xtask clippy
8484

85+
check-features:
86+
runs-on: ubuntu-22.04
87+
env:
88+
CARGO_INCREMENTAL: 0
89+
steps:
90+
# This repo is unstable and unnecessary: https://github.com/microsoft/linux-package-repositories/issues/34
91+
- name: Disable packages.microsoft.com repo
92+
run: sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
93+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
94+
with:
95+
ref: ${{ github.event.pull_request.head.sha }} # see omicron#4461
96+
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
97+
if: ${{ github.ref != 'refs/heads/main' }}
98+
- name: Report cargo version
99+
run: cargo --version
100+
- name: Update PATH
101+
run: source "./env.sh"; echo "PATH=$PATH" >> "$GITHUB_ENV"
102+
- name: Print PATH
103+
run: echo $PATH
104+
- name: Print GITHUB_ENV
105+
run: cat "$GITHUB_ENV"
106+
- name: Install Pre-Requisites
107+
run: ./tools/install_builder_prerequisites.sh -y
108+
- name: Run Cargo Check (No Default Features)
109+
run: cargo check --workspace --bins --tests --no-default-features
110+
- name: Install cargo-binstall
111+
uses: taiki-e/install-action@cargo-binstall
112+
- name: Install cargo-hack
113+
run: cargo binstall cargo-hack --locked
114+
- name: Run Cargo Hack Check (Feature-Powerset, No-Dev-Deps)
115+
run: cargo hack check --workspace --feature-powerset --no-dev-deps --exclude-features image-trampoline,image-standard
116+
85117
# This is just a test build of docs. Publicly available docs are built via
86118
# the separate "rustdocs" repo.
87119
build-docs:

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nexus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ num-integer.workspace = true
5151
once_cell.workspace = true
5252
openssl.workspace = true
5353
oximeter-client.workspace = true
54-
oximeter-db.workspace = true
54+
oximeter-db = { workspace = true, default-features = false, features = [ "oxql" ] }
5555
oxnet.workspace = true
5656
parse-display.workspace = true
5757
paste.workspace = true

oximeter/db/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ clap.workspace = true
1919
dropshot.workspace = true
2020
futures.workspace = true
2121
highway.workspace = true
22+
num.workspace = true
2223
omicron-common.workspace = true
2324
omicron-workspace-hack.workspace = true
2425
oximeter.workspace = true
@@ -45,10 +46,6 @@ optional = true
4546
workspace = true
4647
optional = true
4748

48-
[dependencies.num]
49-
workspace = true
50-
optional = true
51-
5249
[dependencies.peg]
5350
workspace = true
5451
optional = true
@@ -91,6 +88,7 @@ indexmap.workspace = true
9188
itertools.workspace = true
9289
omicron-test-utils.workspace = true
9390
slog-dtrace.workspace = true
91+
sqlformat.workspace = true
9492
sqlparser.workspace = true
9593
strum.workspace = true
9694
tempfile.workspace = true
@@ -105,9 +103,11 @@ sql = [
105103
"dep:sqlparser",
106104
"dep:tabled"
107105
]
106+
oxdb = [
107+
"dep:tabled"
108+
]
108109
oxql = [
109110
"dep:crossterm",
110-
"dep:num",
111111
"dep:peg",
112112
"dep:reedline",
113113
"dep:tabled",
@@ -116,3 +116,4 @@ oxql = [
116116
[[bin]]
117117
name = "oxdb"
118118
doc = false
119+
required-features = ["oxdb"]

oximeter/db/src/bin/oxdb/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ enum Subcommand {
148148
},
149149

150150
/// Enter the Oximeter Query Language shell for interactive querying.
151+
#[cfg(feature = "oxql")]
151152
Oxql {
152153
#[clap(flatten)]
153154
opts: oximeter_db::shells::oxql::ShellOptions,
@@ -350,6 +351,7 @@ async fn main() -> anyhow::Result<()> {
350351
oximeter_db::shells::sql::shell(args.address, args.port, log, opts)
351352
.await?
352353
}
354+
#[cfg(feature = "oxql")]
353355
Subcommand::Oxql { opts } => {
354356
oximeter_db::shells::oxql::shell(args.address, args.port, log, opts)
355357
.await?

oximeter/db/src/client/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// Copyright 2024 Oxide Computer Company
88

99
pub(crate) mod dbwrite;
10+
#[cfg(any(feature = "oxql", test))]
1011
pub(crate) mod oxql;
1112
pub(crate) mod query_summary;
1213
#[cfg(any(feature = "sql", test))]

oximeter/db/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ pub mod model;
3535
#[cfg(any(feature = "oxql", test))]
3636
pub mod oxql;
3737
pub mod query;
38-
#[cfg(any(feature = "oxql", feature = "sql", test))]
38+
#[cfg(any(feature = "oxql", feature = "sql", feature = "oxdb", test))]
3939
pub mod shells;
4040
#[cfg(any(feature = "sql", test))]
4141
pub mod sql;
4242

43+
#[cfg(any(feature = "oxql", test))]
4344
pub use client::oxql::OxqlResult;
4445
pub use client::query_summary::QuerySummary;
4546
pub use client::Client;
@@ -142,10 +143,12 @@ pub enum Error {
142143
#[error("SQL error")]
143144
Sql(#[from] sql::Error),
144145

146+
#[cfg(any(feature = "oxql", test))]
145147
#[error(transparent)]
146148
Oxql(oxql::Error),
147149
}
148150

151+
#[cfg(any(feature = "oxql", test))]
149152
impl From<crate::oxql::Error> for Error {
150153
fn from(e: crate::oxql::Error) -> Self {
151154
Error::Oxql(e)

oximeter/db/src/oxql/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub use self::table::Table;
1919
pub use self::table::Timeseries;
2020
pub use anyhow::Error;
2121

22-
// Format a PEG parsing error into a nice anyhow error.
22+
/// Format a PEG parsing error into a nice anyhow error.
2323
fn fmt_parse_error(source: &str, err: PegError<LineCol>) -> Error {
2424
use std::fmt::Write;
2525
let mut out =

oximeter/db/src/query.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,12 @@ impl FieldSelector {
371371
}
372372
}
373373

374-
/// A stringly-typed selector for finding fields by name and comparsion with a given value.
374+
/// A stringly-typed selector for finding fields by name and comparsion with a
375+
/// given value.
375376
///
376-
/// This is used internally to parse comparisons written as strings, such as from the `oxdb`
377-
/// command-line tool or from another external source (Nexus API, for example).
377+
/// This is used internally to parse comparisons written as strings, such as
378+
/// from the `oxdb` command-line tool or from another external
379+
/// source (Nexus API, for example).
378380
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
379381
pub struct StringFieldSelector {
380382
name: String,

oximeter/instruments/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ http-instruments = [
3636
"dep:oximeter",
3737
"dep:schemars",
3838
"dep:serde",
39+
"dep:slog",
3940
"dep:uuid"
4041
]
4142
kstat = [

sled-storage/src/manager_test_harness.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl Drop for StorageManagerTestHarness {
123123
impl StorageManagerTestHarness {
124124
/// Creates a new StorageManagerTestHarness with no associated disks.
125125
pub async fn new(log: &Logger) -> Self {
126+
#[cfg(all(test, feature = "testing"))]
126127
illumos_utils::USE_MOCKS.store(false, Ordering::SeqCst);
127128
let tmp = camino_tempfile::tempdir_in("/var/tmp")
128129
.expect("Failed to make temporary directory");

sled-storage/src/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Pool {
2727
}
2828

2929
/// Return a Pool consisting of fake info
30-
#[cfg(feature = "testing")]
30+
#[cfg(all(test, feature = "testing"))]
3131
pub fn new_with_fake_info(name: ZpoolName, parent: DiskIdentity) -> Pool {
3232
let info = ZpoolInfo::new_hardcoded(name.to_string());
3333
Pool { name, info, parent }

uuid-kinds/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
#![cfg_attr(not(feature = "std"), no_std)]
6-
75
//! A registry for UUID kinds used in Omicron and related projects.
86
//!
97
//! See this crate's `README.adoc` for more information.
108
9+
#![cfg_attr(not(feature = "std"), no_std)]
10+
1111
// Export these types so that other users don't have to pull in newtype-uuid.
1212
#[doc(no_inline)]
1313
pub use newtype_uuid::{
1414
GenericUuid, ParseError, TagError, TypedUuid, TypedUuidKind, TypedUuidTag,
1515
};
1616

17-
#[cfg(feature = "schemars08")]
17+
#[cfg(all(feature = "schemars08", feature = "std"))]
1818
use schemars::JsonSchema;
1919

2020
macro_rules! impl_typed_uuid_kind {
2121
($($kind:ident => $tag:literal),* $(,)?) => {
2222
$(
2323
paste::paste! {
24-
#[cfg_attr(feature = "schemars08", derive(JsonSchema))]
24+
#[cfg_attr(all(feature = "schemars08", feature = "std"), derive(JsonSchema))]
2525
pub enum [< $kind Kind>] {}
2626

2727
impl TypedUuidKind for [< $kind Kind >] {

0 commit comments

Comments
 (0)