@devries-cameron20 / composio-1 / commits / e8228450c
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(ci): harden e2e image builds and deflake the CLI analytics install-id test (#4987)

### Why CI on Docker-based jobs has been failing intermittently across branches (including `next`): `docker buildx build` resolves base images from `public.ecr.aws/docker/library/*`, and on a cold GitHub Actions buildx cache that resolution hits ECR Public's anonymous rate limit (`429 Too Many Requests`). Whether a job passes is currently a function of cache warmth, not code — e.g. on PR #4973 the `bash`/`zsh` install jobs passed while `fish` failed, and `E2E Test Node.js 24/25` failed while 22 passed. The same 429 killed the daily 07:00 UTC install-e2e run on `next`. Separately, one load-sensitive CLI test (`analytics.dispatch.test.ts`) can fail the entire umbrella "Test Typescript SDK" job. This PR: - retries each image build up to three times inside `.github/actions/build-e2e-image` through `docker/build-push-action` (`build-retries`, validated to 1–3; 10s/20s backoff between attempts), with the final retry overriding `BASE_REGISTRY=mirror.gcr.io/library` to clear persistent ECR throttling from a different IP pool. The builds stay inside the action (not raw `docker buildx build`) because the GHA cache backend authenticates through the action context - digest-pins the e2e base images (`debian:bookworm-slim`, `node:{22.22.3,24.17.0,25.9.0}-slim`) for supply-chain integrity, with digests verified against ECR Public and recorded in `toolchain-versions.json` (`nodeDigests`), consumed by the workflows and the local `pnpm test:e2e:*` scripts - adds `ci.prewarm-e2e-images.yml` (daily 04:00 UTC + `workflow_dispatch`), which rebuilds every cache scope the e2e jobs restore from (`e2e-install-{bash,zsh,fish}`, `e2e-node-*`, `e2e-cli`) so PR jobs start from a warm cache; the node/cli entries refresh only the toolchain-stage cache via the action's new `cache-only` input (their final stages COPY host-built `dist/` a bare checkout cannot provide) - fixes the race behind the flaky analytics test: a process whose bounded state-lock wait expired minted a fresh `install_id` without adopting the one another process had already persisted; the fallback now adopts persisted state first (`adoptOrMintInstallId`), so concurrent first-run events converge on one identity. Adds a regression test for the expiry-adopt path. The bounded-wait-then-give-up behavior for stale locks is unchanged - splits `@composio/cli` tests into a dedicated `test-cli` job in `ts.test.yml` (umbrella "Test Typescript SDK" keeps its name and now excludes the CLI suite), so one CLI flake no longer fails the whole matrix ### Verification | Check | Result | | --- | --- | | `actionlint` on all touched workflows + composite action | clean | | cache restore verified on PR CI after the fix (`importing cache manifest from gha:…` + `CACHED` on install and node e2e pre-builds) | pass | | `docker buildx imagetools inspect` per base ref (ECR Public) | digests recorded in `toolchain-versions.json` | | local build of `Dockerfile.install` with pinned digest (`--load`) | passes | | `imagetools inspect` of all 4 pins vs ECR + mirror.gcr.io | byte-identical digests | | independent reviewer pass over the full diff (wiring, GH Actions expressions, bash, TS) | no defects found | | `vitest run test/src/analytics.dispatch.test.ts` x10 (+3 under full CPU load) | 10/10 + 3/3 pass (37 tests) | | `pnpm --filter @composio/cli typecheck` | pass | | `pnpm --filter @composio/cli run lint:effect` | 0 diagnostics | | oxlint + prettier on touched TS files | clean | | `pnpm --filter @composio/cli test` (full suite) | 183 files, 2020 passed, 1 skipped | | `turbo run test --dry-run` filter checks (umbrella excl. CLI / CLI only) | task lists verified | ### Notes - No changeset: CI workflows and `@composio/cli` (Changesets-excluded) only; the CLI src change is analytics-internal with no public API or user-visible behavior change. - `mirror.gcr.io` final-attempt fallback: implemented. All four base-image digests were verified byte-identical between `public.ecr.aws` and `mirror.gcr.io` via `docker buildx imagetools inspect` (the pinned digests resolve on both), so the retry loop's last attempt rebuilds with `BASE_REGISTRY=mirror.gcr.io/library` to ride out persistent ECR throttling from a different IP pool. - After merge, the first scheduled prewarm run (04:00 UTC) will warm the cold scopes; until then a cold-scope job may still need the retry to ride out a 429 window.

Alberto Schiabel committed Oct 20, 2026 at 18:33 UTC e8228450cdc09b5a3cb37c8db57cedcb0dfec468
13 files changed +455 -27
.github/actions/build-e2e-image/action.yml
+150 -5
@@ -6,8 +6,11 @@ inputs:
6 description: 'Path to the Dockerfile, relative to the repository root'
7 required: true
8 tag:
9 - description: 'Tag for the image loaded into the local Docker daemon'
10 - required: true
9 + description: >-
10 + Tag for the image loaded into the local Docker daemon. Unused (nothing is
11 + loaded) when cache-only is 'true'.
12 + required: false
13 + default: ''
14 cache-scope:
15 description: 'GitHub Actions cache scope. Use one scope per image variant so matrix jobs do not overwrite each other'
16 required: true
@@ -19,6 +22,15 @@ inputs:
22 to save every layer.
23 required: false
24 default: ''
25 + cache-only:
26 + description: >-
27 + 'true' skips the final image build and only refreshes the cache-target
28 + stage in the GitHub Actions cache. For prewarm callers whose checkout
29 + cannot provide the workspace artifacts the later stages COPY (host-built
30 + dist under ts/packages), so the final build would fail anyway. Only
31 + meaningful together with cache-target.
32 + required: false
33 + default: 'false'
34 build-args:
35 description: 'Newline-separated KEY=VALUE build arguments'
36 required: false
@@ -27,6 +39,16 @@ inputs:
39 description: 'Newline-separated KEY=VALUE image labels'
40 required: false
41 default: ''
42 + build-retries:
43 + description: >-
44 + Number of build attempts per build: '1', '2' or '3' (one
45 + build-push-action step per attempt). Base-image resolution from ECR
46 + Public can fail with HTTP 429 anonymous rate limits on shared runner
47 + IPs; failed builds are retried after a delay, and a final retry also
48 + overrides BASE_REGISTRY to mirror.gcr.io, whose Docker Official Image
49 + digests are byte-identical to the pins in ts/e2e-tests/_utils/Dockerfile.*.
50 + required: false
51 + default: '3'
52
53 runs:
54 using: 'composite'
@@ -35,9 +57,28 @@ runs:
57 - name: Set up Docker Buildx
58 uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
59
38 - # `ignore-error` keeps a cache-service outage from failing the build.
39 - - name: Build and cache the ${{ inputs.cache-target }} stage
60 + - name: Validate build-retries
61 + if: inputs.build-retries != '1' && inputs.build-retries != '2' && inputs.build-retries != '3'
62 + shell: bash
63 + run: |
64 + echo "::error::build-retries must be '1', '2' or '3', got '${{ inputs.build-retries }}'"
65 + exit 1
66 +
67 + # The builds must stay inside `uses:` steps: docker/build-push-action
68 + # receives the GitHub cache credentials (ACTIONS_RUNTIME_TOKEN and the
69 + # cache URL) that buildx's `type=gha` backend needs and that plain `run:`
70 + # steps do not get, so raw `docker buildx build` here silently skips cache
71 + # import and export. Retries are chained on the previous attempt's
72 + # `outcome`; `continue-on-error` is expression-driven so a final attempt
73 + # still fails the action. The last retry also overrides BASE_REGISTRY to
74 + # mirror.gcr.io (build args are last-wins): its digest-pinned manifests are
75 + # byte-identical to the ECR Public pins, so persistent ECR 429s can be
76 + # cleared from a different IP pool.
77 +
78 + - name: Build and cache the ${{ inputs.cache-target }} stage (attempt 1)
79 + id: cache-stage-attempt-1
80 if: inputs.cache-target != ''
81 + continue-on-error: ${{ inputs.build-retries != '1' }}
82 uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
83 env:
84 DOCKER_BUILD_SUMMARY: 'false'
@@ -50,9 +91,18 @@ runs:
91 provenance: false
92 outputs: type=cacheonly
93 cache-from: type=gha,scope=${{ inputs.cache-scope }}
94 + # `ignore-error` keeps a cache-service outage from failing the build.
95 cache-to: type=gha,scope=${{ inputs.cache-scope }},mode=max,ignore-error=true
96
55 - - name: Build ${{ inputs.tag }}
97 + - name: Wait before retrying the ${{ inputs.cache-target }} stage
98 + if: inputs.cache-target != '' && steps.cache-stage-attempt-1.outcome == 'failure' && inputs.build-retries != '1'
99 + shell: bash
100 + run: sleep 10
101 +
102 + - name: Build and cache the ${{ inputs.cache-target }} stage (attempt 2)
103 + id: cache-stage-attempt-2
104 + if: inputs.cache-target != '' && steps.cache-stage-attempt-1.outcome == 'failure' && inputs.build-retries != '1'
105 + continue-on-error: ${{ inputs.build-retries == '3' }}
106 uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
107 env:
108 DOCKER_BUILD_SUMMARY: 'false'
@@ -60,7 +110,102 @@ runs:
110 with:
111 context: .
112 file: ${{ inputs.dockerfile }}
113 + target: ${{ inputs.cache-target }}
114 build-args: ${{ inputs.build-args }}
115 + provenance: false
116 + outputs: type=cacheonly
117 + cache-from: type=gha,scope=${{ inputs.cache-scope }}
118 + # `ignore-error` keeps a cache-service outage from failing the build.
119 + cache-to: type=gha,scope=${{ inputs.cache-scope }},mode=max,ignore-error=true
120 +
121 + - name: Wait before the final ${{ inputs.cache-target }} stage attempt
122 + if: inputs.cache-target != '' && steps.cache-stage-attempt-2.outcome == 'failure' && inputs.build-retries == '3'
123 + shell: bash
124 + run: sleep 20
125 +
126 + - name: Build and cache the ${{ inputs.cache-target }} stage (final attempt, mirror.gcr.io fallback)
127 + if: inputs.cache-target != '' && steps.cache-stage-attempt-2.outcome == 'failure' && inputs.build-retries == '3'
128 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
129 + env:
130 + DOCKER_BUILD_SUMMARY: 'false'
131 + DOCKER_BUILD_RECORD_UPLOAD: 'false'
132 + with:
133 + context: .
134 + file: ${{ inputs.dockerfile }}
135 + target: ${{ inputs.cache-target }}
136 + build-args: |
137 + ${{ inputs.build-args }}
138 + BASE_REGISTRY=mirror.gcr.io/library
139 + provenance: false
140 + outputs: type=cacheonly
141 + cache-from: type=gha,scope=${{ inputs.cache-scope }}
142 + # `ignore-error` keeps a cache-service outage from failing the build.
143 + cache-to: type=gha,scope=${{ inputs.cache-scope }},mode=max,ignore-error=true
144 +
145 + # The final image build is skipped in cache-only mode: its later stages
146 + # COPY workspace files (including host-built dist) that a cache-refreshing
147 + # caller may not have, and its layers rebuild from the cached stage anyway.
148 +
149 + - name: Build ${{ inputs.tag }} (attempt 1)
150 + id: image-attempt-1
151 + if: inputs.cache-target == '' || inputs.cache-only != 'true'
152 + continue-on-error: ${{ inputs.build-retries != '1' }}
153 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
154 + env:
155 + DOCKER_BUILD_SUMMARY: 'false'
156 + DOCKER_BUILD_RECORD_UPLOAD: 'false'
157 + with:
158 + context: .
159 + file: ${{ inputs.dockerfile }}
160 + build-args: ${{ inputs.build-args }}
161 + labels: ${{ inputs.labels }}
162 + tags: ${{ inputs.tag }}
163 + provenance: false
164 + load: true
165 + cache-from: type=gha,scope=${{ inputs.cache-scope }}
166 + cache-to: ${{ inputs.cache-target == '' && format('type=gha,scope={0},mode=max,ignore-error=true', inputs.cache-scope) || '' }}
167 +
168 + - name: Wait before retrying the ${{ inputs.tag }} build
169 + if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-1.outcome == 'failure' && inputs.build-retries != '1'
170 + shell: bash
171 + run: sleep 10
172 +
173 + - name: Build ${{ inputs.tag }} (attempt 2)
174 + id: image-attempt-2
175 + if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-1.outcome == 'failure' && inputs.build-retries != '1'
176 + continue-on-error: ${{ inputs.build-retries == '3' }}
177 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
178 + env:
179 + DOCKER_BUILD_SUMMARY: 'false'
180 + DOCKER_BUILD_RECORD_UPLOAD: 'false'
181 + with:
182 + context: .
183 + file: ${{ inputs.dockerfile }}
184 + build-args: ${{ inputs.build-args }}
185 + labels: ${{ inputs.labels }}
186 + tags: ${{ inputs.tag }}
187 + provenance: false
188 + load: true
189 + cache-from: type=gha,scope=${{ inputs.cache-scope }}
190 + cache-to: ${{ inputs.cache-target == '' && format('type=gha,scope={0},mode=max,ignore-error=true', inputs.cache-scope) || '' }}
191 +
192 + - name: Wait before the final ${{ inputs.tag }} build attempt
193 + if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-2.outcome == 'failure' && inputs.build-retries == '3'
194 + shell: bash
195 + run: sleep 20
196 +
197 + - name: Build ${{ inputs.tag }} (final attempt, mirror.gcr.io fallback)
198 + if: (inputs.cache-target == '' || inputs.cache-only != 'true') && steps.image-attempt-2.outcome == 'failure' && inputs.build-retries == '3'
199 + uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
200 + env:
201 + DOCKER_BUILD_SUMMARY: 'false'
202 + DOCKER_BUILD_RECORD_UPLOAD: 'false'
203 + with:
204 + context: .
205 + file: ${{ inputs.dockerfile }}
206 + build-args: |
207 + ${{ inputs.build-args }}
208 + BASE_REGISTRY=mirror.gcr.io/library
209 labels: ${{ inputs.labels }}
210 tags: ${{ inputs.tag }}
211 provenance: false
.github/workflows/ci.prewarm-e2e-images.yml new
+150
@@ -0,0 +1,150 @@
1 +name: Prewarm E2E image caches
2 +
3 +# The e2e Dockerfiles resolve their base images from public.ecr.aws, and on a
4 +# cold GitHub Actions buildx cache that resolution hits anonymous ECR rate
5 +# limits (HTTP 429) before a single test runs. The PR jobs that build the
6 +# composio-e2e-* images only pass when their cache scope is still warm or the
7 +# registry pull succeeds, so this workflow rebuilds every scope those jobs
8 +# restore from (e2e-install-*, e2e-node-*, e2e-cli) and leaves the layers in
9 +# the GitHub Actions cache. Scheduled runs only fire on the default branch
10 +# (next); dispatch it by hand after changing a toolchain pin or an e2e
11 +# Dockerfile.
12 +
13 +on:
14 + schedule:
15 + - cron: '0 4 * * *'
16 + workflow_dispatch:
17 +
18 +concurrency:
19 + group: prewarm-e2e-images
20 + cancel-in-progress: false
21 +
22 +permissions:
23 + contents: read
24 +
25 +jobs:
26 + toolchain-versions:
27 + name: Read toolchain versions and digests
28 + runs-on: ubuntu-latest
29 + outputs:
30 + matrix: ${{ steps.versions.outputs.matrix }}
31 + steps:
32 + - name: Checkout
33 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
34 +
35 + - name: Read versions
36 + id: versions
37 + run: |
38 + set -euo pipefail
39 + toolchain_file=toolchain-versions.json
40 +
41 + if ! jq -e '.node | type == "array" and length > 0' "$toolchain_file" >/dev/null; then
42 + echo "::error::toolchain-versions.json must contain a non-empty \"node\" array."
43 + exit 1
44 + fi
45 +
46 + # Prewarm pins base images by digest so a warmed cache is only reused
47 + # for exactly the image the e2e jobs resolve. Without the map the
48 + # node and cli entries below could drift from the digests those jobs
49 + # build with.
50 + if ! jq -e '.nodeDigests | type == "object"' "$toolchain_file" >/dev/null; then
51 + echo "::error::toolchain-versions.json is missing the \"nodeDigests\" map ({\"<node-version>\": \"sha256:...\"}). Add it next to the \"node\" array so the e2e-node-* and e2e-cli caches can be warmed."
52 + exit 1
53 + fi
54 +
55 + missing_digests=$(jq -r '. as $root | [$root.node[] | select(($root.nodeDigests[.] // "") == "")] | join(", ")' "$toolchain_file")
56 + if [[ -n "$missing_digests" ]]; then
57 + echo "::error::toolchain-versions.json is missing \"nodeDigests\" entries for: ${missing_digests}. Every version in \"node\" needs a \"sha256:...\" digest."
58 + exit 1
59 + fi
60 +
61 + # Install image variants, mirroring the CLI Install E2E matrix. Its
62 + # Dockerfile is self-contained, so these entries run the full build
63 + # (cache-only would skip the only build that saves their scope).
64 + install_matrix=$(jq -cn '
65 + ["bash", "zsh", "fish"] | map({
66 + "name": "install image (\(.))",
67 + "dockerfile": "ts/e2e-tests/_utils/Dockerfile.install",
68 + "tag": "composio-e2e-install:\(.)",
69 + "cache-scope": "e2e-install-\(.)",
70 + "cache-target": "",
71 + "cache-only": "false",
72 + "build-args": "INSTALL_SHELL=\(.)"
73 + })')
74 +
75 + # Node toolchain images, one per version in toolchain-versions.json.
76 + # cache-only matters here and for the cli entry below: the later
77 + # stages COPY host-built dist under ts/packages, which a bare checkout
78 + # cannot provide, so these entries only refresh the toolchain-stage
79 + # cache that the CI jobs' final builds consume.
80 + node_matrix=$(jq -c '
81 + . as $root
82 + | [$root.node[] as $version | {
83 + "name": "node toolchain (\($version))",
84 + "dockerfile": "ts/e2e-tests/_utils/Dockerfile.node",
85 + "tag": "composio-e2e-node:\($version)",
86 + "cache-scope": "e2e-node-\($version)",
87 + "cache-target": "toolchain",
88 + "cache-only": "true",
89 + "build-args": "NODE_VERSION=\($version)\nNODE_VERSION_DIGEST=\($root.nodeDigests[$version])"
90 + }]' "$toolchain_file")
91 +
92 + # The cli toolchain image uses the same NODE_VERSION and CLI_VERSION
93 + # as the E2E Test Typescript SDK cli docker job: Node from mise.lock
94 + # and the version from ts/packages/cli/package.json.
95 + cli_version=$(node -p "require('./ts/packages/cli/package.json').version")
96 + cli_node_version=$(bash .github/scripts/read-mise-lock-version.sh node)
97 + cli_digest=$(jq -r --arg version "$cli_node_version" '.nodeDigests[$version] // ""' "$toolchain_file")
98 + if [[ -z "$cli_digest" ]]; then
99 + echo "::error::toolchain-versions.json has no \"nodeDigests\" entry for ${cli_node_version}, the Node.js version pinned in mise.lock that Dockerfile.cli builds on. Add a \"${cli_node_version}\" digest so the e2e-cli cache can be warmed."
100 + exit 1
101 + fi
102 + cli_matrix=$(jq -cn \
103 + --arg cli_version "$cli_version" \
104 + --arg cli_node_version "$cli_node_version" \
105 + --arg cli_digest "$cli_digest" \
106 + '[{
107 + "name": "cli toolchain",
108 + "dockerfile": "ts/e2e-tests/_utils/Dockerfile.cli",
109 + "tag": "composio-e2e-cli:prewarm",
110 + "cache-scope": "e2e-cli",
111 + "cache-target": "toolchain",
112 + "cache-only": "true",
113 + "build-args": "CLI_VERSION=\($cli_version)\nNODE_VERSION=\($cli_node_version)\nNODE_VERSION_DIGEST=\($cli_digest)"
114 + }]')
115 +
116 + matrix=$(jq -cn \
117 + --argjson install "$install_matrix" \
118 + --argjson node "$node_matrix" \
119 + --argjson cli "$cli_matrix" \
120 + '{include: ($install + $node + $cli)}')
121 + jq . <<< "$matrix"
122 + echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
123 +
124 + prewarm:
125 + name: Prewarm ${{ matrix.name }}
126 + needs: toolchain-versions
127 + runs-on: ubuntu-latest
128 + # Cold builds are the point of this workflow, so allow more time than the
129 + # warm rebuilds inside the e2e jobs.
130 + timeout-minutes: 30
131 + strategy:
132 + fail-fast: false
133 + matrix: ${{ fromJSON(needs.toolchain-versions.outputs.matrix) }}
134 + steps:
135 + - name: Checkout
136 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
137 +
138 + # cache-only refreshes the toolchain-stage cache without the final image
139 + # build, whose stages COPY host-built workspace artifacts a bare checkout
140 + # does not have. The install entries keep the full build: their
141 + # Dockerfile is self-contained, and that build is what saves their scope.
142 + - name: Prewarm the ${{ matrix.cache-scope }} cache
143 + uses: ./.github/actions/build-e2e-image
144 + with:
145 + dockerfile: ${{ matrix.dockerfile }}
146 + tag: ${{ matrix.tag }}
147 + cache-scope: ${{ matrix.cache-scope }}
148 + cache-target: ${{ matrix.cache-target }}
149 + cache-only: ${{ matrix.cache-only }}
150 + build-args: ${{ matrix.build-args }}
.github/workflows/ts.test-e2e.yml
+8
@@ -50,6 +50,7 @@ jobs:
50 permissions: read-all
51 outputs:
52 node: ${{ steps.versions.outputs.node }}
53 + node-digests: ${{ steps.versions.outputs.node-digests }}
54 steps:
55 - name: Checkout Code
56 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -58,6 +59,7 @@ jobs:
59 id: versions
60 run: |
61 echo "node=$(jq -c '.node' toolchain-versions.json)" >> "$GITHUB_OUTPUT"
62 + echo "node-digests=$(jq -c .nodeDigests toolchain-versions.json)" >> "$GITHUB_OUTPUT"
63
64 # Node.js E2E tests, running in Docker to isolate environment
65 # Each test suite defines its own versions.node in e2e.test.ts
@@ -140,6 +142,7 @@ jobs:
142 cache-target: toolchain
143 build-args: |
144 NODE_VERSION=${{ matrix.node-version }}
145 + NODE_VERSION_DIGEST=${{ fromJSON(needs.toolchain-versions.outputs.node-digests)[matrix.node-version] }}
146 labels: |
147 composio.e2e=true
148 composio.runtime=node
@@ -152,6 +155,7 @@ jobs:
155 # CLI E2E tests, running in scratch Docker to isolate environment
156 test-e2e-cli-docker:
157 name: E2E Test CLI (scratch)
158 + needs: toolchain-versions
159 runs-on: ubuntu-24.04
160 permissions: read-all
161 env:
@@ -225,9 +229,13 @@ jobs:
229 tag: composio-e2e-cli:${{ steps.cli-version.outputs.value }}
230 cache-scope: e2e-cli
231 cache-target: toolchain
232 + # The CLI node version comes from mise.lock and must stay present in
233 + # both `node` and `nodeDigests` of toolchain-versions.json, or the
234 + # digest lookup yields an empty pin.
235 build-args: |
236 CLI_VERSION=${{ steps.cli-version.outputs.value }}
237 NODE_VERSION=${{ steps.setup-toolchain.outputs.node-version }}
238 + NODE_VERSION_DIGEST=${{ fromJSON(needs.toolchain-versions.outputs.node-digests)[steps.setup-toolchain.outputs.node-version] }}
239 labels: |
240 composio.e2e=true
241 composio.runtime=cli
.github/workflows/ts.test.yml
+35 -1
@@ -61,11 +61,45 @@ jobs:
61 - name: Check Python helpers codegen is up to date
62 run: pnpm --filter @composio/experimental run check:python-helpers
63
64 + # Mirrors the root `test` script (package.json) with the turbo segment
65 + # re-scoped to exclude @composio/cli: its suite runs in the dedicated
66 + # `test-cli` job below so one flaky CLI test cannot fail the umbrella.
67 + # Keep this chain in sync with package.json `scripts.test`.
68 - name: Run Tests
65 - run: pnpm run test
69 + run: >-
70 + pnpm run test:toolchain
71 + && pnpm run test:install-sh
72 + && pnpm run test:release-workflow
73 + && pnpm run test:issue-triage
74 + && pnpm run test:provider-compatibility
75 + && pnpm run test:context7
76 + && pnpm exec turbo run test --filter='./ts/packages/**' --filter='!@e2e-tests/*' --filter='!@composio/cli'
77 + && pnpm run test:examples
78
79 - name: Build packages for consumer compatibility
80 run: pnpm run build:packages
81
82 - name: Check packed provider compatibility
83 run: pnpm run check:provider-compatibility
84 +
85 + test-cli:
86 + name: Test CLI (@composio/cli)
87 + runs-on: ubuntu-latest
88 + timeout-minutes: 20
89 +
90 + steps:
91 + - name: Checkout Code
92 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
93 +
94 + - name: Setup Node.js, pnpm, Bun
95 + uses: ./.github/actions/setup-node-pnpm-bun
96 + with:
97 + enable-turbo-cache: 'true'
98 +
99 + - name: Install Dependencies
100 + run: pnpm install --frozen-lockfile
101 +
102 + # Package-scoped turbo invocation so the CLI's dependency builds
103 + # (test dependsOn ^build) still run before its vitest suite.
104 + - name: Run CLI Tests
105 + run: pnpm exec turbo run test --filter=@composio/cli
toolchain-versions.json
+6 -1
@@ -1,4 +1,9 @@
1 {
2 "node": ["22.22.3", "24.17.0", "25.9.0"],
3 - "python": ["3.11", "3.13", "3.15"]
3 + "python": ["3.11", "3.13", "3.15"],
4 + "nodeDigests": {
5 + "22.22.3": "sha256:e21fc383b50d5347dc7a9f1cae45b8f4e2f0d39f7ade28e4eef7d2934522b752",
6 + "24.17.0": "sha256:862263c612aa437e3037674b85419622a9d93bff80aa1eee5398dfe686375532",
7 + "25.9.0": "sha256:81db02c4b671288a03915da9534dbd54f96d0e7c24d80ccc54f5b36b2e684370"
8 + }
9 }
ts/e2e-tests/_utils/Dockerfile.cli
+10 -5
@@ -1,15 +1,19 @@
1 # Reusable Dockerfile for CLI e2e tests (debian runtime)
2 -# Usage: docker build -f Dockerfile.cli --build-arg CLI_VERSION=0.1.24 --build-arg NODE_VERSION=22.22.3 -t test-name .
2 +# Usage: docker build -f Dockerfile.cli --build-arg CLI_VERSION=0.1.24 --build-arg NODE_VERSION=22.22.3 --build-arg NODE_VERSION_DIGEST=sha256:e21fc383b50d5347dc7a9f1cae45b8f4e2f0d39f7ade28e4eef7d2934522b752 -t test-name .
3
4 ARG NODE_VERSION
5 +# Digest pin for the node:${NODE_VERSION}-slim base image; must come from toolchain-versions.json (no default on purpose so builds fail loudly instead of silently floating).
6 +ARG NODE_VERSION_DIGEST
7 ARG CLI_VERSION=0.0.0
6 -# Base images come from the ECR Public mirror of the Docker Official Images, so
7 -# builds do not depend on Docker Hub's availability or anonymous pull limits.
8 +# Base images are digest-pinned for supply-chain integrity. ECR Public mirrors the
9 +# Docker Official Images, so builds do not depend on Docker Hub availability, but
10 +# its anonymous rate limit can still return 429 on shared runner IPs; CI mitigates
11 +# that by retrying with backoff (see .github/actions/build-e2e-image).
12 ARG BASE_REGISTRY=public.ecr.aws/docker/library
13
14 # The toolchain stage depends only on the base image and mise.toml/mise.lock, so
15 # CI saves its layers to the GitHub Actions cache (see .github/actions/build-e2e-image).
12 -FROM ${BASE_REGISTRY}/node:${NODE_VERSION}-slim AS toolchain
16 +FROM ${BASE_REGISTRY}/node:${NODE_VERSION}-slim@${NODE_VERSION_DIGEST} AS toolchain
17
18 ENV MISE_DATA_DIR="/mise"
19 ENV MISE_CACHE_DIR="/mise/cache"
@@ -78,7 +82,8 @@ COPY ts/e2e-tests/cli/ /app/ts/e2e-tests/cli/
82 # Pre-create Composio CLI cache directory to work around Bun issue #7967
83 RUN mkdir -p /tmp/.composio
84
81 -FROM ${BASE_REGISTRY}/debian:bookworm-slim
85 +# Runtime base pinned by digest, matching Dockerfile.install (same supply-chain rationale).
86 +FROM ${BASE_REGISTRY}/debian:bookworm-slim@sha256:7c7b2c966bc9ee8cedfeef67e0e279108992c77681fa595db4a9d65c06ccc587
87
88 ENV PATH="/usr/local/bin:/bin"
89 ENV HOME="/tmp"
ts/e2e-tests/_utils/Dockerfile.install
+5 -3
@@ -1,8 +1,10 @@
1 -# Base images come from the ECR Public mirror of the Docker Official Images, so
2 -# builds do not depend on Docker Hub's availability or anonymous pull limits.
1 +# Base images are digest-pinned for supply-chain integrity. ECR Public mirrors the
2 +# Docker Official Images, so builds do not depend on Docker Hub availability, but
3 +# its anonymous rate limit can still return 429 on shared runner IPs; CI mitigates
4 +# that by retrying with backoff (see .github/actions/build-e2e-image).
5 ARG BASE_REGISTRY=public.ecr.aws/docker/library
6
5 -FROM ${BASE_REGISTRY}/debian:bookworm-slim
7 +FROM ${BASE_REGISTRY}/debian:bookworm-slim@sha256:7c7b2c966bc9ee8cedfeef67e0e279108992c77681fa595db4a9d65c06ccc587
8
9 ARG INSTALL_SHELL=bash
10
ts/e2e-tests/_utils/Dockerfile.node
+10 -5
@@ -1,21 +1,26 @@
1 # Reusable Dockerfile for Node.js e2e tests
2 -# Usage: docker build -f Dockerfile.node --build-arg NODE_VERSION=22.22.3 -t test-name .
2 +# Usage: docker build -f Dockerfile.node --build-arg NODE_VERSION=22.22.3 --build-arg NODE_VERSION_DIGEST=sha256:e21fc383b50d5347dc7a9f1cae45b8f4e2f0d39f7ade28e4eef7d2934522b752 -t test-name .
3 #
4 -# Uses official node:slim images, pulled from the ECR Public mirror. For multi-version testing, run the build/run
4 +# Uses official node:slim images. For multi-version testing, run the build/run
5 # multiple times with different NODE_VERSION values from the shell script.
6 #
7 +# Base images are digest-pinned for supply-chain integrity. ECR Public mirrors the
8 +# Docker Official Images, so builds do not depend on Docker Hub availability, but
9 +# its anonymous rate limit can still return 429 on shared runner IPs; CI mitigates
10 +# that by retrying with backoff (see .github/actions/build-e2e-image).
11 +#
12 # bun and pnpm are installed from mise.toml/mise.lock (the single source of truth).
13 # Node is the test matrix axis and stays on the base image, so it is disabled in
14 # mise (MISE_DISABLE_TOOLS) to avoid shadowing the base image's Node.
15
16 ARG NODE_VERSION
12 -# Base images come from the ECR Public mirror of the Docker Official Images, so
13 -# builds do not depend on Docker Hub's availability or anonymous pull limits.
17 +# Digest pin for the node:${NODE_VERSION}-slim base image; must come from toolchain-versions.json (no default on purpose so builds fail loudly instead of silently floating).
18 +ARG NODE_VERSION_DIGEST
19 ARG BASE_REGISTRY=public.ecr.aws/docker/library
20
21 # The toolchain stage depends only on the base image and mise.toml/mise.lock, so
22 # CI saves its layers to the GitHub Actions cache (see .github/actions/build-e2e-image).
18 -FROM ${BASE_REGISTRY}/node:${NODE_VERSION}-slim AS toolchain
23 +FROM ${BASE_REGISTRY}/node:${NODE_VERSION}-slim@${NODE_VERSION_DIGEST} AS toolchain
24
25 ENV MISE_DATA_DIR="/mise"
26 ENV MISE_CACHE_DIR="/mise/cache"
ts/e2e-tests/_utils/scripts/docker-build.ts
+3 -3
@@ -14,7 +14,7 @@ import { resolve, dirname } from 'node:path';
14 import { fileURLToPath } from 'node:url';
15 import { readFileSync } from 'node:fs';
16 import { execFileSync } from 'node:child_process';
17 -import { WELL_KNOWN_NODE_VERSIONS } from '../src/const';
17 +import { WELL_KNOWN_NODE_VERSIONS, nodeDigestFor } from '../src/const';
18
19 const __dirname = dirname(fileURLToPath(import.meta.url));
20
@@ -77,7 +77,7 @@ async function buildNodeImage(nodeVersion: string, repoRoot: string): Promise<bo
77 console.log(`\nBuilding image for Node.js ${nodeVersion}...`);
78
79 const result =
80 - await $`docker build -f ${dockerfilePath} --build-arg NODE_VERSION=${nodeVersion} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`
80 + await $`docker build -f ${dockerfilePath} --build-arg NODE_VERSION=${nodeVersion} --build-arg NODE_VERSION_DIGEST=${nodeDigestFor(nodeVersion)} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`
81 .cwd(repoRoot)
82 .nothrow();
83
@@ -122,7 +122,7 @@ async function buildCliImage(
122 console.log(`\nBuilding image for CLI ${cliVersion}...`);
123
124 const result =
125 - await $`docker build -f ${dockerfilePath} --build-arg CLI_VERSION=${cliVersion} --build-arg NODE_VERSION=${toolchain.nodeVersion} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`
125 + await $`docker build -f ${dockerfilePath} --build-arg CLI_VERSION=${cliVersion} --build-arg NODE_VERSION=${toolchain.nodeVersion} --build-arg NODE_VERSION_DIGEST=${nodeDigestFor(toolchain.nodeVersion)} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`
126 .cwd(repoRoot)
127 .nothrow();
128
ts/e2e-tests/_utils/src/const.ts
+17
@@ -16,6 +16,23 @@ export const WELL_KNOWN_ENV_VARS = [
16 */
17 export const WELL_KNOWN_NODE_VERSIONS = [...toolchainVersions.node, 'current'] as const;
18
19 +/**
20 + * Returns the sha256 digest pinned for a Node.js version in toolchain-versions.json.
21 + * Throws when the version has no pinned digest, so an unpinned image build fails
22 + * loudly instead of silently floating on a mutable base image tag.
23 + */
24 +export function nodeDigestFor(nodeVersion: string): string {
25 + const digests = toolchainVersions.nodeDigests as Record<string, string>;
26 + const digest = digests[nodeVersion];
27 + if (!digest) {
28 + throw new Error(
29 + `No digest pin found for Node.js ${nodeVersion} in toolchain-versions.json (nodeDigests). ` +
30 + 'Add a digest pin for this version, or builds would float on an untagged base image.'
31 + );
32 + }
33 + return digest;
34 +}
35 +
36 /**
37 * CLI versions that are well-known to the CI strategy.
38 * `current` refers to the version in ts/packages/cli/package.json.
ts/e2e-tests/_utils/src/image-lifecycle.ts
+12 -3
@@ -3,6 +3,7 @@ import { existsSync } from 'node:fs';
3 import { homedir } from 'node:os';
4 import { resolve } from 'node:path';
5 import { getRepoRoot } from './config';
6 +import { nodeDigestFor } from './const';
7
8 /**
9 * Result of executing a command.
@@ -224,9 +225,13 @@ export async function ensureNodeImage(
225 }
226
227 const repoRoot = options.repoRoot ?? getRepoRoot();
228 + // `current` must resolve to the mise-pinned version so the tag, build arg, and
229 + // digest lookup all reference a concrete Node.js release.
230 + const resolvedVersion =
231 + nodeVersion === 'current' ? await getMiseVersion('node', repoRoot) : nodeVersion;
232 const dockerfilePath =
233 options.dockerfilePath ?? resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.node');
229 - const imageTag = imageTagForNodeVersion(nodeVersion);
234 + const imageTag = imageTagForNodeVersion(resolvedVersion);
235
236 const inspect = await exec('docker', ['image', 'inspect', imageTag], { cwd: repoRoot });
237 if (inspect.exitCode === 0) {
@@ -238,8 +243,10 @@ export async function ensureNodeImage(
243 '-f',
244 dockerfilePath,
245 '--build-arg',
241 - `NODE_VERSION=${nodeVersion}`,
242 - ...labelsToArgs(defaultNodeLabels(nodeVersion)),
246 + `NODE_VERSION=${resolvedVersion}`,
247 + '--build-arg',
248 + `NODE_VERSION_DIGEST=${nodeDigestFor(resolvedVersion)}`,
249 + ...labelsToArgs(defaultNodeLabels(resolvedVersion)),
250 '-t',
251 imageTag,
252 repoRoot,
@@ -418,6 +425,8 @@ export async function ensureCliImage(
425 `CLI_VERSION=${cliVersion}`,
426 '--build-arg',
427 `NODE_VERSION=${nodeVersion}`,
428 + '--build-arg',
429 + `NODE_VERSION_DIGEST=${nodeDigestFor(nodeVersion)}`,
430 ...labelsToArgs(defaultCliLabels(cliVersion)),
431 '-t',
432 imageTag,
ts/packages/cli/src/analytics/dispatch.ts
+14 -1
@@ -263,8 +263,21 @@ const getOrCreateInstallIdUnlocked = Effect.gen(function* () {
263 return installId;
264 });
265
266 +// A process whose bounded lock wait expired (a live lock held elsewhere) must
267 +// still adopt an install_id another process already persisted, so concurrent
268 +// first-run events converge on one identity instead of each racer minting its
269 +// own. The fallback only reads: persistence stays exclusive to the lock-holding
270 +// path, and an unlocked write here could clobber a concurrent state merge.
271 +const adoptOrMintInstallId = Effect.gen(function* () {
272 + const state = yield* readAnalyticsState;
273 + if (typeof state?.install_id === 'string' && state.install_id.length > 0) {
274 + return state.install_id;
275 + }
276 + return yield* makeInstallId;
277 +});
278 +
279 const getOrCreateInstallId = withAnalyticsStateLock(getOrCreateInstallIdUnlocked).pipe(
267 - Effect.catch(() => makeInstallId)
280 + Effect.catch(() => adoptOrMintInstallId)
281 );
282
283 const mergeAnalyticsStateUnlocked = (installId: string, patch: Partial<AnalyticsState>) =>
ts/packages/cli/test/src/analytics.dispatch.test.ts
+35
@@ -607,6 +607,41 @@ describe('CLI analytics dispatch', () => {
607 }).pipe(Effect.provide(makePlatformLayer(home)));
608 });
609
610 + it.effect('adopts the persisted install_id when the bounded lock wait expires', () => {
611 + const home = tempy.temporaryDirectory();
612 + const scriptPath = path.join(home, 'composio.ts');
613 + const composioDir = path.join(home, '.composio');
614 + const lockPath = path.join(composioDir, 'analytics.json.lock');
615 + enableTelemetry('');
616 + process.argv[1] = scriptPath;
617 + mkdirSync(composioDir, { recursive: true });
618 + writeFileSync(scriptPath, '');
619 + // A live lock that is never released drives this process through the full
620 + // bounded wait; the identity another run already persisted must still win
621 + // over minting a fresh install_id, and the fallback must not rewrite state
622 + // without holding the lock.
623 + writeFileSync(lockPath, 'other-process');
624 + writeFileSync(
625 + path.join(composioDir, 'analytics.json'),
626 + JSON.stringify({ install_id: 'install_persisted' })
627 + );
628 +
629 + return Effect.gen(function* () {
630 + const fs = yield* FileSystem.FileSystem;
631 + yield* trackCliEventEffect({ name: CLI_ANALYTICS_EVENTS.CLI_SETUP_SUCCEEDED });
632 +
633 + expect(childProcessMocks.spawn).toHaveBeenCalledTimes(1);
634 + const args = childProcessMocks.spawn.mock.calls[0]![1] as string[];
635 + const payload = decodeWorkerPayload<{ installId: string }>(args[2]!);
636 + expect(payload.installId).toBe('install_persisted');
637 +
638 + const persisted = JSON.parse(
639 + yield* fs.readFileString(path.join(composioDir, 'analytics.json'), 'utf8')
640 + ) as { install_id: string };
641 + expect(persisted.install_id).toBe('install_persisted');
642 + }).pipe(Effect.provide(makePlatformLayer(home)));
643 + });
644 +
645 it.effect('keys post-login events on the persisted apollo_user_id', () => {
646 const home = tempy.temporaryDirectory();
647 const scriptPath = `${home}/composio.ts`;