Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 06:00 UTC
feat(release): build and smoke-test release candidates on the PR
The release PR builds the exact npm and PyPI files to publish and installs them in a clean project like a user would. The build runs on pull_request with no secrets and records each file's checksum.
jkomyno committed
Nov 5, 2026 at 17:48 UTC
56921c14edf8c70bb1fe62bc9650552c6a226919
8 files changed
+1174
.github/workflows/sdk.release.candidates.yml
new
+125
@@ -0,0 +1,125 @@
1
+name: SDK release candidates
2
+run-name: SDK release candidates (${{ github.head_ref }})
3
+
4
+# Builds and checks the package files a release PR will publish. This workflow only runs on
5
+# pull_request, with a read-only token, no secrets and no caches. The privileged SDK release
6
+# workflow never checks out PR code; after approval and merge, its tag run publishes these exact
7
+# artifacts.
8
+on:
9
+ pull_request:
10
+ branches: [next]
11
+ paths: ['.github/sdk-release-plan.json', 'scripts/sdk-release/**']
12
+
13
+permissions:
14
+ contents: read
15
+ actions: read
16
+
17
+jobs:
18
+ select-candidates:
19
+ if: >-
20
+ github.repository == 'ComposioHQ/composio' &&
21
+ startsWith(github.event.pull_request.head.ref, 'sdk-release/batch-')
22
+ runs-on: ubuntu-latest
23
+ outputs:
24
+ typescript: ${{ steps.select.outputs.typescript }}
25
+ python: ${{ steps.select.outputs.python }}
26
+ languages: ${{ steps.select.outputs.languages }}
27
+ steps:
28
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
29
+ with:
30
+ ref: ${{ github.event.pull_request.head.sha }}
31
+ persist-credentials: false
32
+ - name: Select planned language lanes
33
+ id: select
34
+ run: |
35
+ node --input-type=module <<'JS'
36
+ import { readFileSync, appendFileSync } from 'node:fs';
37
+ const batch = JSON.parse(readFileSync('.github/sdk-release-plan.json', 'utf8'));
38
+ const languages = [...new Set(batch.plan.releases.map(release => release.language))];
39
+ // Languages reach shell steps through the matrix, so accept only known values.
40
+ if (!languages.every(language => ['typescript', 'python'].includes(language))) throw new Error('Unknown release language');
41
+ appendFileSync(process.env.GITHUB_OUTPUT, `languages=${JSON.stringify(languages)}\n`);
42
+ for (const language of ['typescript', 'python']) appendFileSync(process.env.GITHUB_OUTPUT, `${language}=${languages.includes(language)}\n`);
43
+ JS
44
+
45
+ candidate:
46
+ # The release merge requires this check name to pass on the approved head.
47
+ name: SDK candidate (${{ matrix.language }})
48
+ needs: select-candidates
49
+ if: needs.select-candidates.outputs.typescript == 'true' || needs.select-candidates.outputs.python == 'true'
50
+ runs-on: ubuntu-latest
51
+ strategy:
52
+ fail-fast: false
53
+ matrix:
54
+ language: ${{ fromJSON(needs.select-candidates.outputs.languages) }}
55
+ steps:
56
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
57
+ with:
58
+ ref: ${{ github.event.pull_request.head.sha }}
59
+ persist-credentials: false
60
+ - uses: ./.github/actions/setup-node-pnpm-bun
61
+ with:
62
+ enable-caching: 'false'
63
+ - uses: ./.github/actions/setup-python-uv
64
+ with:
65
+ enable-caching: 'false'
66
+ if: matrix.language == 'python'
67
+ - run: pnpm install --frozen-lockfile --ignore-scripts
68
+ - name: Build and check the candidate
69
+ id: build
70
+ env:
71
+ SDK_SOURCE_SHA: ${{ github.event.pull_request.head.sha }}
72
+ run: bun scripts/sdk-release/candidates.ts ${{ matrix.language }}
73
+ - name: Retain candidate bytes for publication
74
+ if: steps.build.outputs.selected == 'true'
75
+ id: upload
76
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
77
+ with:
78
+ name: sdk-candidate-${{ matrix.language }}
79
+ path: sdk-candidate/${{ matrix.language }}/
80
+ retention-days: 30
81
+ if-no-files-found: error
82
+ overwrite: true
83
+ - name: Report candidate identity
84
+ if: steps.build.outputs.selected == 'true'
85
+ env:
86
+ ARTIFACT_ID: ${{ steps.upload.outputs.artifact-id }}
87
+ ARTIFACT_DIGEST: ${{ steps.upload.outputs.artifact-digest }}
88
+ SOURCE_SHA: ${{ github.event.pull_request.head.sha }}
89
+ SDK_READ_TOKEN: ${{ github.token }}
90
+ run: bun scripts/sdk-release/candidates.ts report ${{ matrix.language }}
91
+
92
+ # Installs third-party packages from the registries, so it runs apart from the build job and
93
+ # has no upload step. Code it runs still holds this run's runtime token, so the tag run refuses
94
+ # any candidate artifact created after the build job finished.
95
+ smoke:
96
+ # The release merge requires this check name to pass on the approved head.
97
+ name: SDK candidate smoke (${{ matrix.language }})
98
+ needs: [select-candidates, candidate]
99
+ runs-on: ubuntu-latest
100
+ permissions:
101
+ contents: read
102
+ actions: read
103
+ strategy:
104
+ fail-fast: false
105
+ matrix:
106
+ language: ${{ fromJSON(needs.select-candidates.outputs.languages) }}
107
+ steps:
108
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
109
+ with:
110
+ ref: ${{ github.event.pull_request.head.sha }}
111
+ persist-credentials: false
112
+ - uses: ./.github/actions/setup-node-pnpm-bun
113
+ with:
114
+ enable-caching: 'false'
115
+ - uses: ./.github/actions/setup-python-uv
116
+ with:
117
+ enable-caching: 'false'
118
+ if: matrix.language == 'python'
119
+ - run: pnpm install --frozen-lockfile --ignore-scripts
120
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333
121
+ with:
122
+ name: sdk-candidate-${{ matrix.language }}
123
+ path: sdk-candidate/${{ matrix.language }}
124
+ - name: Install and import the candidate like a user
125
+ run: bun scripts/sdk-release/consumers.ts sdk-candidate/${{ matrix.language }}
scripts/sdk-release/artifacts.ts
new
+163
@@ -0,0 +1,163 @@
1
+import { Effect, FileSystem, Option, Schema, Stream } from 'effect';
2
+import { FetchHttpClient, HttpClient } from 'effect/http';
3
+import { GitHub, PositiveInt, REPOSITORY_PATH, Sha, paginate } from './github';
4
+import { Language } from './lanes';
5
+import { ensure, fail, run, sha256Hex, withoutReleaseTokens } from './runtime';
6
+
7
+const Digest = Schema.String.check(Schema.isPattern(/^sha256:[a-f0-9]{64}$/));
8
+const IsoDate = Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T/));
9
+const ArchiveEntry = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
10
+
11
+export const CandidateFile = Schema.Struct({
12
+ name: Schema.String.check(Schema.isPattern(ArchiveEntry)),
13
+ sha256: Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/)),
14
+ size: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
15
+});
16
+export type CandidateFile = typeof CandidateFile.Type;
17
+
18
+export const CandidateManifest = Schema.Struct({
19
+ sourceSha: Sha,
20
+ producerRun: PositiveInt,
21
+ language: Language,
22
+ files: Schema.Array(CandidateFile).check(
23
+ Schema.isMinLength(1),
24
+ Schema.makeFilter(files =>
25
+ new Set(files.map(file => file.name)).size === files.length
26
+ ? undefined
27
+ : 'Candidate filenames must be unique'
28
+ )
29
+ ),
30
+});
31
+export type CandidateManifest = typeof CandidateManifest.Type;
32
+
33
+/** Name of the manifest each candidate artifact carries next to its distributions. */
34
+export const CANDIDATE_MANIFEST = 'candidate.json';
35
+export const candidateArtifactName = (language: Language) => `sdk-candidate-${language}`;
36
+
37
+export const ActionArtifact = Schema.Struct({
38
+ id: PositiveInt,
39
+ name: Schema.String,
40
+ digest: Digest,
41
+ expired: Schema.Boolean,
42
+ created_at: IsoDate,
43
+ expires_at: IsoDate,
44
+ workflow_run: Schema.Struct({ id: PositiveInt, head_sha: Sha }),
45
+});
46
+export type CandidateArtifact = typeof ActionArtifact.Type;
47
+
48
+export const normalizeArtifactDigest = (value: unknown) =>
49
+ Effect.gen(function* () {
50
+ const digest = yield* Schema.decodeUnknownEffect(Schema.String)(value);
51
+ return yield* Schema.decodeUnknownEffect(Digest)(
52
+ digest.startsWith('sha256:') ? digest : `sha256:${digest}`
53
+ );
54
+ });
55
+
56
+/** An artifact is usable while GitHub still retains it. */
57
+const isRetained = (artifact: CandidateArtifact, now: number) =>
58
+ !artifact.expired && Date.parse(artifact.expires_at) > now;
59
+
60
+/** The run's single artifact with this name, if it was produced from this source and is still retained. */
61
+export const reuseCandidate = (
62
+ artifacts: ReadonlyArray<CandidateArtifact>,
63
+ name: string,
64
+ producerRun: number,
65
+ sourceSha: string,
66
+ now = Date.now()
67
+) =>
68
+ Effect.gen(function* () {
69
+ const matching = artifacts.filter(artifact => artifact.name === name);
70
+ yield* ensure(matching.length <= 1, 'Multiple immutable candidates have the same name');
71
+ const [artifact] = matching;
72
+ if (!artifact) return Option.none<CandidateArtifact>();
73
+ yield* ensure(
74
+ artifact.workflow_run.id === producerRun && artifact.workflow_run.head_sha === sourceSha,
75
+ 'Candidate source or producer does not match'
76
+ );
77
+ yield* ensure(
78
+ isRetained(artifact, now),
79
+ 'Original candidate unavailable; add changesets and request a new release'
80
+ );
81
+ return Option.some(yield* Schema.decodeUnknownEffect(ActionArtifact)(artifact));
82
+ });
83
+
84
+export const verifyArchive = (bytes: Uint8Array, digest: string) =>
85
+ Effect.gen(function* () {
86
+ yield* ensure(
87
+ `sha256:${yield* sha256Hex(bytes)}` === digest,
88
+ 'Actions artifact archive digest mismatch'
89
+ );
90
+ });
91
+
92
+export const verifyCandidateFiles = (
93
+ actual: ReadonlyMap<string, Uint8Array>,
94
+ expected: ReadonlyArray<CandidateFile>
95
+) =>
96
+ Effect.gen(function* () {
97
+ yield* ensure(actual.size === expected.length, 'Candidate file inventory mismatch');
98
+ for (const file of expected) {
99
+ const bytes = actual.get(file.name);
100
+ yield* ensure(
101
+ bytes !== undefined &&
102
+ bytes.length === file.size &&
103
+ (yield* sha256Hex(bytes)) === file.sha256,
104
+ `Candidate checksum mismatch: ${file.name}`
105
+ );
106
+ }
107
+ });
108
+
109
+export const readCandidateFiles = (directory: string) =>
110
+ Effect.gen(function* () {
111
+ const fs = yield* FileSystem.FileSystem;
112
+ const names = (yield* fs.readDirectory(directory)).filter(name => name !== CANDIDATE_MANIFEST);
113
+ return new Map(
114
+ yield* Effect.forEach(names, name =>
115
+ Effect.map(fs.readFile(`${directory}/${name}`), bytes => [name, bytes] as const)
116
+ )
117
+ );
118
+ });
119
+
120
+export const originalCandidates = (run: number) =>
121
+ Stream.runCollect(
122
+ paginate(
123
+ `${REPOSITORY_PATH}/actions/runs/${run}/artifacts`,
124
+ Schema.Struct({ artifacts: Schema.Array(ActionArtifact) }),
125
+ body => body.artifacts
126
+ )
127
+ );
128
+
129
+/** Downloads an original Actions artifact, checks its digest and archive paths, and unpacks it into `directory`. */
130
+export const downloadCandidate = (artifact: { id: number; digest: string }, directory: string) =>
131
+ Effect.gen(function* () {
132
+ const github = yield* GitHub;
133
+ const fs = yield* FileSystem.FileSystem;
134
+ const client = yield* HttpClient.HttpClient;
135
+ const location = yield* github.redirectLocation(
136
+ `${REPOSITORY_PATH}/actions/artifacts/${artifact.id}/zip`
137
+ );
138
+ const url = yield* Option.match(location, {
139
+ onNone: () => fail('Artifact download has no archive location'),
140
+ onSome: value => Effect.try(() => new URL(value)),
141
+ });
142
+ yield* ensure(url.protocol === 'https:', 'Expected an HTTPS artifact archive');
143
+ const archive = yield* client
144
+ .get(url)
145
+ .pipe(Effect.provideService(FetchHttpClient.RequestInit, { redirect: 'error' }));
146
+ yield* ensure(
147
+ archive.status >= 200 && archive.status < 300,
148
+ 'Original artifact is unavailable'
149
+ );
150
+ const bytes = new Uint8Array(yield* archive.arrayBuffer);
151
+ yield* verifyArchive(bytes, artifact.digest);
152
+ const zip = `${directory}.zip`;
153
+ yield* fs.makeDirectory(directory, { recursive: true });
154
+ yield* fs.writeFile(zip, bytes);
155
+ const paths = (yield* run('unzip', ['-Z1', zip], { env: withoutReleaseTokens }))
156
+ .trim()
157
+ .split('\n');
158
+ yield* ensure(
159
+ new Set(paths).size === paths.length && paths.every(path => ArchiveEntry.test(path)),
160
+ 'Unexpected artifact archive path'
161
+ );
162
+ yield* run('unzip', ['-q', zip, '-d', directory], { env: withoutReleaseTokens });
163
+ });
scripts/sdk-release/candidates.ts
new
+257
@@ -0,0 +1,257 @@
1
+import { Config, Effect, FileSystem, Option, Path, Schema, Stdio } from 'effect';
2
+import { getPackages } from '@manypkg/get-packages';
3
+import {
4
+ ActionArtifact,
5
+ CANDIDATE_MANIFEST,
6
+ CandidateManifest,
7
+ candidateArtifactName,
8
+ normalizeArtifactDigest,
9
+ reuseCandidate,
10
+} from './artifacts';
11
+import {
12
+ GitHub,
13
+ PositiveIntFromString,
14
+ REPOSITORY_PATH,
15
+ Sha,
16
+ request,
17
+} from './github';
18
+import { Language } from './lanes';
19
+import type { SdkRelease } from './plan';
20
+import { discoverPythonPackages } from './python-metadata';
21
+import {
22
+ appendFile,
23
+ ensure,
24
+ formatJson,
25
+ fromPromise,
26
+ inDirectory,
27
+ readJson,
28
+ runMain,
29
+ sha256Hex,
30
+ type ReleaseServices,
31
+} from './runtime';
32
+import { BATCH_PATH, ReleaseBatch } from './source';
33
+
34
+const PackedManifest = Schema.StructWithRest(
35
+ Schema.Struct({ name: Schema.String, version: Schema.String }),
36
+ [Schema.Record(Schema.String, Schema.Unknown)]
37
+);
38
+
39
+export const tarballName = (name: string, version: string) =>
40
+ `${name.replace(/^@/, '').replaceAll('/', '-')}-${version}.tgz`;
41
+
42
+/**
43
+ * Builds the SDK packages and packs the selected ones into `directory`. Provider compatibility is
44
+ * checked by ts.test.yml; this job runs no registry installs before the files are hashed.
45
+ */
46
+export const buildTypescript = (cwd: string, directory: string, names: ReadonlySet<string>) =>
47
+ Effect.gen(function* () {
48
+ const path = yield* Path.Path;
49
+ const exec = inDirectory(cwd);
50
+ const { packages } = yield* fromPromise(() => getPackages(cwd));
51
+ const selected = packages.filter(pkg => names.has(pkg.packageJson.name));
52
+ yield* exec('pnpm', [
53
+ 'exec',
54
+ 'turbo',
55
+ 'build',
56
+ ...selected.map(pkg => `--filter=${pkg.packageJson.name}`),
57
+ ]);
58
+ for (const pkg of selected) {
59
+ yield* exec('pnpm', [
60
+ '--dir',
61
+ pkg.dir,
62
+ 'pack',
63
+ '--pack-destination',
64
+ directory,
65
+ '--config.ignore-scripts=true',
66
+ ]);
67
+ const name = tarballName(pkg.packageJson.name, pkg.packageJson.version);
68
+ const packed = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(PackedManifest))(
69
+ yield* exec('tar', ['-xOf', path.join(directory, name), 'package/package.json'])
70
+ );
71
+ yield* ensure(
72
+ packed.name === pkg.packageJson.name && packed.version === pkg.packageJson.version,
73
+ 'Packed npm metadata differs from the approved source'
74
+ );
75
+ }
76
+ });
77
+
78
+const PYTHON_DISTRIBUTION = /\.whl$|\.tar\.gz$/;
79
+
80
+/** Builds the synchronized Python train with the locked release toolchain and keeps its distributions. */
81
+export const buildPython = (cwd: string, directory: string) =>
82
+ Effect.gen(function* () {
83
+ const fs = yield* FileSystem.FileSystem;
84
+ const path = yield* Path.Path;
85
+ const environment = { UV_PROJECT_ENVIRONMENT: path.resolve(cwd, 'python/.venv') };
86
+ const exec = inDirectory(cwd, environment);
87
+ yield* exec('uv', ['sync', '--locked', '--only-group', 'release']);
88
+ yield* inDirectory(path.join(cwd, 'python'), environment)('make', [
89
+ 'build',
90
+ 'BUILD_ARGS=--no-isolation',
91
+ ]);
92
+ yield* exec('uv', [
93
+ 'run',
94
+ '--locked',
95
+ '--only-group',
96
+ 'release',
97
+ 'python',
98
+ 'scripts/sdk-release/validate-python-candidates.py',
99
+ ]);
100
+ const dist = path.resolve(cwd, 'python/dist');
101
+ for (const name of (yield* fs.readDirectory(dist)).filter(name =>
102
+ PYTHON_DISTRIBUTION.test(name)
103
+ ))
104
+ yield* fs.copyFile(path.join(dist, name), path.join(directory, name));
105
+ });
106
+
107
+/** Lane-specific source checks and builds for a fresh candidate. */
108
+const LANE_BUILDS: Record<
109
+ Language,
110
+ {
111
+ readonly verifyTrain: (
112
+ cwd: string,
113
+ selected: ReadonlyArray<SdkRelease>
114
+ ) => Effect.Effect<void, unknown, ReleaseServices>;
115
+ readonly build: (
116
+ cwd: string,
117
+ directory: string,
118
+ selected: ReadonlyArray<SdkRelease>
119
+ ) => Effect.Effect<void, unknown, ReleaseServices>;
120
+ }
121
+> = {
122
+ typescript: {
123
+ verifyTrain: () => Effect.void,
124
+ build: (cwd, directory, selected) =>
125
+ buildTypescript(cwd, directory, new Set(selected.map(release => release.name))),
126
+ },
127
+ python: {
128
+ verifyTrain: (cwd, selected) =>
129
+ Effect.gen(function* () {
130
+ const [release] = selected;
131
+ const python = yield* discoverPythonPackages(cwd);
132
+ yield* ensure(
133
+ python.every(pkg => pkg.version === release.newVersion),
134
+ 'Python candidate train differs from the approved target'
135
+ );
136
+ }),
137
+ build: (cwd, directory) => buildPython(cwd, directory),
138
+ },
139
+};
140
+
141
+const BuildEnvironment = Config.all({
142
+ runId: Config.schema(PositiveIntFromString, 'GITHUB_RUN_ID'),
143
+ /** The release PR head; on pull_request, GITHUB_SHA is the merge commit instead. */
144
+ sha: Config.schema(Sha, 'SDK_SOURCE_SHA'),
145
+ ref: Config.String('GITHUB_REF'),
146
+ outputPath: Config.String('GITHUB_OUTPUT'),
147
+ controllerToken: Config.option(Config.String('SDK_RELEASE_TOKEN')),
148
+});
149
+type BuildEnvironment = Config.Success<typeof BuildEnvironment>;
150
+
151
+/** Release-PR runs build candidates; source-tag runs publish the approved release-PR bytes. */
152
+const isSourceTag = (ref: string) => ref.startsWith('refs/tags/sdk-release/');
153
+
154
+/** Builds a release-PR candidate. */
155
+const buildCandidate = (
156
+ env: BuildEnvironment,
157
+ language: Language,
158
+ selected: ReadonlyArray<SdkRelease>
159
+) =>
160
+ Effect.gen(function* () {
161
+ const fs = yield* FileSystem.FileSystem;
162
+ const path = yield* Path.Path;
163
+ const cwd = path.resolve('.');
164
+ const directory = path.resolve('sdk-candidate', language);
165
+ yield* fs.makeDirectory(directory, { recursive: true });
166
+ const lane = LANE_BUILDS[language];
167
+ yield* lane.verifyTrain(cwd, selected);
168
+ const { packages } = yield* fromPromise(() => getPackages(cwd));
169
+ for (const release of selected) {
170
+ const pkg = packages.find(candidate => candidate.packageJson.name === release.name);
171
+ yield* ensure(
172
+ pkg?.packageJson.version === release.newVersion,
173
+ `Candidate version differs from approved target: ${release.name}`
174
+ );
175
+ }
176
+ yield* lane.build(cwd, directory, selected);
177
+ const files = yield* Effect.forEach(yield* fs.readDirectory(directory), name =>
178
+ Effect.gen(function* () {
179
+ const bytes = yield* fs.readFile(`${directory}/${name}`);
180
+ return { name, sha256: yield* sha256Hex(bytes), size: bytes.length };
181
+ })
182
+ );
183
+ const manifest = yield* Schema.decodeUnknownEffect(CandidateManifest)({
184
+ sourceSha: env.sha,
185
+ producerRun: env.runId,
186
+ language,
187
+ files,
188
+ });
189
+ yield* fs.writeFileString(`${directory}/${CANDIDATE_MANIFEST}`, formatJson(manifest));
190
+ yield* appendFile(env.outputPath, 'selected=true\n');
191
+ });
192
+
193
+const buildMode = (language: Language) =>
194
+ Effect.gen(function* () {
195
+ const env = yield* BuildEnvironment;
196
+ yield* ensure(
197
+ !Option.exists(env.controllerToken, token => token !== ''),
198
+ 'Candidate jobs must not receive the controller credential'
199
+ );
200
+ yield* ensure(
201
+ !isSourceTag(env.ref),
202
+ 'Source-tag runs publish approved candidates, never builds'
203
+ );
204
+ const batch = yield* readJson(ReleaseBatch, BATCH_PATH);
205
+ const selected = batch.plan.releases.filter(release => release.language === language);
206
+ if (!selected.length) return yield* appendFile(env.outputPath, 'selected=false\n');
207
+ yield* buildCandidate(env, language, selected);
208
+ });
209
+
210
+const ReportEnvironment = Config.all({
211
+ artifactId: Config.schema(PositiveIntFromString, 'ARTIFACT_ID'),
212
+ artifactDigest: Config.String('ARTIFACT_DIGEST'),
213
+ sourceSha: Config.schema(Sha, 'SOURCE_SHA'),
214
+ runId: Config.schema(PositiveIntFromString, 'GITHUB_RUN_ID'),
215
+ summaryPath: Config.String('GITHUB_STEP_SUMMARY'),
216
+ token: Config.schema(Schema.NonEmptyString, 'SDK_READ_TOKEN'),
217
+});
218
+
219
+/** Confirms the uploaded artifact is this run's candidate and records its identity. */
220
+const reportMode = (language: Language) =>
221
+ Effect.gen(function* () {
222
+ const env = yield* ReportEnvironment;
223
+ const artifact = yield* request(
224
+ 'GET',
225
+ `${REPOSITORY_PATH}/actions/artifacts/${env.artifactId}`,
226
+ ActionArtifact
227
+ ).pipe(Effect.provide(GitHub.layer(env.token)));
228
+ yield* reuseCandidate([artifact], candidateArtifactName(language), env.runId, env.sourceSha);
229
+ yield* ensure(
230
+ artifact.digest === (yield* normalizeArtifactDigest(env.artifactDigest)),
231
+ 'Uploaded artifact digest differs'
232
+ );
233
+ const manifest = yield* readJson(
234
+ CandidateManifest,
235
+ `sdk-candidate/${language}/${CANDIDATE_MANIFEST}`
236
+ );
237
+ const files = manifest.files
238
+ .map(file => `- ${file.name}: ${file.sha256} (${file.size} bytes)`)
239
+ .join('\n');
240
+ yield* appendFile(
241
+ env.summaryPath,
242
+ `${language} candidate ID=${artifact.id} digest=${artifact.digest} producer=${env.runId} source=${env.sourceSha} expires=${artifact.expires_at}\n\n${files}\n`
243
+ );
244
+ });
245
+
246
+/** `candidates.ts <language>` builds a release-PR candidate; `report <language>` records it. */
247
+const Arguments = Schema.Union([
248
+ Schema.Tuple([Language]),
249
+ Schema.Tuple([Schema.Literal('report'), Language]),
250
+]);
251
+
252
+const main = Effect.gen(function* () {
253
+ const args = yield* Schema.decodeUnknownEffect(Arguments)(yield* (yield* Stdio.Stdio).args);
254
+ return yield* args.length === 1 ? buildMode(args[0]) : reportMode(args[1]);
255
+});
256
+
257
+if (import.meta.main) runMain(main);
scripts/sdk-release/consumers.ts
new
+340
@@ -0,0 +1,340 @@
1
+import { Effect, FileSystem, Path, Schema, Stdio } from 'effect';
2
+import { HttpClient } from 'effect/http';
3
+import { Toml } from 'effect/encoding';
4
+import { getPackages } from '@manypkg/get-packages';
5
+import {
6
+ CANDIDATE_MANIFEST,
7
+ CandidateManifest,
8
+ readCandidateFiles,
9
+ verifyCandidateFiles,
10
+} from './artifacts';
11
+import { tarballName } from './candidates';
12
+import { NPM_REGISTRY, type Language } from './lanes';
13
+import { discoverPythonPackages } from './python-metadata';
14
+import {
15
+ ensure,
16
+ fail,
17
+ fromPromise,
18
+ inDirectory,
19
+ readJson,
20
+ ReleaseError,
21
+ runMain,
22
+ writeFile,
23
+} from './runtime';
24
+import { BATCH_PATH, ReleaseBatch } from './source';
25
+import {
26
+ discoverProviderCases,
27
+ type ProviderCompatibilityCase,
28
+} from '../../ts/scripts/check-provider-compatibility';
29
+
30
+const PYPI_INDEX = 'https://pypi.org/simple';
31
+const Versioned = Schema.Struct({ version: Schema.String });
32
+const MiseTools = Schema.Struct({ tools: Schema.Struct({ python: Schema.String }) });
33
+
34
+type Release = ReleaseBatch['plan']['releases'][number];
35
+
36
+/** Third-party packages come from the registry; SDK packages come from the candidate directory. */
37
+export const npmInstallArgs = (
38
+ candidates: string,
39
+ releases: ReadonlyArray<Pick<Release, 'name' | 'newVersion'>>,
40
+ others: ReadonlyArray<string>
41
+) => [
42
+ 'install',
43
+ '--ignore-scripts',
44
+ '--no-audit',
45
+ '--no-fund',
46
+ `--registry=${NPM_REGISTRY}`,
47
+ ...others,
48
+ ...releases.map(release => `${candidates}/${tarballName(release.name, release.newVersion)}`),
49
+];
50
+
51
+/** The candidate wheel file for that package and version. */
52
+export const pythonRequirement = (
53
+ candidates: string,
54
+ wheels: ReadonlyArray<string>,
55
+ name: string,
56
+ version: string
57
+) => {
58
+ const prefix = `${name.replaceAll('-', '_')}-${version}-`;
59
+ const wheel = wheels.find(file => file.startsWith(prefix) && file.endsWith('.whl'));
60
+ return wheel && `${candidates}/${wheel}`;
61
+};
62
+
63
+const installedVersion = (manifest: string) =>
64
+ Effect.map(readJson(Versioned, manifest), value => value.version);
65
+
66
+/** Peers that are not released themselves resolve to the workspace or installed version. */
67
+const externalPeers = (
68
+ npm: ReadonlyArray<Release>,
69
+ packages: Awaited<ReturnType<typeof getPackages>>['packages']
70
+) =>
71
+ Effect.gen(function* () {
72
+ const path = yield* Path.Path;
73
+ const peers = new Map<string, string>();
74
+ for (const release of npm) {
75
+ const pkg = packages.find(candidate => candidate.packageJson.name === release.name);
76
+ for (const name of Object.keys(pkg?.packageJson.peerDependencies ?? {})) {
77
+ if (npm.some(selected => selected.name === name)) continue;
78
+ const local = packages.find(candidate => candidate.packageJson.name === name);
79
+ const version =
80
+ local?.packageJson.version ??
81
+ (yield* installedVersion(
82
+ path.join(pkg?.dir ?? '', 'node_modules', name, 'package.json')
83
+ ));
84
+ yield* ensure(
85
+ !peers.has(name) || peers.get(name) === version,
86
+ `Selected public consumers require incompatible versions of ${name}`
87
+ );
88
+ peers.set(name, version);
89
+ }
90
+ }
91
+ return peers;
92
+ });
93
+
94
+const PROVIDER_TOOL_FIXTURE = `
95
+import type { Tool, ExecuteToolFn } from '@composio/core';
96
+const tool: Tool = { slug: 'RELEASE_CHECK', name: 'Release check', description: 'Checks public provider conversion', inputParameters: { type: 'object', properties: { value: { type: 'string' } }, required: ['value'] }, toolkit: { slug: 'release', name: 'Release' }, tags: [] };
97
+const execute: ExecuteToolFn = async () => ({ data: {}, error: null, successful: true });
98
+`;
99
+
100
+/** Type-checks and runs a strict consumer of the installed packages and provider contracts. */
101
+export const checkStrictConsumer = (
102
+ directory: string,
103
+ names: ReadonlyArray<string>,
104
+ providers: ReadonlyArray<ProviderCompatibilityCase>
105
+) =>
106
+ Effect.gen(function* () {
107
+ const path = yield* Path.Path;
108
+ const command = inDirectory(directory);
109
+ const imports = names
110
+ .map(
111
+ (name, index) =>
112
+ `import * as sdk${index} from '${name}';\nconsole.log(Object.keys(sdk${index}).length);`
113
+ )
114
+ .join('\n');
115
+ const providerContracts = providers.length
116
+ ? `${PROVIDER_TOOL_FIXTURE}${providers
117
+ .map(
118
+ (provider, index) =>
119
+ `import { ${provider.providerExportName} as Provider${index} } from '${provider.name}';\nconst wrapped${index} = new Provider${index}().wrapTool(tool${provider.agentic ? ', execute' : ''});\nif (!wrapped${index}) throw new Error('${provider.name} failed public conversion');`
120
+ )
121
+ .join('\n')}`
122
+ : '';
123
+ yield* writeFile(path.join(directory, 'consumer.ts'), imports + providerContracts);
124
+ const providerDeclarationsOwnedByProviderCi = providers.length ? ['--skipLibCheck'] : [];
125
+ yield* command(path.join(directory, 'node_modules/.bin/tsc'), [
126
+ '--strict',
127
+ '--noEmit',
128
+ ...providerDeclarationsOwnedByProviderCi,
129
+ '--target',
130
+ 'ES2022',
131
+ '--module',
132
+ 'NodeNext',
133
+ '--moduleResolution',
134
+ 'NodeNext',
135
+ 'consumer.ts',
136
+ ]);
137
+ yield* command('node', ['consumer.ts']);
138
+ });
139
+
140
+/** Installs the candidate npm packages fresh and type-checks a strict consumer. */
141
+const verifyNpmConsumer = (
142
+ cwd: string,
143
+ batch: ReleaseBatch,
144
+ directory: string,
145
+ candidates: string
146
+) =>
147
+ Effect.gen(function* () {
148
+ const path = yield* Path.Path;
149
+ const command = inDirectory(directory);
150
+ const npm = batch.plan.releases.filter(release => release.language === 'typescript');
151
+ const { packages } = yield* fromPromise(() => getPackages(cwd));
152
+ const peers = yield* externalPeers(npm, packages);
153
+ const typescript = yield* installedVersion(
154
+ path.resolve(cwd, 'node_modules/typescript/package.json')
155
+ );
156
+ const nodeTypes = yield* installedVersion(
157
+ path.resolve(cwd, 'node_modules/@types/node/package.json')
158
+ );
159
+ yield* writeFile(
160
+ path.join(directory, 'package.json'),
161
+ JSON.stringify({ private: true, type: 'module' })
162
+ );
163
+ yield* command(
164
+ 'npm',
165
+ npmInstallArgs(candidates, npm, [
166
+ `typescript@${typescript}`,
167
+ `@types/node@${nodeTypes}`,
168
+ ...[...peers].map(([name, version]) => `${name}@${version}`),
169
+ ])
170
+ );
171
+ for (const release of npm) {
172
+ const installed = yield* installedVersion(
173
+ path.join(directory, 'node_modules', release.name, 'package.json')
174
+ );
175
+ yield* ensure(
176
+ installed === release.newVersion &&
177
+ packages.some(
178
+ pkg =>
179
+ pkg.packageJson.name === release.name &&
180
+ pkg.packageJson.version === release.newVersion
181
+ ),
182
+ `Candidate consumer installed the wrong version: ${release.name}`
183
+ );
184
+ }
185
+ const providers = (yield* fromPromise(() => discoverProviderCases())).filter(provider =>
186
+ npm.some(release => release.name === provider.name)
187
+ );
188
+ yield* checkStrictConsumer(
189
+ directory,
190
+ npm.map(release => release.name),
191
+ providers
192
+ );
193
+ });
194
+
195
+const pythonVerifier = (packages: ReadonlyArray<string>, version: string) =>
196
+ `import importlib, importlib.metadata, pathlib\npackages = ${JSON.stringify(packages)}\nfor name in packages:\n distribution = importlib.metadata.distribution(name)\n assert distribution.version == ${JSON.stringify(version)}, (name, distribution.version)\n markers = [file for file in distribution.files or [] if str(file).endswith('/py.typed')]\n assert markers, ('Missing typing metadata', name)\n modules = {str(marker).split('/')[0] for marker in markers}\n for module in modules:\n importlib.import_module(module)\n assert pathlib.Path(distribution.locate_file(module), 'py.typed').exists()\nprint('Verified public imports, exact versions and typing metadata:', packages)\n`;
197
+
198
+const pythonVersion = (cwd: string) =>
199
+ Effect.gen(function* () {
200
+ const fs = yield* FileSystem.FileSystem;
201
+ const path = yield* Path.Path;
202
+ const mise = yield* Effect.fromResult(
203
+ Toml.parse(yield* fs.readFileString(path.resolve(cwd, 'mise.toml')))
204
+ );
205
+ return (yield* Schema.decodeUnknownEffect(MiseTools)(mise)).tools.python;
206
+ });
207
+
208
+const candidateWheels = (candidates: string) =>
209
+ Effect.flatMap(FileSystem.FileSystem, fs => fs.readDirectory(candidates));
210
+
211
+/** Each Python package gets its own environment: providers have incompatible dependency trains. */
212
+const verifyPythonConsumer = (
213
+ cwd: string,
214
+ batch: ReleaseBatch,
215
+ directory: string,
216
+ candidates: string
217
+) =>
218
+ Effect.gen(function* () {
219
+ const path = yield* Path.Path;
220
+ const command = inDirectory(directory);
221
+ const version =
222
+ batch.plan.releases.find(release => release.language === 'python')?.newVersion ?? '';
223
+ const packages = yield* discoverPythonPackages(cwd);
224
+ const python = yield* pythonVersion(cwd);
225
+ const wheels = yield* candidateWheels(candidates);
226
+ const requirement = (name: string) =>
227
+ Effect.fromNullishOr(pythonRequirement(candidates, wheels, name, version)).pipe(
228
+ Effect.mapError(() => new ReleaseError({ message: `Missing candidate wheel: ${name}` }))
229
+ );
230
+ for (const pkg of packages) {
231
+ const environment = path.join(directory, pkg.name);
232
+ yield* command('uv', ['venv', '--python', python, environment]);
233
+ const executable = path.join(environment, 'bin/python');
234
+ const names = [...new Set(['composio', pkg.name])];
235
+ yield* command('uv', [
236
+ 'pip',
237
+ 'install',
238
+ '--python',
239
+ executable,
240
+ '--index-url',
241
+ PYPI_INDEX,
242
+ ...(yield* Effect.forEach(names, requirement)),
243
+ ]);
244
+ yield* command('uv', ['pip', 'check', '--python', executable]);
245
+ yield* writeFile(path.join(environment, 'verify.py'), pythonVerifier(names, version));
246
+ yield* command(executable, [path.join(environment, 'verify.py')]);
247
+ }
248
+ });
249
+
250
+const providerImport = (name: string) =>
251
+ `import importlib, importlib.metadata\ndistribution = importlib.metadata.distribution(${JSON.stringify(name)})\nmodules = {str(file).split('/')[0] for file in distribution.files or [] if str(file).endswith('/__init__.py')}\nassert modules, ('No importable modules', ${JSON.stringify(name)})\nfor module in sorted(modules):\n importlib.import_module(module)\nprint('Imported', ${JSON.stringify(name)}, distribution.version)\n`;
252
+
253
+/**
254
+ * Providers depend on an unpinned `composio`, so users can upgrade core alone: install the
255
+ * candidate core wheel with each provider's latest published version and import the provider.
256
+ */
257
+export const verifyPublishedProviders = (
258
+ cwd: string,
259
+ candidates: string,
260
+ version: string,
261
+ directory: string
262
+) =>
263
+ Effect.gen(function* () {
264
+ const path = yield* Path.Path;
265
+ const command = inDirectory(directory);
266
+ const python = yield* pythonVersion(cwd);
267
+ const core = pythonRequirement(
268
+ candidates,
269
+ yield* candidateWheels(candidates),
270
+ 'composio',
271
+ version
272
+ );
273
+ if (!core) return yield* fail('Missing candidate wheel: composio');
274
+ const providers = (yield* discoverPythonPackages(cwd)).filter(pkg => pkg.name !== 'composio');
275
+ const failures: string[] = [];
276
+ const client = yield* HttpClient.HttpClient;
277
+ for (const provider of providers) {
278
+ // A provider released for the first time has no published version to check against yet.
279
+ const published = yield* client.get(`https://pypi.org/pypi/${provider.name}/json`);
280
+ if (published.status === 404) continue;
281
+ const environment = path.join(directory, `published-${provider.name}`);
282
+ const executable = path.join(environment, 'bin/python');
283
+ yield* Effect.gen(function* () {
284
+ yield* command('uv', ['venv', '--python', python, environment]);
285
+ yield* command('uv', [
286
+ 'pip',
287
+ 'install',
288
+ '--python',
289
+ executable,
290
+ '--index-url',
291
+ PYPI_INDEX,
292
+ core,
293
+ provider.name,
294
+ ]);
295
+ yield* writeFile(path.join(environment, 'verify.py'), providerImport(provider.name));
296
+ yield* command(executable, [path.join(environment, 'verify.py')]);
297
+ }).pipe(
298
+ Effect.catch(error =>
299
+ Effect.sync(() =>
300
+ failures.push(
301
+ `Candidate composio breaks the latest published ${provider.name}: ${error.message}`
302
+ )
303
+ )
304
+ )
305
+ );
306
+ }
307
+ yield* ensure(failures.length === 0, failures.join('\n'));
308
+ });
309
+
310
+const CONSUMERS: Record<Language, typeof verifyNpmConsumer | typeof verifyPythonConsumer> = {
311
+ typescript: verifyNpmConsumer,
312
+ python: verifyPythonConsumer,
313
+};
314
+
315
+/** Checks a downloaded candidate against its manifest, then installs and imports it like a user. */
316
+export const verifyCandidateConsumers = (cwd: string, batch: ReleaseBatch, candidates: string) =>
317
+ Effect.scoped(
318
+ Effect.gen(function* () {
319
+ const fs = yield* FileSystem.FileSystem;
320
+ const manifest = yield* readJson(CandidateManifest, `${candidates}/${CANDIDATE_MANIFEST}`);
321
+ yield* verifyCandidateFiles(yield* readCandidateFiles(candidates), manifest.files);
322
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: 'sdk-candidate-consumer-' });
323
+ yield* CONSUMERS[manifest.language](cwd, batch, directory, candidates);
324
+ const python = batch.plan.releases.find(release => release.language === 'python');
325
+ if (manifest.language === 'python' && python)
326
+ yield* verifyPublishedProviders(cwd, candidates, python.newVersion, directory);
327
+ })
328
+ );
329
+
330
+/** `consumers.ts <candidate-dir>` installs a downloaded candidate like a user would. */
331
+const main = Effect.gen(function* () {
332
+ const path = yield* Path.Path;
333
+ const [candidates] = yield* Schema.decodeUnknownEffect(Schema.Tuple([Schema.String]))(
334
+ yield* (yield* Stdio.Stdio).args
335
+ );
336
+ const batch = yield* readJson(ReleaseBatch, BATCH_PATH);
337
+ yield* verifyCandidateConsumers(path.resolve('.'), batch, path.resolve(candidates));
338
+});
339
+
340
+if (import.meta.main) runMain(main);
scripts/sdk-release/lanes.ts
+21
@@ -3,6 +3,7 @@ import { Schema } from 'effect';
3
export const Language = Schema.Literals(['typescript', 'python']);
4
export type Language = typeof Language.Type;
5
export const LANGUAGES = Language.literals;
6
+export const NPM_REGISTRY = 'https://registry.npmjs.org';
7
8
/** Private workspace package whose Changesets version drives the synchronized Python train. */
9
export const PYTHON_RELEASE_MARKER = '@composio/python-sdk';
@@ -15,3 +16,23 @@ export const PRIMARY_TARGETS: Record<Language, ReadonlyArray<string>> = {
16
typescript: ['@composio/core', '@composio/slim'],
17
python: [PYTHON_RELEASE_MARKER],
18
};
19
+
20
+/** Where each language's registry serves metadata and files. */
21
+export const REGISTRY_LANES: Record<
22
+ Language,
23
+ {
24
+ /** Host that serves the lane's public distribution files. */
25
+ readonly downloadHost: string;
26
+ /** Public metadata URL for one package version. */
27
+ readonly versionUrl: (name: string, version: string) => string;
28
+ }
29
+> = {
30
+ typescript: {
31
+ downloadHost: 'registry.npmjs.org',
32
+ versionUrl: (name, version) => `${NPM_REGISTRY}/${encodeURIComponent(name)}/${version}`,
33
+ },
34
+ python: {
35
+ downloadHost: 'files.pythonhosted.org',
36
+ versionUrl: (name, version) => `https://pypi.org/pypi/${name}/${version}/json`,
37
+ },
38
+};
scripts/sdk-release/validate-python-candidates.py
new
+52
@@ -0,0 +1,52 @@
1
+"""Check the built stable train against the frozen project metadata."""
2
+import email.parser
3
+import pathlib
4
+import tarfile
5
+import tomllib
6
+import zipfile
7
+
8
+from packaging.requirements import Requirement
9
+from packaging.specifiers import SpecifierSet
10
+from packaging.utils import canonicalize_name
11
+
12
+root = pathlib.Path(__file__).resolve().parents[2]
13
+projects = [root / 'python', *sorted((root / 'python/providers').glob('*/pyproject.toml'))]
14
+projects = [path.parent if path.is_file() else path for path in projects]
15
+distributions = root / 'python/dist'
16
+expected = set()
17
+
18
+
19
+def requirement(value):
20
+ parsed = Requirement(value)
21
+ return (canonicalize_name(parsed.name), tuple(sorted(parsed.extras)), str(parsed.specifier), str(parsed.marker or ''))
22
+
23
+
24
+for directory in projects:
25
+ project = tomllib.loads((directory / 'pyproject.toml').read_text())['project']
26
+ name = canonicalize_name(project['name'])
27
+ version = project['version']
28
+ wheels = list(distributions.glob(f'{name.replace("-", "_")}-{version}-*.whl'))
29
+ sdists = list(distributions.glob(f'{name.replace("-", "_")}-{version}.tar.gz'))
30
+ assert len(wheels) == len(sdists) == 1, f'Expected one wheel and sdist for {name}'
31
+ expected.update([wheels[0].name, sdists[0].name])
32
+ with zipfile.ZipFile(wheels[0]) as wheel:
33
+ metadata_paths = [path for path in wheel.namelist() if path.endswith('.dist-info/METADATA')]
34
+ assert len(metadata_paths) == 1
35
+ metadata = email.parser.BytesParser().parsebytes(wheel.read(metadata_paths[0]))
36
+ assert any(path.endswith('/py.typed') for path in wheel.namelist()), f'Missing typed marker: {name}'
37
+ with tarfile.open(sdists[0]) as sdist:
38
+ package_info = [entry for entry in sdist.getmembers() if entry.name.count('/') == 1 and entry.name.endswith('/PKG-INFO')]
39
+ assert len(package_info) == 1
40
+ stream = sdist.extractfile(package_info[0])
41
+ assert stream is not None
42
+ sdist_metadata = email.parser.BytesParser().parsebytes(stream.read())
43
+ for built in [metadata, sdist_metadata]:
44
+ assert canonicalize_name(built['Name']) == name and built['Version'] == version
45
+ assert SpecifierSet(built['Requires-Python'] or '') == SpecifierSet(project.get('requires-python', '')), f'Python requirement changed: {name}'
46
+ actual = [requirement(value) for value in built.get_all('Requires-Dist', []) if 'extra ==' not in value]
47
+ wanted = [requirement(value) for value in project.get('dependencies', [])]
48
+ assert sorted(actual) == sorted(wanted), f'Dependency metadata changed: {name}'
49
+
50
+actual = {path.name for path in distributions.iterdir() if path.name.endswith(('.whl', '.tar.gz'))}
51
+assert actual == expected, f'Distribution inventory mismatch: {actual ^ expected}'
52
+print(f'Validated {len(projects)} projects and {len(expected)} distributions')
test/sdk-release-artifacts.test.ts
new
+56
@@ -0,0 +1,56 @@
1
+import { describe, expect, test } from 'bun:test';
2
+import { Option } from 'effect';
3
+import {
4
+ normalizeArtifactDigest,
5
+ reuseCandidate,
6
+ verifyArchive,
7
+ verifyCandidateFiles,
8
+} from '../scripts/sdk-release/artifacts';
9
+import { runRelease } from './sdk-release-harness';
10
+
11
+const head = 'b'.repeat(40);
12
+const base = 'a'.repeat(40);
13
+const files = [{ name: 'package.tgz', sha256: 'a'.repeat(64), size: 4 }];
14
+const artifact = {
15
+ id: 42,
16
+ name: 'sdk-candidate-typescript',
17
+ digest: `sha256:${'b'.repeat(64)}`,
18
+ expired: false,
19
+ expires_at: '2026-12-01T00:00:00Z',
20
+ workflow_run: { id: 8, head_sha: head },
21
+ created_at: '2026-11-01T00:00:00Z',
22
+};
23
+describe('immutable candidates', () => {
24
+ test('native upload and REST digests normalize without accepting malformed hashes', async () => {
25
+ const raw = 'a'.repeat(64);
26
+ expect(await runRelease(normalizeArtifactDigest(raw))).toBe(`sha256:${raw}`);
27
+ expect(await runRelease(normalizeArtifactDigest(`sha256:${raw}`))).toBe(`sha256:${raw}`);
28
+ await expect(runRelease(normalizeArtifactDigest(`sha256:${raw.slice(1)}`))).rejects.toThrow();
29
+ await expect(runRelease(normalizeArtifactDigest(`md5:${raw}`))).rejects.toThrow();
30
+ });
31
+ test('reuses IDs only from the original source and producer', async () => {
32
+ const reused = await runRelease(
33
+ reuseCandidate([artifact], artifact.name, 8, head, Date.parse('2026-11-03'))
34
+ );
35
+ expect(Option.getOrUndefined(reused)?.id).toBe(42);
36
+ await expect(runRelease(reuseCandidate([artifact], artifact.name, 9, head))).rejects.toThrow(
37
+ 'Candidate source or producer does not match'
38
+ );
39
+ await expect(runRelease(reuseCandidate([artifact], artifact.name, 8, base))).rejects.toThrow(
40
+ 'Candidate source or producer does not match'
41
+ );
42
+ await expect(
43
+ runRelease(reuseCandidate([{ ...artifact, expired: true }], artifact.name, 8, head))
44
+ ).rejects.toThrow('Original candidate unavailable');
45
+ });
46
+ test('archive digest and every file checksum fail closed', async () => {
47
+ await expect(runRelease(verifyArchive(new Uint8Array([1]), artifact.digest))).rejects.toThrow(
48
+ 'Actions artifact archive digest mismatch'
49
+ );
50
+ await expect(
51
+ runRelease(
52
+ verifyCandidateFiles(new Map([['package.tgz', new Uint8Array([1, 2, 3, 4])]]), files)
53
+ )
54
+ ).rejects.toThrow('Candidate checksum mismatch: package.tgz');
55
+ });
56
+});
test/sdk-release-consumers.test.ts
new
+160
@@ -0,0 +1,160 @@
1
+import { afterEach, describe, expect, test } from 'bun:test';
2
+import {
3
+ checkStrictConsumer,
4
+ npmInstallArgs,
5
+ pythonRequirement,
6
+ verifyPublishedProviders,
7
+} from '../scripts/sdk-release/consumers';
8
+import {
9
+ makeExecutable,
10
+ readText,
11
+ resolvePath,
12
+ runRelease,
13
+ symlink,
14
+ temporaryDirectories,
15
+ writeText,
16
+} from './sdk-release-harness';
17
+import { run, withoutReleaseTokens } from '../scripts/sdk-release/runtime';
18
+
19
+const directories = temporaryDirectories('sdk-consumer-');
20
+afterEach(directories.cleanup);
21
+
22
+const release = (name: string, newVersion: string) => ({ name, newVersion });
23
+
24
+describe('candidate package source', () => {
25
+ test('SDK packages install from candidate files, never by registry name', () => {
26
+ const args = npmInstallArgs(
27
+ '/work/sdk-candidate/typescript',
28
+ [release('@composio/core', '1.2.3'), release('@composio/openai', '2.0.0')],
29
+ ['typescript@5.9.3']
30
+ );
31
+ expect(args).toContain('/work/sdk-candidate/typescript/composio-core-1.2.3.tgz');
32
+ expect(args).toContain('/work/sdk-candidate/typescript/composio-openai-2.0.0.tgz');
33
+ expect(args.filter(arg => arg.startsWith('@composio/'))).toEqual([]);
34
+
35
+ const wheels = ['composio-0.9.0-py3-none-any.whl', 'composio_openai-0.9.0-py3-none-any.whl'];
36
+ const python = '/work/sdk-candidate/python';
37
+ expect(pythonRequirement(python, wheels, 'composio-openai', '0.9.0')).toBe(
38
+ '/work/sdk-candidate/python/composio_openai-0.9.0-py3-none-any.whl'
39
+ );
40
+ expect(pythonRequirement(python, wheels, 'composio', '0.9.0')).toBe(
41
+ '/work/sdk-candidate/python/composio-0.9.0-py3-none-any.whl'
42
+ );
43
+ expect(pythonRequirement(python, wheels, 'composio-gemini', '0.9.0')).toBeUndefined();
44
+ });
45
+});
46
+
47
+const exec = (cwd: string, executable: string, args: ReadonlyArray<string>) =>
48
+ runRelease(run(executable, args, { cwd, env: withoutReleaseTokens }));
49
+
50
+/** Packs a one-file package whose exports declare `./dist/index.js` and `./dist/index.d.ts`. */
51
+const fixtureTarball = async (root: string, files: Record<string, string>) => {
52
+ await writeText(
53
+ `${root}/package/package.json`,
54
+ JSON.stringify({
55
+ name: '@composio/release-fixture',
56
+ version: '1.0.0',
57
+ type: 'module',
58
+ exports: { '.': { types: './dist/index.d.ts', import: './dist/index.js' } },
59
+ })
60
+ );
61
+ for (const [name, contents] of Object.entries(files))
62
+ await writeText(`${root}/package/${name}`, contents);
63
+ await exec(root, 'tar', ['-czf', 'fixture.tgz', 'package']);
64
+ return `${root}/fixture.tgz`;
65
+};
66
+
67
+/** Installs the tarball offline into a consumer project that borrows the repository TypeScript. */
68
+const consumerWith = async (tarball: string) => {
69
+ const directory = await directories.create();
70
+ await writeText(`${directory}/package.json`, JSON.stringify({ private: true, type: 'module' }));
71
+ await exec(directory, 'npm', ['install', '--offline', '--ignore-scripts', '--no-audit', tarball]);
72
+ await symlink(
73
+ await resolvePath('node_modules/typescript'),
74
+ `${directory}/node_modules/typescript`
75
+ );
76
+ await writeText(`${directory}/node_modules/.bin/.keep`, '');
77
+ await symlink('../typescript/bin/tsc', `${directory}/node_modules/.bin/tsc`);
78
+ return directory;
79
+};
80
+
81
+describe('strict npm consumer', () => {
82
+ test('a candidate tarball missing a declared export fails, and the complete tarball passes', async () => {
83
+ const complete = await fixtureTarball(await directories.create(), {
84
+ 'dist/index.js': 'export const value = 1;\n',
85
+ 'dist/index.d.ts': 'export declare const value: number;\n',
86
+ });
87
+ await runRelease(
88
+ checkStrictConsumer(await consumerWith(complete), ['@composio/release-fixture'], [])
89
+ );
90
+
91
+ const missing = await fixtureTarball(await directories.create(), {
92
+ 'dist/index.js': 'export const value = 1;\n',
93
+ });
94
+ await expect(
95
+ runRelease(
96
+ checkStrictConsumer(await consumerWith(missing), ['@composio/release-fixture'], [])
97
+ )
98
+ ).rejects.toThrow('@composio/release-fixture');
99
+ });
100
+});
101
+
102
+describe('candidate core with published providers', () => {
103
+ test('installs the candidate core with each published provider, skips unpublished ones and names the one that fails', async () => {
104
+ const cwd = await directories.create();
105
+ const candidates = await directories.create();
106
+ const work = await directories.create();
107
+ await writeText(`${cwd}/mise.toml`, '[tools]\npython = "3.12.13"\n');
108
+ await writeText(`${cwd}/python/composio/__version__.py`, '__version__ = "1.0.0"\n');
109
+ await writeText(
110
+ `${cwd}/python/pyproject.toml`,
111
+ '[project]\nname = "composio"\nversion = "1.0.0"\n'
112
+ );
113
+ for (const provider of ['openai', 'broken', 'brandnew']) {
114
+ await writeText(
115
+ `${cwd}/python/providers/${provider}/pyproject.toml`,
116
+ `[project]\nname = "composio-${provider}"\nversion = "1.0.0"\n`
117
+ );
118
+ await writeText(`${cwd}/python/providers/${provider}/setup.py`, 'setup(version="1.0.0")\n');
119
+ }
120
+ await writeText(`${candidates}/composio-1.0.0-py3-none-any.whl`, 'wheel');
121
+ await writeText(`${candidates}/composio_openai-1.0.0-py3-none-any.whl`, 'wheel');
122
+ const bin = `${cwd}/fake-bin`;
123
+ const log = `${cwd}/uv.log`;
124
+ await writeText(
125
+ `${bin}/uv`,
126
+ [
127
+ '#!/bin/sh',
128
+ `echo "$@" >> ${log}`,
129
+ 'if [ "$1" = venv ]; then',
130
+ ' mkdir -p "$4/bin"',
131
+ ` printf '#!/bin/sh\\ncase "$0" in *composio-broken*) echo "ImportError: boom" >&2; exit 1;; esac\\n' > "$4/bin/python"`,
132
+ ' chmod +x "$4/bin/python"',
133
+ 'fi',
134
+ ].join('\n')
135
+ );
136
+ await makeExecutable(`${bin}/uv`);
137
+ const previous = process.env.PATH;
138
+ try {
139
+ process.env.PATH = `${bin}:${previous}`;
140
+ await expect(
141
+ runRelease(verifyPublishedProviders(cwd, candidates, '1.0.0', work), async input =>
142
+ String(input).includes('/composio-brandnew/')
143
+ ? new Response('{}', { status: 404 })
144
+ : new Response('{}')
145
+ )
146
+ ).rejects.toThrow('Candidate composio breaks the latest published composio-broken');
147
+ } finally {
148
+ process.env.PATH = previous;
149
+ }
150
+ const installs = (await readText(log))
151
+ .split('\n')
152
+ .filter(line => line.startsWith('pip install'));
153
+ const core = `${candidates}/composio-1.0.0-py3-none-any.whl`;
154
+ expect(installs).toHaveLength(2);
155
+ expect(installs[0]).toContain(core);
156
+ expect(installs[0]).toMatch(/ composio-broken$/);
157
+ expect(installs[1]).toContain(core);
158
+ expect(installs[1]).toMatch(/ composio-openai$/);
159
+ });
160
+});