Skip to content

Commit 0aee130

Browse files
committed
formatting fixes + CI
1 parent 4d1260e commit 0aee130

17 files changed

Lines changed: 196 additions & 84 deletions

File tree

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# This alias is part of the OpenAPI manager example. See
33
# `../e2e-example/README.md` for more.
44
example-openapi = "run -p e2e-example-bin --"
5+
xfmt = "fmt -- --config imports_granularity=Crate --config group_imports=One --config format_code_in_doc_comments=true"

.github/renovate.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"local>oxidecomputer/renovate-config",
5+
"local>oxidecomputer/renovate-config//rust/autocreate",
6+
"local>oxidecomputer/renovate-config//actions/pin"
7+
]
8+
}

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
7+
name: CI
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
env:
14+
RUSTFLAGS: -D warnings
15+
steps:
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
- uses: dtolnay/rust-toolchain@stable
18+
with:
19+
components: rustfmt, clippy
20+
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
21+
with:
22+
key: partition-${{ matrix.partition }}
23+
- name: Lint (clippy)
24+
run: cargo clippy --all-targets
25+
- name: Lint (rustfmt)
26+
run: cargo xfmt --check
27+
- name: Run rustdoc
28+
run: just rustdoc
29+
- name: Check for differences
30+
run: git diff --exit-code
31+
32+
build-and-test:
33+
name: Build and test
34+
runs-on: ${{ matrix.os }}
35+
strategy:
36+
matrix:
37+
os: [ubuntu-latest]
38+
# 1.85 is the MSRV
39+
rust-version: ["1.85", "stable"]
40+
fail-fast: false
41+
env:
42+
RUSTFLAGS: -D warnings
43+
steps:
44+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
45+
- uses: dtolnay/rust-toolchain@master
46+
with:
47+
toolchain: ${{ matrix.rust-version }}
48+
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
49+
with:
50+
key: partition-${{ matrix.partition }}
51+
- uses: taiki-e/install-action@nextest
52+
- name: Build
53+
run: cargo build
54+
- name: Run tests
55+
run: cargo nextest run
56+
- name: Doctests
57+
run: cargo test --doc

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# adapted from https://github.com/taiki-e/cargo-hack/blob/main/.github/workflows/release.yml
2+
3+
name: Publish releases to GitHub
4+
on:
5+
push:
6+
tags:
7+
- "*"
8+
9+
jobs:
10+
dropshot-api-manager-release:
11+
if: github.repository_owner == 'oxidecomputer' && startsWith(github.ref_name, 'dropshot-api-manager-0')
12+
runs-on: ubuntu-latest
13+
environment: release
14+
permissions:
15+
id-token: write # Required for OIDC token exchange
16+
contents: write # Required for creating releases
17+
steps:
18+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
with:
20+
persist-credentials: false
21+
- uses: rust-lang/crates-io-auth-action@v1
22+
id: auth
23+
- name: Install Rust
24+
uses: dtolnay/rust-toolchain@stable
25+
- name: Install cargo release
26+
uses: taiki-e/install-action@67cc679904bee382389bf22082124fa963c6f6bd # v2
27+
with:
28+
tool: cargo-release@0.25.17,just
29+
- uses: taiki-e/create-gh-release-action@26b80501670402f1999aff4b934e1574ef2d3705 # v1
30+
with:
31+
prefix: iddqd
32+
changelog: CHANGELOG.md
33+
title: $prefix $version
34+
branch: main
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
- run: just ci-cargo-release
38+
env:
39+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

Justfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set positional-arguments
2+
3+
# Note: help messages should be 1 line long as required by just.
4+
5+
# Run cargo release in CI.
6+
ci-cargo-release:
7+
# cargo-release requires a release off a branch.
8+
git checkout -B to-release
9+
cargo release publish --publish --execute --no-confirm --workspace
10+
git checkout -
11+
git branch -D to-release

crates/dropshot-api-manager-types/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ mod validation;
1616
mod versions;
1717

