Skip to content

chore(env): validate environment variables before every build - #731

Merged
Calebux merged 1 commit into
zintarh:mainfrom
Vox-d-glitch:fix/584-validate-env-prebuild
Oct 1, 2026
Merged

Calebux merged 1 commit into
zintarh:mainfrom
Vox-d-glitch:fix/584-validate-env-prebuild

Conversation

@Vox-d-glitch

Copy link
Copy Markdown
Contributor

I added a prebuild script that runs pnpm validate:env --build, so pnpm build now fails before next build starts when a required variable is missing, with a message naming it. In --build mode the validator loads .env files with @next/env, the same loader and precedence next build uses, and checks the actual values rather than the documentation. Without the flag it keeps its existing documentation checks, which CI still runs.

The validator now lists every variable in .env.example with its phase. Build-time NEXT_PUBLIC_* variables are inlined into the bundle, so a missing required one (at least one contract address, as .env.example states) or a malformed contract address fails the build. Runtime variables such as CRON_SECRET can be provided by the deployment after the build, so a missing one produces a warning. A new test asserts that the validator and .env.example declare the same variables and covers the build-time checks.

The README now documents each variable's phase, whether it is required, what it does and where to get a value. The CI, Lighthouse and bundle-size builds pass the all-A placeholder contract address, which satisfies the check and which the app already treats as "no contract configured".

Closes #584

Run validate:env --build as the prebuild step. It loads .env files the
way next build does and fails the build, naming the variable, when no
contract address is set or one is malformed; a missing runtime-only
variable such as CRON_SECRET is reported as a warning.

The validator now lists every variable in .env.example with its phase,
and a test keeps the two in sync. The README documents each variable
and where to obtain a value, and the CI builds pass the placeholder
contract address.
@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

@Vox-d-glitch is attempting to deploy a commit to the zintarh Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

@Vox-d-glitch Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Calebux
Calebux merged commit e00ff70 into zintarh:main Oct 1, 2026
1 check failed
@Calebux

Calebux commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the contribution! This PR conflicted with recent changes on main, so the conflicts were resolved during merge:

  • .github/workflows/bundle-size.yml: I merged both changes: the target branch added a size-limit check step, and this PR added the placeholder environment variable for the build step; both are included without conflict.
  • .github/workflows/ci.yml: Combined the target branch's updated CI structure (pnpm action-setup v4, new jobs for route file casing, standalone type check, and production build) with this PR's addition of the placeholder environment variable. No conflicts required dropping anything.
  • README.md: I combined the target branch's indexer component table and handsoff list updates with this PR's environment variable documentation, so the README now reflects both the new prebuild validation and the current service layout; nothing had to be dropped.
  • package.json: I combined the target branch's added scripts and @vitest/coverage-v8 devDependency with this PR's prebuild command, using this PR's pnpm validate:env --build in place of the target branch's earlier node scripts/validate-env.js.
  • scripts/validate-env.js: I combined the target branch's per‑network contract address validation and placeholder rejection with this PR's --build mode, so that --build now checks each network individually and rejects placeholder addresses, while the non‑build documentation checks remain unchanged. The file path for the config validation was updated to contractAddress.ts (as already renamed in the target branch).

Resolved and merged with PRmaster. Your commits are included in the merge.

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.

chore(env): validate:env is not run by any workflow or build step

2 participants