From 2cec825e324798ff5fefda2109f83688f194dfb4 Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Wed, 26 Mar 2025 23:43:20 +0100 Subject: [PATCH 1/3] Fix initial run of snapshot tests --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e12e8ebe5..6ce5086c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -305,7 +305,7 @@ pub fn main() -> eyre::Result<()> { #[test] fn snapshot() { - std::fs::remove_dir_all(concat!(env!("CARGO_MANIFEST_DIR"), "/site")).unwrap(); + let _ = std::fs::remove_dir_all(concat!(env!("CARGO_MANIFEST_DIR"), "/site")); main().unwrap(); let timestamped_files = ["releases.json", "feed.xml"]; let inexplicably_non_deterministic_files = ["images/2023-08-rust-survey-2022/experiences.png"]; From ebf880a861ddae6367b3f32522a373bdbd1574ee Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Wed, 26 Mar 2025 23:47:04 +0100 Subject: [PATCH 2/3] Add snapshot tests in CI --- .github/workflows/snapshot_tests.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/snapshot_tests.yml diff --git a/.github/workflows/snapshot_tests.yml b/.github/workflows/snapshot_tests.yml new file mode 100644 index 000000000..1b8ee3a88 --- /dev/null +++ b/.github/workflows/snapshot_tests.yml @@ -0,0 +1,23 @@ +name: Snapshot tests +on: + pull_request + +env: + # renovate: datasource=github-tags depName=rust lookupName=rust-lang/rust + RUST_VERSION: 1.85.1 + +jobs: + snapshot-tests: + runs-on: ubuntu-latest + if: contains(github.event.pull_request.body, 'RUN_SNAPSHOT_TESTS') + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - run: rustup override set ${{ env.RUST_VERSION }} + - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 + + - run: git fetch --depth 2 + - run: git checkout origin/master + - name: Generate good snapshots + run: INSTA_OUTPUT=none INSTA_UPDATE=always cargo test -- --include-ignored + - run: git checkout $GITHUB_SHA # merge of master+branch + - run: cargo test -- --include-ignored From 32d6ed8f3daa7466620d5dd6e9dfa785eff04e9b Mon Sep 17 00:00:00 2001 From: Remo Senekowitsch Date: Thu, 27 Mar 2025 00:23:57 +0100 Subject: [PATCH 3/3] Update readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e4baf291..7dbbd7c97 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,9 @@ release = true # (to be only used for official posts about Rust releases announc If you're making changes to how the site is generated, you may want to check the impact your changes have on the output. For this purpose, there is a setup to do snapshot testing over the entire output directory. -It's not run in CI, because the number of snapshots is too large. -But you can run these tests locally as needed. + +To run these tests in CI, add the string `RUN_SNAPSHOT_TESTS` to the PR description. +You can also run these tests locally for a faster feedback cycle: - Make sure you have [cargo-insta](https://insta.rs/docs/quickstart/) installed.