From b0a753298824cdecff794889361dd0b8d85642d6 Mon Sep 17 00:00:00 2001 From: argenis de la rosa Date: Thu, 5 Mar 2026 02:38:11 -0500 Subject: [PATCH] test(docs): guard main-first contributor PR base policy --- tests/docs_pr_base_branch_consistency.rs | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/docs_pr_base_branch_consistency.rs diff --git a/tests/docs_pr_base_branch_consistency.rs b/tests/docs_pr_base_branch_consistency.rs new file mode 100644 index 000000000..0a54f82a0 --- /dev/null +++ b/tests/docs_pr_base_branch_consistency.rs @@ -0,0 +1,31 @@ +use std::fs; +use std::path::Path; + +fn read_repo_file(path: &str) -> String { + let repo_root = Path::new(env!("CARGO_MANIFEST_DIR")); + fs::read_to_string(repo_root.join(path)) + .unwrap_or_else(|err| panic!("failed to read {path}: {err}")) +} + +#[test] +fn contributor_docs_use_main_as_default_pr_base_branch() { + let contributing = read_repo_file("CONTRIBUTING.md"); + let pr_workflow = read_repo_file("docs/pr-workflow.md"); + + assert!( + contributing + .contains("Open a PR against `main` using the PR template (`dev` is used only when maintainers explicitly request integration batching)"), + "CONTRIBUTING.md must set main as the default contributor PR base" + ); + + assert!( + pr_workflow + .contains("Normal contributor PR base is `main` by default; use `dev` only when maintainers explicitly request integration batching."), + "docs/pr-workflow.md must match the main-first contributor PR base policy" + ); + + assert!( + !contributing.contains("Open a PR against `dev` using the PR template"), + "CONTRIBUTING.md still contains stale dev-first PR guidance" + ); +}