Skip to content

Commit e135d1e

Browse files
authored
Add docs.rs build check script and CI job (#188)
✍️ *Description of changes:* The [docs.rs build](https://docs.rs/crate/metrique-aggregation/latest/builds/2825680) failed for metrique aggregation because of a bug (? I am investigating) where even though the dev-dependency included the `emf` feature, it wans't available when scraping the example. This PR: 1. Fixes the issue by adding a `__build_examples` feature 2. Adds a new script and CI target that faithfully simulate docs.rs build by actually packaging each crate first 3. Adds this script to GitHub actions I verified that the github action failed before I added the fix: https://github.com/awslabs/metrique/actions/runs/21071514566/job/60602148756 🔏 *By submitting this pull request* - [x] I confirm that I've made a best effort attempt to update all relevant documentation. - [x] I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 30ac60e commit e135d1e

File tree

14 files changed

+144
-3
lines changed

14 files changed

+144
-3
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Build
22
on: [pull_request]
3+
permissions:
4+
contents: read
35

46
jobs:
57
build:
@@ -28,3 +30,13 @@ jobs:
2830
with:
2931
toolchain: ${{ matrix.toolchain }}
3032
flags: ${{ matrix.flags }}
33+
34+
docs-rs:
35+
name: Docs.rs Build Check
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: dtolnay/rust-toolchain@nightly
40+
- uses: dtolnay/install@cargo-docs-rs
41+
- name: Check docs.rs build
42+
run: ./scripts/check-docsrs.sh

Cargo.lock

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

metrique-aggregation/Cargo.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ edition = "2024"
55
rust-version = "1.89" # build.yml
66
license = "Apache-2.0"
77
description = "Library for working with unit of work metrics - aggregation"
8+
repository = "https://github.com/awslabs/metrique"
9+
readme = "README.md"
810

911
[dependencies]
10-
metrique = { path = "../metrique", version = "0.1"}
12+
metrique = { path = "../metrique", version = "0.1" }
1113
metrique-writer = { path = "../metrique-writer", version = "0.1.14" }
1214
metrique-core = { path = "../metrique-core", version = "0.1.12" }
1315
metrique-macro = { path = "../metrique-macro", version = "0.1.11" }
@@ -33,10 +35,21 @@ uuid = { version = "1", features = ["v4"] }
3335
tracing.workspace = true
3436
tracing-subscriber = { workspace = true, features = ["env-filter"] }
3537

38+
[features]
39+
# There seems to be a rustdoc bug where when a dev dependency enables a new feature, its not picked up properly
40+
__build_examples_for_rustdoc = ["metrique/emf", "metrique/test-util"]
41+
3642
# We need to name one example so that our examples that use dev-dependencies get scraped
3743
[[example]]
3844
name = "embedded"
3945
doc-scrape-examples = true
46+
requires_features = ["__build_examples_for_rustdoc"]
47+
48+
[package.metadata.docs.rs]
49+
all-features = true
50+
targets = ["x86_64-unknown-linux-gnu"]
51+
rustdoc-args = ["--cfg", "docsrs"]
52+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
4053

4154
[[bench]]
4255
name = "aggregation"

metrique-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ metrique-writer = { path = "../metrique-writer" }
2020
all-features = true
2121
targets = ["x86_64-unknown-linux-gnu"]
2222
rustdoc-args = ["--cfg", "docsrs"]
23+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

metrique-macro/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ assert2 = { workspace = true }
2929
all-features = true
3030
targets = ["x86_64-unknown-linux-gnu"]
3131
rustdoc-args = ["--cfg", "docsrs"]
32+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

metrique-metricsrs/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@ metrique-metricsrs = { path = ".", features = ["metrics-rs-024", "test-util"] }
4848
tokio = { workspace = true, features = ["macros", "test-util"] }
4949
rand = { workspace = true }
5050
rstest = { workspace = true }
51+
52+
[package.metadata.docs.rs]
53+
all-features = true
54+
targets = ["x86_64-unknown-linux-gnu"]
55+
rustdoc-args = ["--cfg", "docsrs"]
56+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

metrique-service-metrics/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ tracing-appender = { workspace = true }
2222
all-features = true
2323
targets = ["x86_64-unknown-linux-gnu"]
2424
rustdoc-args = ["--cfg", "docsrs"]
25+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

metrique-timesource/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ tokio = { workspace = true, features = ["test-util", "full"] }
2525
all-features = true
2626
targets = ["x86_64-unknown-linux-gnu"]
2727
rustdoc-args = ["--cfg", "docsrs"]
28+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

metrique-writer-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ private-test-util = ["dep:tracing"]
3838
all-features = true
3939
targets = ["x86_64-unknown-linux-gnu"]
4040
rustdoc-args = ["--cfg", "docsrs"]
41+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

metrique-writer-format-emf/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ metrics_024 = { workspace = true }
4242
all-features = true
4343
targets = ["x86_64-unknown-linux-gnu"]
4444
rustdoc-args = ["--cfg", "docsrs"]
45+
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

0 commit comments

Comments
 (0)