Skip to content

Add POST /api/v1/crates/{name}/{version}/rebuild_docs API endpoint #11169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4f3a33c
wip
syphar Jan 26, 2025
4e27fd9
progress
syphar Feb 22, 2025
38af5b6
disable token auth, move docs.rs call to async job
syphar May 14, 2025
2c3658a
improve error handling
syphar May 15, 2025
ec8fd74
fix intra-doc link
syphar May 15, 2025
98ce51f
move docs_rs client into separate crate, add tests with mockito
syphar May 15, 2025
f646e86
return job enqueueing errors to client
syphar May 15, 2025
cf823be
add user agent
syphar May 15, 2025
94f8d77
fix clippy error
syphar May 15, 2025
7025859
remove unused dependency
syphar May 15, 2025
6e52274
use claims library for nicer assertions
syphar May 16, 2025
de87b00
add DocsRsClient to App&Worker Context, add API tests, make config ma…
syphar May 16, 2025
2f48060
update to edition 2024
syphar May 16, 2025
47f9f7a
rename config for hostname / url
syphar May 16, 2025
157deb9
cargo fmt
syphar May 16, 2025
19ebf47
update openapi snapshot
syphar May 16, 2025
5e74b3e
drop docs.rs client from App & global Config, keep it in background e…
syphar May 16, 2025
f32f6a9
add `post` to `RequestHelper` and use it
syphar May 16, 2025
642bc0d
broken: use `.map` instead of `if let Some()`
syphar May 16, 2025
84d7ca1
fix compile errors with `as _`
syphar May 16, 2025
0e07715
only allow triggering rebuilds for crate maintainers
syphar May 17, 2025
0110d5f
docs.rs: Simplify `base_url` argument
Turbo87 May 19, 2025
962a741
docs.rs: Extract `DEFAULT_BASE_URL` constant
Turbo87 May 19, 2025
fc4338c
bin/background-worker: Simplify `RealDocsRsClient` construction
Turbo87 May 19, 2025
1016bb6
controllers/version/docs: Simplify return type
Turbo87 May 19, 2025
49b0be2
controllers/version/docs: Simplify error handling
Turbo87 May 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ crates_io_cdn_logs = { path = "crates/crates_io_cdn_logs" }
crates_io_database = { path = "crates/crates_io_database" }
crates_io_database_dump = { path = "crates/crates_io_database_dump" }
crates_io_diesel_helpers = { path = "crates/crates_io_diesel_helpers" }
crates_io_docs_rs = { path = "crates/crates_io_docs_rs" }
crates_io_env_vars = { path = "crates/crates_io_env_vars" }
crates_io_github = { path = "crates/crates_io_github" }
crates_io_index = { path = "crates/crates_io_index" }
Expand Down Expand Up @@ -138,6 +139,7 @@ utoipa-axum = "=0.2.0"

[dev-dependencies]
bytes = "=1.10.1"
crates_io_docs_rs = { path = "crates/crates_io_docs_rs", features = ["mock"] }
crates_io_github = { path = "crates/crates_io_github", features = ["mock"] }
crates_io_index = { path = "crates/crates_io_index", features = ["testing"] }
crates_io_tarball = { path = "crates/crates_io_tarball", features = ["builder"] }
Expand Down
31 changes: 31 additions & 0 deletions crates/crates_io_docs_rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "crates_io_docs_rs"
version = "0.0.0"
license = "MIT OR Apache-2.0"
edition = "2024"

[lints]
workspace = true

[features]
mock = ["dep:mockall"]

[dependencies]
anyhow = "=1.0.98"
async-trait = "=0.1.88"
crates_io_env_vars = { path = "../crates_io_env_vars" }
http = "=1.3.1"
mockall = { version = "=0.13.1", optional = true }
reqwest = { version = "=0.12.15", features = ["json"] }
serde = { version = "=1.0.219", features = ["derive"] }
thiserror = "=2.0.12"
tracing = "=0.1.41"
url = "=2.5.4"

[dev-dependencies]
claims = "=0.8.0"
serde_json = "=1.0.140"
mockito = "=1.7.0"
test-case = "=3.3.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frondeus/test-case#148

I noticed it too when I ran the tests locally 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice 😅

reason enough to drop it?

tokio = { version = "=1.45.0", features = ["macros", "rt-multi-thread"] }
tracing-subscriber = "=0.3.19"
12 changes: 12 additions & 0 deletions crates/crates_io_docs_rs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# crates_io_docs_rs

This package implements functionality for interacting with the docs.rs API.

It contains a `DocsRsClient` trait that defines the supported operations, that
the crates.io codebase needs to interact with docs.rs. The `RealDocsRsClient`
struct is an implementation of this trait that uses the `reqwest` crate to
perform the actual HTTP requests.

If the `mock` feature is enabled, a `MockDocsRsClient` struct is available,
which can be used for testing purposes. This struct is generated automatically
by the [`mockall`](https://docs.rs/mockall) crate.
18 changes: 18 additions & 0 deletions crates/crates_io_docs_rs/examples/test_docs_rs_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use anyhow::{Result, anyhow};
use crates_io_docs_rs::{DocsRsClient, RealDocsRsClient};
use std::env;

#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();

let access_token = env::args()
.nth(1)
.ok_or_else(|| anyhow!("Missing access token"))?;

let docs_rs = RealDocsRsClient::new("https://docs.rs", access_token)?;

docs_rs.rebuild_docs("empty-library", "1.0.0").await?;

Ok(())
}
Loading