From 7bb7dcd51096ed9b33748d2ec39d46328db56f26 Mon Sep 17 00:00:00 2001 From: hgt-bot Date: Fri, 30 Oct 2026 11:14:19 -0400 Subject: [PATCH 1/3] test: smoke-test the built release files Add `npm run test:release`, which builds imagediff.js and imagediff.min.js fresh from the files npm would publish and runs the Node, CLI and browser specs against each. With --committed it also checks that the committed build outputs match the fresh build. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + CONTRIBUTING.md | 10 +++++ README.md | 1 + make/release-check.js | 85 ++++++++++++++++++++++++++++++++++++ package.json | 1 + spec/CliSpec.js | 5 ++- spec/ImageDiffSpec.js | 3 +- spec/LoadSpec.js | 7 +-- spec/browser/jasmine.spec.js | 5 ++- spec/index.html | 6 ++- 10 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 make/release-check.js diff --git a/.gitignore b/.gitignore index 8ee27d7..0cbb491 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules test-results playwright-report +.release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4913bd1..b351a56 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,3 +20,13 @@ docs: trim local setup to the essentials ## Build outputs `imagediff.js` and `imagediff.min.js` are generated by `npm run build` and committed for releases. Rebuild and commit them only when preparing a release; ordinary PRs change `js/imagediff.js` and leave the built files alone. `npm test` runs against the source, including the CLI, so nothing needs rebuilding to test a change. + +## Releasing + +On the release PR, after `npm run build` and committing the build outputs, run: + +```sh +npm run test:release -- --committed +``` + +It smoke-tests the freshly built `imagediff.js` and `imagediff.min.js` in a page, through `require` in Node, and through the CLI, and checks that the committed build outputs match the fresh build. Publish only once it passes. diff --git a/README.md b/README.md index b8eb422..e0b33bc 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ npm test * `npm run test:node` runs the specs, including a smoke test of the `imagediff` CLI, in Node.js against [node-canvas](https://github.com/Automattic/node-canvas) (the optional `canvas` dependency, which `npm ci` installs from prebuilt binaries on common platforms). * `npm run test:browser` runs the specs in headless Chromium with Playwright. * `npm run test:serve` serves the specs at http://localhost:8085/spec/ to watch them run in a browser. +* `npm run test:release` builds the release files fresh in `.release/` (from the files npm would publish) and runs the specs against both `imagediff.js` and `imagediff.min.js`: through `require` in Node, as a ` - + From 6c4f9062a4b3156d7a779243f616b2afeca2376a Mon Sep 17 00:00:00 2001 From: hgt-bot Date: Fri, 30 Oct 2026 11:21:39 -0400 Subject: [PATCH 2/3] test: point npm test at a built file instead of staging a release copy Replace make/release-check.js and its .release/ staging with one IMAGEDIFF_LIBRARY variable that runs the Node and browser specs against a built file. test:release builds, runs npm test against both builds, and fails if the build changed the committed outputs. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 - CONTRIBUTING.md | 4 +- README.md | 3 +- make/release-check.js | 85 ------------------------------------ package.json | 2 +- spec/CliSpec.js | 5 +-- spec/ImageDiffSpec.js | 7 ++- spec/LoadSpec.js | 2 +- spec/browser/jasmine.spec.js | 6 +-- spec/index.html | 2 +- 10 files changed, 17 insertions(+), 100 deletions(-) delete mode 100644 make/release-check.js diff --git a/.gitignore b/.gitignore index 0cbb491..8ee27d7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ node_modules test-results playwright-report -.release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b351a56..8407dc1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ docs: trim local setup to the essentials On the release PR, after `npm run build` and committing the build outputs, run: ```sh -npm run test:release -- --committed +npm run test:release ``` -It smoke-tests the freshly built `imagediff.js` and `imagediff.min.js` in a page, through `require` in Node, and through the CLI, and checks that the committed build outputs match the fresh build. Publish only once it passes. +It rebuilds, runs `npm test` against the built `imagediff.js` and `imagediff.min.js` (through `require` in Node and in a page, along with the CLI specs), and then fails if the fresh build differs from the committed build outputs. Publish only once it passes. diff --git a/README.md b/README.md index e0b33bc..9d79a79 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,8 @@ npm test * `npm run test:node` runs the specs, including a smoke test of the `imagediff` CLI, in Node.js against [node-canvas](https://github.com/Automattic/node-canvas) (the optional `canvas` dependency, which `npm ci` installs from prebuilt binaries on common platforms). * `npm run test:browser` runs the specs in headless Chromium with Playwright. * `npm run test:serve` serves the specs at http://localhost:8085/spec/ to watch them run in a browser. -* `npm run test:release` builds the release files fresh in `.release/` (from the files npm would publish) and runs the specs against both `imagediff.js` and `imagediff.min.js`: through `require` in Node, as a ` From f9761bf709356b430041a10c20d2e02a0c8cf01e Mon Sep 17 00:00:00 2001 From: hgt-bot Date: Fri, 30 Oct 2026 11:27:01 -0400 Subject: [PATCH 3/3] build: add an npm release command that builds and validates Replace test:release with `npm run release`, which builds the release files and runs the specs against both (test:built). `npm publish` (prepublishOnly) refuses to publish if the built files differ from what's committed or fail the specs, without rebuilding. Co-Authored-By: Claude Opus 5.5 --- CONTRIBUTING.md | 8 +++++--- README.md | 4 ++-- package.json | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8407dc1..892fd2a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,10 +23,12 @@ docs: trim local setup to the essentials ## Releasing -On the release PR, after `npm run build` and committing the build outputs, run: +In the release PR, run: ```sh -npm run test:release +npm run release ``` -It rebuilds, runs `npm test` against the built `imagediff.js` and `imagediff.min.js` (through `require` in Node and in a page, along with the CLI specs), and then fails if the fresh build differs from the committed build outputs. Publish only once it passes. +It builds `imagediff.js` and `imagediff.min.js` and runs `npm test` against each, through `require` in Node and in a page. Commit the built files once it passes. It doesn't bump the version, tag or publish. + +After merging, `npm publish` checks the committed built files again before publishing: it refuses if they differ from what's committed or if the specs fail against them. It doesn't rebuild, so what's published is what's committed. diff --git a/README.md b/README.md index 9d79a79..343457e 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,8 @@ npm test * `npm run test:node` runs the specs, including a smoke test of the `imagediff` CLI, in Node.js against [node-canvas](https://github.com/Automattic/node-canvas) (the optional `canvas` dependency, which `npm ci` installs from prebuilt binaries on common platforms). * `npm run test:browser` runs the specs in headless Chromium with Playwright. * `npm run test:serve` serves the specs at http://localhost:8085/spec/ to watch them run in a browser. -* `IMAGEDIFF_LIBRARY=imagediff.min.js npm test` runs the same specs against a built file (a path from the repository root) instead of the source: through `require` in Node and as a `