Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
ci(workflows): bound every job with a timeout
Yudhi Armyndharis3a2ef47d5ced
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 014497359..daee80d93 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -25,6 +25,7 @@ jobs:lint:name: Lintruns-on: ubuntu-latest+ timeout-minutes: 20steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -100,6 +101,7 @@ jobs:audit:name: Security auditruns-on: ubuntu-latest+ timeout-minutes: 10steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -139,6 +141,7 @@ jobs:test:name: Testruns-on: ubuntu-latest+ timeout-minutes: 20# Real Redis for the queue-on e2e suite (test/queue-on.e2e-spec.ts); the rest of the e2e family# boots QUEUE_ENABLED=false and never connects. Mirrors the test-postgres job's service pattern;# the image pin matches docker-compose.yml.@@ -199,6 +202,7 @@ jobs:test-postgres:name: Test (PostgreSQL migrations)runs-on: ubuntu-latest+ timeout-minutes: 15services:postgres:image: postgres:16-alpine@@ -275,6 +279,7 @@ jobs:dashboard:name: Dashboardruns-on: ubuntu-latest+ timeout-minutes: 15steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -316,6 +321,7 @@ jobs:scripts-smoke:name: Shell scriptsruns-on: ubuntu-latest+ timeout-minutes: 10steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -352,6 +358,7 @@ jobs:chart:name: Helm chart and workflowsruns-on: ubuntu-latest+ timeout-minutes: 10steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -398,6 +405,7 @@ jobs:build:name: Buildruns-on: ubuntu-latest+ timeout-minutes: 15needs: [lint, audit, test, dashboard, scripts-smoke, chart]steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -424,6 +432,7 @@ jobs:docker:name: Docker Buildruns-on: ubuntu-latest+ timeout-minutes: 60needs: [build, test-postgres]permissions:contents: readdiff --git a/.github/workflows/java-sdk-release.yml b/.github/workflows/java-sdk-release.ymlindex 73d6671c6..890f87d05 100644--- a/.github/workflows/java-sdk-release.yml+++ b/.github/workflows/java-sdk-release.yml@@ -20,6 +20,7 @@ permissions:jobs:publish:runs-on: ubuntu-latest+ timeout-minutes: 30defaults:run:working-directory: sdk/javadiff --git a/.github/workflows/js-sdk-release.yml b/.github/workflows/js-sdk-release.ymlindex a03f58a81..cf89339fa 100644--- a/.github/workflows/js-sdk-release.yml+++ b/.github/workflows/js-sdk-release.yml@@ -27,6 +27,7 @@ permissions:jobs:publish:runs-on: ubuntu-latest+ timeout-minutes: 15defaults:run:working-directory: sdk/javascriptdiff --git a/.github/workflows/php-sdk-release.yml b/.github/workflows/php-sdk-release.ymlindex 45819e115..c86204c10 100644--- a/.github/workflows/php-sdk-release.yml+++ b/.github/workflows/php-sdk-release.yml@@ -26,6 +26,7 @@ permissions:jobs:release:runs-on: ubuntu-latest+ timeout-minutes: 15steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7with:diff --git a/.github/workflows/python-sdk-release.yml b/.github/workflows/python-sdk-release.ymlindex fc8383ba0..e5254e59e 100644--- a/.github/workflows/python-sdk-release.yml+++ b/.github/workflows/python-sdk-release.yml@@ -28,6 +28,7 @@ jobs:# id-token: write. This is PyPA's documented layout for trusted publishing.build:runs-on: ubuntu-latest+ timeout-minutes: 15permissions:contents: readsteps:@@ -100,6 +101,7 @@ jobs:# Runs only after the guards, the tests and the build above all passed.needs: buildruns-on: ubuntu-latest+ timeout-minutes: 15permissions:contents: read# Mints the OIDC token PyPI exchanges for its short-lived upload credential. Without this thediff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex f3dc35603..34c9c9052 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -30,6 +30,7 @@ jobs:lint:name: Lintruns-on: ubuntu-latest+ timeout-minutes: 20steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -126,6 +127,7 @@ jobs:test:name: Testruns-on: ubuntu-latest+ timeout-minutes: 20# Mirrors ci.yml's test job. Without this service the queue-on e2e suite self-skips and the# release path reports green on a suite it never actually ran — the tag is the one place that# must not be verified less than the branch it came from.@@ -173,6 +175,7 @@ jobs:test-postgres:name: Test (PostgreSQL migrations)runs-on: ubuntu-latest+ timeout-minutes: 15services:postgres:image: postgres:16-alpine@@ -245,6 +248,7 @@ jobs:dashboard:name: Dashboardruns-on: ubuntu-latest+ timeout-minutes: 15steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -283,6 +287,7 @@ jobs:scripts-smoke:name: Shell scriptsruns-on: ubuntu-latest+ timeout-minutes: 10steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -311,6 +316,7 @@ jobs:chart:name: Helm chart and workflowsruns-on: ubuntu-latest+ timeout-minutes: 10steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -358,6 +364,7 @@ jobs:build:name: Buildruns-on: ubuntu-latest+ timeout-minutes: 15needs: [lint, test, dashboard, scripts-smoke, chart]steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -378,6 +385,7 @@ jobs:release:name: GitHub Releaseruns-on: ubuntu-latest+ timeout-minutes: 15permissions:contents: write# Gate the public Release on every CI-strength job AND a successfully built+pushed image that@@ -431,6 +439,7 @@ jobs:docker:name: Docker Releaseruns-on: ubuntu-latest+ timeout-minutes: 90permissions:contents: readpackages: write@@ -523,6 +532,7 @@ jobs:boot-smoke:name: Boot smoke (amd64 + arm64)runs-on: ubuntu-latest+ timeout-minutes: 45permissions:packages: readneeds: [docker]@@ -612,6 +622,7 @@ jobs:image-scan:name: Image scan (${{ matrix.platform }})runs-on: ubuntu-latest+ timeout-minutes: 20permissions:packages: readneeds: [docker]@@ -668,6 +679,7 @@ jobs:promote:name: Promote image to release tagsruns-on: ubuntu-latest+ timeout-minutes: 15permissions:packages: writeneeds: [docker, boot-smoke, image-scan]@@ -766,6 +778,7 @@ jobs:cleanup-staging:name: Clean up the staging tagruns-on: ubuntu-latest+ timeout-minutes: 10if: always()permissions:packages: write@@ -813,6 +826,7 @@ jobs:verify-published:name: Verify published tags (anonymous)runs-on: ubuntu-latest+ timeout-minutes: 15# After cleanup-staging, not beside it: GHCR's package-versions API is eventually consistent, so# that job can read a version whose release tags are not listed yet and delete the version the# release just published. This check is the net for exactly that, so it has to run last. It is adiff --git a/.github/workflows/sdk-ci.yml b/.github/workflows/sdk-ci.ymlindex 51a21c8de..fbf59540a 100644--- a/.github/workflows/sdk-ci.yml+++ b/.github/workflows/sdk-ci.yml@@ -35,6 +35,7 @@ jobs:javascript:name: JavaScript SDKruns-on: ubuntu-latest+ timeout-minutes: 15defaults:run:working-directory: sdk/javascript@@ -56,6 +57,7 @@ jobs:python:name: Python SDK (${{ matrix.python }})runs-on: ubuntu-latest+ timeout-minutes: 15strategy:fail-fast: falsematrix:@@ -79,6 +81,7 @@ jobs:php:name: PHP SDK (${{ matrix.php }})runs-on: ubuntu-latest+ timeout-minutes: 15strategy:fail-fast: falsematrix:@@ -97,6 +100,7 @@ jobs:java:name: Java SDKruns-on: ubuntu-latest+ timeout-minutes: 15defaults:run:working-directory: sdk/java@@ -112,6 +116,7 @@ jobs:go:name: Go SDKruns-on: ubuntu-latest+ timeout-minutes: 15defaults:run:working-directory: sdk/godiff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.ymlindex 927c315cb..0c2600b0e 100644--- a/.github/workflows/security-scan.yml+++ b/.github/workflows/security-scan.yml@@ -34,6 +34,7 @@ jobs:audit:name: Security auditruns-on: ubuntu-latest+ timeout-minutes: 10steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7@@ -121,6 +122,7 @@ jobs:image-scan:name: Image scan (${{ matrix.platform }})runs-on: ubuntu-latest+ timeout-minutes: 20permissions:packages: readstrategy:diff --git a/.github/workflows/split-php-sdk.yml b/.github/workflows/split-php-sdk.ymlindex 29eb0cea7..0bd9f43d5 100644--- a/.github/workflows/split-php-sdk.yml+++ b/.github/workflows/split-php-sdk.yml@@ -33,6 +33,7 @@ jobs:test:name: PHP SDK testsruns-on: ubuntu-latest+ timeout-minutes: 15defaults:run:working-directory: sdk/php@@ -49,6 +50,7 @@ jobs:# Never mirror an untested (red) SDK to Packagist dev-main.needs: [test]runs-on: ubuntu-latest+ timeout-minutes: 15steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7with:diff --git a/src/common/ci-privilege-gate.spec.ts b/src/common/ci-privilege-gate.spec.tsindex adb085fe1..47a7af408 100644--- a/src/common/ci-privilege-gate.spec.ts+++ b/src/common/ci-privilege-gate.spec.ts@@ -414,3 +414,30 @@ describe('ci.yml moves the branch image tag only for the tested branch head', ()expect(run).toMatch(/GITHUB_SHA/);});});++/**+ * A job without `timeout-minutes` runs to GitHub's 360-minute default. A hung dashboard test run once+ * held its job for half an hour and still reported green, and a stalled apt mirror held another for+ * over an hour, so every job carries its own bound: a hang turns into a prompt red job instead.+ */+describe('every workflow job declares a bounded timeout', () => {+ type TimedWorkflow = { jobs?: Record<string, { 'timeout-minutes'?: unknown }> };+ const workflows = fs.readdirSync(workflowDir).filter(f => f.endsWith('.yml') || f.endsWith('.yaml'));+ const jobs = workflows.flatMap(file =>+ Object.entries((workflowOf(file) as TimedWorkflow).jobs ?? {}).map(([job, def]) => ({+ id: `${file}:${job}`,+ timeout: def['timeout-minutes'],+ })),+ );++ it('finds the jobs of every workflow', () => {+ expect(jobs.length).toBeGreaterThanOrEqual(30);+ });++ it('gives each job a timeout between 1 and 120 minutes', () => {+ const unbounded = jobs+ .filter(({ timeout }) => !(Number.isInteger(timeout) && (timeout as number) > 0 && (timeout as number) <= 120))+ .map(({ id, timeout }) => `${id} (${String(timeout)})`);+ expect(unbounded).toEqual([]);+ });+});