Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

ci(workflows): bound every job with a timeout

Yudhi Armyndharis3a2ef47d5ced
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 014497359..daee80d93 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -25,6 +25,7 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
+ timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -100,6 +101,7 @@ jobs:
audit:
name: Security audit
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -139,6 +141,7 @@ jobs:
test:
name: Test
runs-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: 15
services:
postgres:
image: postgres:16-alpine
@@ -275,6 +279,7 @@ jobs:
dashboard:
name: Dashboard
runs-on: ubuntu-latest
+ timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -316,6 +321,7 @@ jobs:
scripts-smoke:
name: Shell scripts
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -352,6 +358,7 @@ jobs:
chart:
name: Helm chart and workflows
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -398,6 +405,7 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
+ timeout-minutes: 15
needs: [lint, audit, test, dashboard, scripts-smoke, chart]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -424,6 +432,7 @@ jobs:
docker:
name: Docker Build
runs-on: ubuntu-latest
+ timeout-minutes: 60
needs: [build, test-postgres]
permissions:
contents: read
diff --git a/.github/workflows/java-sdk-release.yml b/.github/workflows/java-sdk-release.yml
index 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: 30
defaults:
run:
working-directory: sdk/java
diff --git a/.github/workflows/js-sdk-release.yml b/.github/workflows/js-sdk-release.yml
index 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: 15
defaults:
run:
working-directory: sdk/javascript
diff --git a/.github/workflows/php-sdk-release.yml b/.github/workflows/php-sdk-release.yml
index 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: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
diff --git a/.github/workflows/python-sdk-release.yml b/.github/workflows/python-sdk-release.yml
index 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: 15
permissions:
contents: read
steps:
@@ -100,6 +101,7 @@ jobs:
# Runs only after the guards, the tests and the build above all passed.
needs: build
runs-on: ubuntu-latest
+ timeout-minutes: 15
permissions:
contents: read
# Mints the OIDC token PyPI exchanges for its short-lived upload credential. Without this the
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f3dc35603..34c9c9052 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -30,6 +30,7 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
+ timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -126,6 +127,7 @@ jobs:
test:
name: Test
runs-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: 15
services:
postgres:
image: postgres:16-alpine
@@ -245,6 +248,7 @@ jobs:
dashboard:
name: Dashboard
runs-on: ubuntu-latest
+ timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -283,6 +287,7 @@ jobs:
scripts-smoke:
name: Shell scripts
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -311,6 +316,7 @@ jobs:
chart:
name: Helm chart and workflows
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -358,6 +364,7 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
+ timeout-minutes: 15
needs: [lint, test, dashboard, scripts-smoke, chart]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -378,6 +385,7 @@ jobs:
release:
name: GitHub Release
runs-on: ubuntu-latest
+ timeout-minutes: 15
permissions:
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 Release
runs-on: ubuntu-latest
+ timeout-minutes: 90
permissions:
contents: read
packages: write
@@ -523,6 +532,7 @@ jobs:
boot-smoke:
name: Boot smoke (amd64 + arm64)
runs-on: ubuntu-latest
+ timeout-minutes: 45
permissions:
packages: read
needs: [docker]
@@ -612,6 +622,7 @@ jobs:
image-scan:
name: Image scan (${{ matrix.platform }})
runs-on: ubuntu-latest
+ timeout-minutes: 20
permissions:
packages: read
needs: [docker]
@@ -668,6 +679,7 @@ jobs:
promote:
name: Promote image to release tags
runs-on: ubuntu-latest
+ timeout-minutes: 15
permissions:
packages: write
needs: [docker, boot-smoke, image-scan]
@@ -766,6 +778,7 @@ jobs:
cleanup-staging:
name: Clean up the staging tag
runs-on: ubuntu-latest
+ timeout-minutes: 10
if: 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 a
diff --git a/.github/workflows/sdk-ci.yml b/.github/workflows/sdk-ci.yml
index 51a21c8de..fbf59540a 100644
--- a/.github/workflows/sdk-ci.yml
+++ b/.github/workflows/sdk-ci.yml
@@ -35,6 +35,7 @@ jobs:
javascript:
name: JavaScript SDK
runs-on: ubuntu-latest
+ timeout-minutes: 15
defaults:
run:
working-directory: sdk/javascript
@@ -56,6 +57,7 @@ jobs:
python:
name: Python SDK (${{ matrix.python }})
runs-on: ubuntu-latest
+ timeout-minutes: 15
strategy:
fail-fast: false
matrix:
@@ -79,6 +81,7 @@ jobs:
php:
name: PHP SDK (${{ matrix.php }})
runs-on: ubuntu-latest
+ timeout-minutes: 15
strategy:
fail-fast: false
matrix:
@@ -97,6 +100,7 @@ jobs:
java:
name: Java SDK
runs-on: ubuntu-latest
+ timeout-minutes: 15
defaults:
run:
working-directory: sdk/java
@@ -112,6 +116,7 @@ jobs:
go:
name: Go SDK
runs-on: ubuntu-latest
+ timeout-minutes: 15
defaults:
run:
working-directory: sdk/go
diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml
index 927c315cb..0c2600b0e 100644
--- a/.github/workflows/security-scan.yml
+++ b/.github/workflows/security-scan.yml
@@ -34,6 +34,7 @@ jobs:
audit:
name: Security audit
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -121,6 +122,7 @@ jobs:
image-scan:
name: Image scan (${{ matrix.platform }})
runs-on: ubuntu-latest
+ timeout-minutes: 20
permissions:
packages: read
strategy:
diff --git a/.github/workflows/split-php-sdk.yml b/.github/workflows/split-php-sdk.yml
index 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 tests
runs-on: ubuntu-latest
+ timeout-minutes: 15
defaults:
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: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
diff --git a/src/common/ci-privilege-gate.spec.ts b/src/common/ci-privilege-gate.spec.ts
index 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([]);
+ });
+});