Skip to content

feat: add deploy pipeline, container limits, keypair cache and type g… - #323

Merged
abayomicornelius merged 1 commit into
Heliobond:mainfrom
Omoboi-dev:feat/issues-225-226-227-228
Jul 29, 2026
Merged

feat: add deploy pipeline, container limits, keypair cache and type g…#323
abayomicornelius merged 1 commit into
Heliobond:mainfrom
Omoboi-dev:feat/issues-225-226-227-228

Conversation

@Omoboi-dev

Copy link
Copy Markdown
Contributor

Summary

Closes #225
closes #226
closes #227
closes #228

Four backend hardening issues in one branch — they touch overlapping files
(stellar.ts, Dockerfile, docker-compose.yml).

#228 — Strict mode: replace assertions with runtime validation

The three sites named in the issue:

  • config.tsas "testnet" | "mainnet" → exported StellarNetwork type
    and an isStellarNetwork guard. validateRequiredEnv() now reads
    process.env directly, since the config object is built at import time and
    could never see a bad value. This fixes a config.test.ts case failing on main.
  • lib/registry.tssim.result! → local isSimulationError guard plus an
    explicit retval === undefined check.
  • routes/admin.tsraw as number[] → entries validated individually and
    copied into a number[], so the type comes from construction.

Also removed while in those files: reason!, result as {...} (now a
ProjectUpdateOutcome discriminated union), (err as Error), the
req.query.x as string casts, and getResult! in stellar.ts. Response body
shapes are unchanged.

Left alone: the as any at stellar.ts:152 — narrowing it requires
restructuring transaction handling, not a type fix. Pre-existing warning, not new.

#227 — Cache the admin keypair

Derived once into a module-level variable instead of per call (previously once
per project per cron cycle). The secret is cached alongside it so a changed
secret rebuilds. Error behaviour unchanged; resetAdminKeypairCache() exported
for tests.

#225 — Container resource limits

512 MB / 0.5 CPU on the backend, 256 MB / 0.25 CPU on Redis, and
NODE_OPTIONS=--max-old-space-size=384 in the production stage only.

The 128 MB gap is deliberate: V8 old space excludes the Node binary and native
buffers, so a ceiling below the limit gives JavaScript heap out of memory with
a stack trace instead of a silent SIGKILL. Redis caps itself at 192mb with
allkeys-lru so it evicts rather than growing into its limit.

#226 — Deployment workflow

New .github/workflows/deploy.yml: push to main → staging, release or v*
tag → production, plus manual dispatch.

  • Builds and pushes to GHCR with the built-in GITHUB_TOKEN — no extra secret
  • Deploys by digest, so a moved tag cannot change what runs
  • Status via the GitHub Deployments API (in_progresssuccess/failure
    under if: always()), attached to the merge commit so it shows on the PR
  • Honours the event_type=deploy dispatch release.yml already fires
  • Rollout target is DEPLOY_HOOK_URL, set per environment

New docs/DEPLOYMENT.md covers limits, tuning, pipeline, registry and rollback.

Tests

Four new suites, 54 tests, all passing: keypair cache behaviour, the type guards,
and parsers asserting the compose/Dockerfile limits and the workflow's triggers,
digest pinning and status reporting.

tsc --noEmit and eslint clean on changed files. Suite totals main → branch:
26 → 23 failures (3 fixed, 0 new), 645 → 701 passing, same 11 failing suites.

…uards

Closes Heliobond#225, Heliobond#226, Heliobond#227, Heliobond#228.

- Heliobond#228: replace unsafe casts and non-null assertions with runtime guards in config.ts, registry.ts, stellar.ts and admin.ts
- Heliobond#227: derive the admin keypair once and cache it, keeping the missing-secret error
- Heliobond#225: set 512MB/0.5 CPU limits and a 384MB V8 heap ceiling for the container
- Heliobond#226: add deploy.yml building to GHCR, staging on merge, production on release
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Omoboi-dev 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

@abayomicornelius
abayomicornelius merged commit d5a22cd into Heliobond:main Jul 29, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants