diff --git a/.cigen/config.yml b/.cigen/config.yml index 61478fe..247252c 100644 --- a/.cigen/config.yml +++ b/.cigen/config.yml @@ -27,6 +27,8 @@ input_groups: docs_examples: - "README.md" - "docs/src/content/docs/**/*.md" + - "docs/src/content/case-studies/**/*.md" + - "docs/src/content/compare/**/*.md" - "docs/src/examples/*.yml" docs: diff --git a/internal_docs/STATUS.md b/internal_docs/STATUS.md index 5945384..3d8cc84 100644 --- a/internal_docs/STATUS.md +++ b/internal_docs/STATUS.md @@ -138,7 +138,8 @@ What the code does today, checked against the code in December 2026. Where cigen - `tests/docs_examples.rs`: every YAML example in the docs (`docs/src/content/docs/`), the case studies (`docs/src/content/case-studies/`, drafts included), the compare pages (`docs/src/content/compare/`) and the README, and the homepage's config, is run through - `cigen generate`; examples of errors must fail with the error they show. + `cigen generate`; examples of errors must fail with the error they show. Every file it reads must be an input of + cigen's own `test` job. - `tests/module_scenarios.rs`: a job using the `rust` module installs nothing when it skips, and reruns in mockci when a file the module contributes or its parameters change; the generated `--modules-digest` changes the hash; unknown modules and parameters fail generation with a fix. @@ -210,6 +211,9 @@ What the code does today, checked against the code in December 2026. Where cigen step now passes `toJSON(matrix)` to `cigen hash --matrix`, which mixes the entry into the job's hash. The CircleCI provider can't express a matrix or job parameters through its passthrough, and cigen's own `matrix:` gives each combination its own job, so neither has the hole. +24. Resolved (PR #53): `tests/docs_examples.rs` read the case studies (PR #40) and the compare pages (PR #55), but + cigen's own `test` job didn't have them as inputs, so a commit that broke one of their configs alone would have + skipped the test that checks it. The test now checks that every file it reads is an input of that job. ## Next diff --git a/tests/docs_examples.rs b/tests/docs_examples.rs index 9d5cc37..e95b263 100644 --- a/tests/docs_examples.rs +++ b/tests/docs_examples.rs @@ -134,3 +134,44 @@ fn a_repeated_path_starts_a_new_split_project() { let found = examples_in("page.md", page); assert_eq!(found.examples.len(), 2); } + +/// The patterns of a job's inputs, with `@group` references expanded. +fn expanded_inputs(config: &cigen::schema::CigenConfig, entries: &[String], out: &mut Vec) { + for entry in entries { + match entry.strip_prefix('@') { + Some(group) => expanded_inputs(config, &config.input_groups[group], out), + None => out.push(entry.clone()), + } + } +} + +#[test] +fn every_file_this_test_reads_is_an_input_of_cigens_test_job() { + // cigen's own CI skips its `test` job when its inputs haven't changed. A page this test + // reads that isn't an input would let a broken example skip: a false skip. + let root = support::repo_root(); + let config = cigen::config::load(&root.join(".cigen")).expect("cigen's own config loads"); + let mut patterns = Vec::new(); + expanded_inputs(&config, &config.jobs["test"].inputs, &mut patterns); + let mut inputs = std::collections::BTreeSet::new(); + for pattern in &patterns { + inputs.extend(cigen::pathspec::list_files(&root, pattern).expect("pattern matches")); + } + let read = pages() + .into_iter() + .map(|(name, _)| std::path::PathBuf::from(name)) + .chain(site_examples().into_iter().map(|path| { + path.strip_prefix(&root) + .expect("examples are in the repository") + .to_path_buf() + })); + let missing: Vec = read + .filter(|path| !inputs.contains(path)) + .map(|path| path.display().to_string()) + .collect(); + assert!( + missing.is_empty(), + "add these to the test job's inputs in .cigen/config.yml: {}", + missing.join(", ") + ); +}