Skip to content

Build & upload rustdoc json output next to other docs #2827

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

Merged
merged 1 commit into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 18 additions & 1 deletion src/db/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{CrateId, update_latest_version_id};

/// List of directories in docs.rs's underlying storage (either the database or S3) containing a
/// subdirectory named after the crate. Those subdirectories will be deleted.
static LIBRARY_STORAGE_PATHS_TO_DELETE: &[&str] = &["rustdoc", "sources"];
static LIBRARY_STORAGE_PATHS_TO_DELETE: &[&str] = &["rustdoc", "rustdoc-json", "sources"];
static OTHER_STORAGE_PATHS_TO_DELETE: &[&str] = &["sources"];

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -222,6 +222,7 @@ mod tests {
use super::*;
use crate::db::ReleaseId;
use crate::registry_api::{CrateOwner, OwnerKind};
use crate::storage::rustdoc_json_path;
use crate::test::{async_wrapper, fake_release_that_failed_before_build};
use test_case::test_case;

Expand Down Expand Up @@ -405,6 +406,17 @@ mod tests {
.collect())
}

async fn json_exists(storage: &AsyncStorage, version: &str) -> Result<bool> {
storage
.exists(&rustdoc_json_path(
"a",
version,
"x86_64-unknown-linux-gnu",
crate::storage::RustdocJsonFormatVersion::Latest,
))
.await
}

let mut conn = env.async_db().await.async_conn().await;
let v1 = env
.fake_release()
Expand All @@ -426,6 +438,7 @@ mod tests {
.rustdoc_file_exists("a", "1.0.0", None, "a/index.html", archive_storage)
.await?
);
assert!(json_exists(&*env.async_storage().await, "1.0.0").await?);
let crate_id = sqlx::query_scalar!(
r#"SELECT crate_id as "crate_id: CrateId" FROM releases WHERE id = $1"#,
v1.0
Expand Down Expand Up @@ -457,6 +470,7 @@ mod tests {
.rustdoc_file_exists("a", "2.0.0", None, "a/index.html", archive_storage)
.await?
);
assert!(json_exists(&*env.async_storage().await, "2.0.0").await?);
assert_eq!(
owners(&mut conn, crate_id).await?,
vec!["Peter Rabbit".to_string()]
Expand Down Expand Up @@ -494,13 +508,16 @@ mod tests {
.await?
);
}
assert!(!json_exists(&*env.async_storage().await, "1.0.0").await?);

assert!(release_exists(&mut conn, v2).await?);
assert!(
env.async_storage()
.await
.rustdoc_file_exists("a", "2.0.0", None, "a/index.html", archive_storage)
.await?
);
assert!(json_exists(&*env.async_storage().await, "2.0.0").await?);
assert_eq!(
owners(&mut conn, crate_id).await?,
vec!["Peter Rabbit".to_string()]
Expand Down
Loading
Loading