Skip to content

Commit 8f1d3df

Browse files
authored
Merge pull request #11169 from syphar/docs-rs-trigger
Add `POST /api/v1/crates/{name}/{version}/rebuild_docs` API endpoint
2 parents 3bf1d43 + dc403b0 commit 8f1d3df

File tree

17 files changed

+659
-0
lines changed

17 files changed

+659
-0
lines changed

Cargo.lock

Lines changed: 90 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ crates_io_cdn_logs = { path = "crates/crates_io_cdn_logs" }
6666
crates_io_database = { path = "crates/crates_io_database" }
6767
crates_io_database_dump = { path = "crates/crates_io_database_dump" }
6868
crates_io_diesel_helpers = { path = "crates/crates_io_diesel_helpers" }
69+
crates_io_docs_rs = { path = "crates/crates_io_docs_rs" }
6970
crates_io_env_vars = { path = "crates/crates_io_env_vars" }
7071
crates_io_github = { path = "crates/crates_io_github" }
7172
crates_io_index = { path = "crates/crates_io_index" }
@@ -138,6 +139,7 @@ utoipa-axum = "=0.2.0"
138139

139140
[dev-dependencies]
140141
bytes = "=1.10.1"
142+
crates_io_docs_rs = { path = "crates/crates_io_docs_rs", features = ["mock"] }
141143
crates_io_github = { path = "crates/crates_io_github", features = ["mock"] }
142144
crates_io_index = { path = "crates/crates_io_index", features = ["testing"] }
143145
crates_io_tarball = { path = "crates/crates_io_tarball", features = ["builder"] }

crates/crates_io_docs_rs/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "crates_io_docs_rs"
3+
version = "0.0.0"
4+
license = "MIT OR Apache-2.0"
5+
edition = "2024"
6+
7+
[lints]
8+
workspace = true
9+
10+
[features]
11+
mock = ["dep:mockall"]
12+
13+
[dependencies]
14+
anyhow = "=1.0.98"
15+
async-trait = "=0.1.88"
16+
crates_io_env_vars = { path = "../crates_io_env_vars" }
17+
http = "=1.3.1"
18+
mockall = { version = "=0.13.1", optional = true }
19+
reqwest = { version = "=0.12.15", features = ["json"] }
20+
serde = { version = "=1.0.219", features = ["derive"] }
21+
thiserror = "=2.0.12"
22+
tracing = "=0.1.41"
23+
url = "=2.5.4"
24+
25+
[dev-dependencies]
26+
claims = "=0.8.0"
27+
serde_json = "=1.0.140"
28+
mockito = "=1.7.0"
29+
test-case = "=3.3.1"
30+
tokio = { version = "=1.45.0", features = ["macros", "rt-multi-thread"] }
31+
tracing-subscriber = "=0.3.19"

crates/crates_io_docs_rs/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# crates_io_docs_rs
2+
3+
This package implements functionality for interacting with the docs.rs API.
4+
5+
It contains a `DocsRsClient` trait that defines the supported operations, that
6+
the crates.io codebase needs to interact with docs.rs. The `RealDocsRsClient`
7+
struct is an implementation of this trait that uses the `reqwest` crate to
8+
perform the actual HTTP requests.
9+
10+
If the `mock` feature is enabled, a `MockDocsRsClient` struct is available,
11+
which can be used for testing purposes. This struct is generated automatically
12+
by the [`mockall`](https://docs.rs/mockall) crate.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use anyhow::{Result, anyhow};
2+
use crates_io_docs_rs::{DEFAULT_BASE_URL, DocsRsClient, RealDocsRsClient};
3+
use std::env;
4+
use url::Url;
5+
6+
#[tokio::main]
7+
async fn main() -> Result<()> {
8+
tracing_subscriber::fmt::init();
9+
10+
let access_token = env::args()
11+
.nth(1)
12+
.ok_or_else(|| anyhow!("Missing access token"))?;
13+
14+
let docs_rs = RealDocsRsClient::new(Url::parse(DEFAULT_BASE_URL)?, access_token);
15+
16+
docs_rs.rebuild_docs("empty-library", "1.0.0").await?;
17+
18+
Ok(())
19+
}

0 commit comments

Comments
 (0)