1818
pub use apis::*;
19-
pub use validation::*;
20-
pub use versions::*;
21-
2219
// Re-export these types for consumers of `api_versions!`.
2320
pub use paste::paste;
2421
pub use semver;
22+
pub use validation::*;
23+
pub use versions::*;

crates/dropshot-api-manager-types/src/validation.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Copyright 2025 Oxide Computer Company
22

3-
use std::{fmt, ops::Deref};
4-
5-
use camino::Utf8PathBuf;
6-
73
use crate::{ManagedApiMetadata, Versions};
4+
use camino::Utf8PathBuf;
5+
use std::{fmt, ops::Deref};
86

97
/// Context for validation of OpenAPI specifications.
108
pub struct ValidationContext<'a> {

crates/dropshot-api-manager-types/src/versions.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,11 @@ impl<'a> ExactSizeIterator for IterVersionsSemversInner<'a> {
204204
///
205205
/// ```
206206
/// use dropshot_api_manager_types::{
207-
/// api_versions,
208-
/// SupportedVersion,
209-
/// SupportedVersions
207+
/// SupportedVersion, SupportedVersions, api_versions,
210208
/// };
211209
///
212210
/// api_versions!([
211+
/// // Define the API versions here.
213212
/// (2, ADD_FOOBAR_OPERATION),
214213
/// (1, INITIAL),
215214
/// ]);
@@ -221,10 +220,9 @@ impl<'a> ExactSizeIterator for IterVersionsSemversInner<'a> {
221220
/// these, equivalent to:
222221
///
223222
/// ```
224-
/// pub const VERSION_ADD_FOOBAR_OPERATION: semver::Version =
225-
/// semver::Version::new(2, 0, 0);
226-
/// pub const VERSION_INITIAL: semver::Version =
227-
/// semver::Version::new(1, 0, 0);
223+
/// pub const VERSION_ADD_FOOBAR_OPERATION: semver::Version =
224+
/// semver::Version::new(2, 0, 0);
225+
/// pub const VERSION_INITIAL: semver::Version = semver::Version::new(1, 0, 0);
228226
/// ```
229227
///
230228
/// It also defines a function called `pub fn supported_versions() ->

crates/dropshot-api-manager/src/cmd/debug.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Copyright 2025 Oxide Computer Company
22

3-
use dropshot_api_manager_types::ApiIdent;
4-
53
use crate::{
64
apis::ManagedApis,
75
environment::{
@@ -11,6 +9,7 @@ use crate::{
119
resolved::Resolved,
1210
spec_files_generic::{ApiFiles, AsRawFiles},
1311
};
12+
use dropshot_api_manager_types::ApiIdent;
1413
use std::collections::BTreeMap;
1514

1615
pub(crate) fn debug_impl(

crates/dropshot-api-manager/src/environment.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
//! Describes the environment the command is running in, and particularly where
44
//! different sets of specifications are loaded from
55
6-
use crate::apis::ManagedApis;
7-
use crate::git::GitRevision;
8-
use crate::output::Styles;
9-
use crate::output::headers::GENERATING;
10-
use crate::output::headers::HEADER_WIDTH;
11-
use crate::spec_files_blessed::BlessedFiles;
12-
use crate::spec_files_generated::GeneratedFiles;
13-
use crate::spec_files_local::LocalFiles;
14-
use crate::spec_files_local::walk_local_directory;
6+
use crate::{
7+
apis::ManagedApis,
8+
git::GitRevision,
9+
output::{
10+
Styles,
11+
headers::{GENERATING, HEADER_WIDTH},
12+
},
13+
spec_files_blessed::BlessedFiles,
14+
spec_files_generated::GeneratedFiles,
15+
spec_files_local::{LocalFiles, walk_local_directory},
16+
};
1517
use anyhow::Context;
16-
use camino::Utf8Component;
17-
use camino::Utf8Path;
18-
use camino::Utf8PathBuf;
18+
use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
1919
use owo_colors::OwoColorize;
2020

2121
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)