Skip to content

Commit 84ef441

Browse files
authored
use drift to detect API compatibility (#1)
Use https://docs.rs/drift (written by ahl) to detect whether two documents are wire-compatible. I've tested this out with the changes introduced in newtype-uuid 1.3.0, and it appears to correctly detect that they're wire-identical (yay).
1 parent b63cfa6 commit 84ef441

File tree

10 files changed

+598
-41
lines changed

10 files changed

+598
-41
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ jobs:
4646
RUSTFLAGS: -D warnings
4747
steps:
4848
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49+
# The e2e-example tests require origin/main to be present.
50+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
51+
with:
52+
ref: main
4953
- uses: dtolnay/rust-toolchain@master
5054
with:
5155
toolchain: ${{ matrix.rust-version }}

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ atomicwrites = "0.4.4"
2121
camino = "1.2.0"
2222
clap = "4.5"
2323
debug-ignore = "1.0.5"
24+
drift = "0.1.0"
2425
dropshot = "0.16.4"
2526
dropshot-api-manager = { path = "crates/dropshot-api-manager", version = "0.2.0" }
2627
dropshot-api-manager-types = { path = "crates/dropshot-api-manager-types", version = "0.2.0" }

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ impl ApiSpecFileName {
132132
}
133133
}
134134

135+
/// For versioned APIs, returns the version part of the filename
136+
pub fn version(&self) -> Option<&semver::Version> {
137+
match &self.kind {
138+
ApiSpecFileNameKind::Lockstep => None,
139+
ApiSpecFileNameKind::Versioned { version, .. } => Some(version),
140+
}
141+
}
142+
135143
/// For versioned APIs, returns the hash part of the filename
136144
pub fn hash(&self) -> Option<&str> {
137145
match &self.kind {

crates/dropshot-api-manager/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ atomicwrites.workspace = true
1515
camino.workspace = true
1616
clap = { workspace = true, features = ["cargo", "derive", "env"] }
1717
debug-ignore.workspace = true
18+
drift.workspace = true
1819
dropshot.workspace = true
1920
fs-err.workspace = true
2021
hex.workspace = true

0 commit comments

Comments
 (0)