Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(ci): pin the image gates and the staging cleanup condition
Yudhi Armyndharisee4e4f44021b
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 84833b46f..7c6603d79 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -257,15 +257,16 @@ jobs:# that the data entities can build their own schema (raw SQL the ORM passes through verbatim,# such as a partial index predicate, only case-folds on a real server), that the UTC pin# holds across a backup round trip, a retention window and a local-midnight count, that webhook- # failure recovery and media metadata updates hold on the real server, and that a send- # idempotency key is claimed by a unique-violation insert. All seven+ # failure recovery and media metadata updates hold on the real server, that a send+ # idempotency key is claimed by a unique-violation insert, and that a replace-all import runs (its+ # idempotency-key trim casts a varchar session id against a uuid). All eight# self-skip unless DATABASE_TYPE=postgres, so they are a no-op in the default test job and only# execute here against the postgres:16 service.## TZ is deliberately NOT UTC: the pin's whole job is to make a `timestamp` column mean the same# instant on a host that runs in another zone, and on a UTC runner every assertion about it# would pass for the wrong reason (the UTC-pin spec fails outright rather than pass vacuously).- - name: Postgres specs (FTS + migrations + ordering + schema + UTC + recovery + idempotency)+ - name: Postgres specs (FTS + migrations + ordering + schema + UTC + recovery + idempotency + import)# --runInBand: the specs issue DDL against the one shared service database, and jest's# default file-parallelism races their catalog writes (pg_type duplicate-key). The lock# spec's own two-migrator race is in-file (Promise.all) and unaffected by runInBand. Thediff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex d07780849..35e950973 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -231,11 +231,11 @@ jobs:# their own schema (raw SQL the ORM passes through verbatim, such as a partial index predicate,# only case-folds on a real server), that the UTC pin holds across a backup round trip, a# retention window and a local-midnight count, that webhook failure recovery and media metadata- # updates hold on the real server, and that a send idempotency key is claimed by a unique-violation- # insert. All seven self-skip unless DATABASE_TYPE=postgres, so they are a no-op in the default test- # job and only execute here against the postgres:16 service. TZ is deliberately not UTC, for the- # reason ci.yml states.- - name: Postgres specs (FTS + migrations + ordering + schema + UTC + recovery + idempotency)+ # updates hold on the real server, that a send idempotency key is claimed by a unique-violation+ # insert, and that a replace-all import runs. All eight self-skip unless DATABASE_TYPE=postgres, so+ # they are a no-op in the default test job and only execute here against the postgres:16 service.+ # TZ is deliberately not UTC, for the reason ci.yml states.+ - name: Postgres specs (FTS + migrations + ordering + schema + UTC + recovery + idempotency + import)# --runInBand: same reason the CI job passes it — both specs issue DDL against the one# shared service database, and jest's default file-parallelism races their catalog writes# (the first v0.19.0 tag failed this step on `relation "messages" already exists` over adiff --git a/docs/09-testing-strategy.md b/docs/09-testing-strategy.mdindex fbb03f250..c4817b3ac 100644--- a/docs/09-testing-strategy.md+++ b/docs/09-testing-strategy.md@@ -259,7 +259,7 @@ request's superseded run; push runs on `main` are never cancelled or queued behi| `lint` | backend ESLint, full-program TypeScript check, formatting, version consistency, .dockerignore context, OpenAPI snapshot, SDK routes and webhook events against the contract, contract coverage per SDK, SDK docs against the shipped client surface, client wire shapes (`check:contract-shapes` — the JavaScript SDK's, dashboard's, Python's, Go's and Java's hand-written types against the OpenAPI schemas; the PHP client returns untyped arrays and has no types layer to gate) || `audit` | dependency security audit of all three npm trees (root, `dashboard/` and `sdk/javascript/`); when npm's audit endpoint cannot answer, the root audit skips with a warning annotation here while the dashboard and SDK audits, a plain `npm audit`, fail closed, so the job still goes red until a re-run; the release gate and the weekly scan fail (`CHECK_AUDIT_REQUIRED=1`) || `test` | backend coverage run, repo-file drift gates (`test:docs`), script unit tests (node:test), e2e smoke tests |-| `test-postgres` | real PostgreSQL 16 service, backend build, migration smoke, and the PostgreSQL specs (FTS provider, boot-migration lock, message list ordering, entity synchronize, UTC pin, webhook recovery, send idempotency keys) |+| `test-postgres` | real PostgreSQL 16 service, backend build, migration smoke, and the PostgreSQL specs (FTS provider, boot-migration lock, message list ordering, entity synchronize, UTC pin, webhook recovery, send idempotency keys, replace-all import) || `dashboard` | dashboard install, lint, formatting, type-check, i18n parity, build, unit tests || `scripts-smoke` | shellcheck on `docker-entrypoint.sh` and every `scripts/*.sh`, plus the backup/restore smoke test || `chart` | helm lint, helm template with default and fully-toggled values, kubeconform on both renders, the rendered-behaviour check, actionlint on the workflows |diff --git a/src/common/release-gate-parity.spec.ts b/src/common/release-gate-parity.spec.tsindex 5ef2006ef..2c7ceb2ff 100644--- a/src/common/release-gate-parity.spec.ts+++ b/src/common/release-gate-parity.spec.ts@@ -119,6 +119,16 @@ describe('release gate jobs can stop the publish jobs', () => {expect(softened).toEqual([]);});+ // The image gates and the check of what the public can pull are jobs of their own, so a failure of one+ // stops the publish jobs only while neither it nor one of its steps is allowed to fail. closure() above+ // would still list one as a need after such an edit.+ it.each(['boot-smoke', 'image-scan', 'verify-published'])('%s cannot fail without failing the job', gate => {+ const job = jobs()[gate];+ expect(job).toBeDefined();+ expect(job['continue-on-error']).toBeUndefined();+ expect((job.steps ?? []).filter(step => step['continue-on-error'] !== undefined)).toEqual([]);+ });+it.each(PUBLISHERS)('%s has no condition of its own that lets it run after a failed gate', publisher => {const job = jobs()[publisher];expect(job).toBeDefined();diff --git a/src/common/release-staging-cleanup.spec.ts b/src/common/release-staging-cleanup.spec.tsindex d8a960780..da27972d9 100644--- a/src/common/release-staging-cleanup.spec.ts+++ b/src/common/release-staging-cleanup.spec.ts@@ -38,4 +38,20 @@ describe('release staging-tag cleanup', () => {expect(deleting.length).toBeGreaterThan(0);for (const step of deleting) expect(step.if).toContain("needs.docker.result != 'success'");});++ // Both conditions have to hold at once: an `||` between them, or a negation around them, deletes the+ // staging image on every failed gate or after a promote that ran, each of which the two checks above+ // would still pass as substrings.+ it('deletes only when promote was skipped and the build itself did not succeed', () => {+ const deleting = (job?.steps ?? []).filter(step => /-X DELETE/.test(step.run ?? ''));+ expect(deleting.length).toBeGreaterThan(0);+ for (const step of deleting) {+ expect(+ (step.if ?? '')+ .split('&&')+ .map(term => term.trim())+ .sort(),+ ).toEqual(["needs.docker.result != 'success'", "needs.promote.result == 'skipped'"].sort());+ }+ });});