Skip to content

fix(cd): re-land lefthook hooks + override better-sqlite3 for Node 24 CD build - #281

Merged
bolyachevets merged 2 commits into
mainfrom
fix/lefthook-git-less-build
Sep 21, 2026
Merged

bolyachevets merged 2 commits into
mainfrom
fix/lefthook-git-less-build

Conversation

@panish16

@panish16 panish16 commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Re-lands #278 (reverted in da2cf56) and fixes two separate reasons the CD image build fails. CD is currently red on main for the second one.

1. lefthook breaks the CD install (caused by #278)

CD build image (node:24-alpine, Cloud Build) has no git/.git:

lefthook postinstall: Error: exec: "git": executable file not found in $PATH
. prepare: Failed -> [ELIFECYCLE] exit 1   (run 34994839975)
  • prepare: lefthook install || exit 0
  • pnpm-workspace.yaml: lefthook: false (skip its own postinstall; prepare installs hooks locally)

2. nuxt generate core-dumps in CD (independent of lefthook, hits main too)

node::RemoveEnvironmentCleanupHook ... Assertion failed: (env) != nullptr   (exit 134)

happens right at @nuxt/content init. @nuxt/content@3.4.0 pins better-sqlite3@11.9.1, which predates Node 24; there is no musl prebuild so CD compiles it from source.

  • overrides: better-sqlite3: 12.11.1 (engines include Node 24). Lockfile diff is limited to better-sqlite3.

Evidence: 3/3 CD runs failed without the override, including a main deploy on da2cf56 which has no lefthook (run 35617976139); same commit had been green on 09-18, so the crash is intermittent-to-consistent, not tied to toolchain (gcc/musl/python and the node:24-alpine source build were identical in green and red logs).

Verification

The PR checks do not exercise the CD image (GitHub runners and the node:24 bcregistry-ui-ci-pr trigger both have git; that trigger is also COMMENTS_ENABLED so it stays "fail 0s" until an owner comments /gcbrun). The real test is CD: both fixes together ran through BCREGISTRY UI CD from a feature-* branch (run 35622407773): install OK, nuxt generate OK, "Deploy complete" to yfthig-dev.web.app.

…-land, git-less build safe)

Re-applies #278, which broke the Cloud Build CD image build: that image has no git binary, so lefthook's postinstall and the repo's prepare script both failed with 'exec: git: executable file not found in $PATH'.

- prepare: 'lefthook install || exit 0' so a missing git/.git never fails an install
- pnpm-workspace.yaml: lefthook: false (skip its postinstall; prepare handles hook install locally)
…in CD)

@nuxt/content@3.4.0 pins better-sqlite3 11.9.1, which predates Node 24. On the node:24-alpine CD image it is compiled from source and nuxt generate aborts at @nuxt/content init with 'node::RemoveEnvironmentCleanupHook ... Assertion failed: (env) != nullptr' (exit 134). Verified on CD: crashed 3/3 without the override, passed and deployed to dev with it.
@panish16 panish16 changed the title feat: re-land lefthook + gitleaks hooks (git-less build safe) fix(cd): re-land lefthook hooks + override better-sqlite3 for Node 24 CD build Sep 21, 2026
@panish16

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@bcregistry-sre

Copy link
Copy Markdown
Collaborator

Temporary Url for review: https://yfthig-dev--pr-281-wc36mjh9.web.app

@bolyachevets
bolyachevets merged commit eea35c3 into main Sep 21, 2026
12 checks passed
panish16 added a commit to panish16/ppr that referenced this pull request Sep 21, 2026
The root prepare script ran 'lefthook install' unconditionally, which fails in environments without git/.git (e.g. Cloud Build images). Same guard as bcgov/bcregistry#281.
panish16 pushed a commit to panish16/connect that referenced this pull request Sep 23, 2026
Adds the secret-scan command from the Git Hooks RFC (discussion bcgov#23) to
the lefthook config already on main (lint + typecheck only, no secret
scanning yet). Matches the pattern now live on bcgov/bcregistry and
bcgov/ppr: bare 'npx gitleaks-secret-scanner', no custom install script.

Also guards 'prepare' with '|| exit 0' so a missing git binary (e.g. a
git-less CD build image) can't fail the install - this bit bcregistry
after it merged the same lefthook setup without the guard:
bcgov/bcregistry#281
panish16 added a commit to panish16/namex that referenced this pull request Sep 24, 2026
lefthook's own npm postinstall already skips itself under CI=true by
default (only installs if LEFTHOOK=1/true is explicitly set - see
https://lefthook.dev/usage/envs/LEFTHOOK.html). Our prepare script
called 'lefthook install' directly though, which bypasses that and
always runs - that's what broke bcgov/bcregistry#281's CD build (no
git in the image).

'|| exit 0' (the fix used on bcregistry/ppr) stops the failure from
crashing the install, but still attempts the install in CI every
time. This skips it outright when CI is set, since hooks have no
purpose in a non-interactive build anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants