Broken doc site builds should break CI
Currently, react-static can build an empty or broken public dir and CI will still pass as if it successfully deployed that broken build.
Some quick research. Probably should wrap up more concisely in a PR or issue upstream.
Starting point:
// static.config.js
throw new Error("HI");
This produces an error but doesn't exit non-zero. Inspecting things, the init() call (see below) exits successfully without hitting the try/catch.
Then directly in source edit node_modules/react-static/bin/react-static:
Take this section at the top: https://github.com/react-static/react-static/blob/master/packages/react-static/bin/react-static#L5-L10
try {
init()
} catch (e) {
console.trace(e)
process.exit(1)
}
cut it out, move it to the bottom of the file like this:
(async () => {
try {
await init()
console.log("TODO RS INIT SUCCESSFUL");
} catch (e) {
console.log("TODO RS CAUGHT");
console.trace(e)
process.exit(1)
}
console.log("TODO RS INIT DONE");
})();
And change init's definition to async function init() { /* ... */ }
Now, the debugging statements show that we don't get to TODO RS INIT SUCCESSFUL and do trip TODO RS CAUGHT and we exit non-zero as expected.
It looks like react-static may have fixed this here: https://github.com/react-static/react-static/pull/1451
AFAICT it’s presently only in master https://github.com/react-static/react-static/blob/master/CHANGELOG.md but as soon as that releases we should definitely update!