Skip to content

Commit 2ed0480

Browse files
committed
Improve check to use test env
1 parent 9e423be commit 2ed0480

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

integrations/intercom-conversations/gitbook-manifest.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ secrets:
1919
CLIENT_SECRET: ${{ env.INTERCOM_CLIENT_SECRET }}
2020
target: organization
2121
envs:
22+
test:
23+
secrets:
24+
CLIENT_ID: '<CLIENT_ID>'
25+
CLIENT_SECRET: '<CLIENT_SECRET>'
2226
dev-samy:
2327
organization: 27dLEczo4lLcYIQhRuxg
2428
secrets:

integrations/zendesk-conversations/gitbook-manifest.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ secrets:
1919
CLIENT_SECRET: ${{ env.ZENDESK_CLIENT_SECRET }}
2020
target: organization
2121
envs:
22+
test:
23+
secrets:
24+
CLIENT_ID: '<CLIENT_ID>'
25+
CLIENT_SECRET: '<CLIENT_SECRET>'
2226
dev-samy:
2327
organization: 27dLEczo4lLcYIQhRuxg
2428
secrets:

packages/cli/src/check.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { Miniflare } from 'miniflare';
22

33
import { buildScriptFromManifest } from './build';
4-
import { getDefaultManifestPath, resolveIntegrationManifestPath } from './manifest';
54
import { getMiniflareOptions } from './dev';
5+
import { withEnvironment } from './environments';
66

77
/**
88
* Check that an integration can build correctly without publishing it.
99
*/
10-
export async function checkIntegrationBuild() {
11-
const manifestSpecPath = await resolveIntegrationManifestPath(getDefaultManifestPath());
12-
const { path: scriptPath } = await buildScriptFromManifest(manifestSpecPath, {
13-
mode: 'development',
14-
});
10+
export async function checkIntegrationBuild(manifestSpecPath: string) {
11+
// We use a special env "test" to make it easy to configure the integration for testing.
12+
return withEnvironment('test', async () => {
13+
const { path: scriptPath } = await buildScriptFromManifest(manifestSpecPath, {
14+
mode: 'development',
15+
});
1516

16-
const mf = new Miniflare(getMiniflareOptions(scriptPath));
17-
await mf.ready;
17+
const mf = new Miniflare(getMiniflareOptions(scriptPath));
18+
await mf.ready;
1819

19-
await mf.dispose();
20+
await mf.dispose();
21+
});
2022
}

packages/cli/src/cli.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ program
142142

143143
program
144144
.command('check')
145+
.argument('[file]', 'integration definition file', DEFAULT_MANIFEST_FILE)
145146
.description('check the integration build')
146-
.option('--env <env>', 'environment to use')
147-
.action(async (options) => {
148-
return withEnvironment(options.env, async () => {
149-
await checkIntegrationBuild();
150-
});
147+
.action(async (filePath) => {
148+
await checkIntegrationBuild(
149+
await resolveIntegrationManifestPath(path.resolve(process.cwd(), filePath)),
150+
);
151151
});
152152

153153
const openAPIProgram = program.command('openapi').description('manage OpenAPI specifications');

packages/cli/src/manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const IntegrationManifestSchema = z
121121
)
122122
.optional(),
123123
contentSecurityPolicy: z.union([z.string(), z.record(z.string(), z.string())]).optional(),
124-
envs: z.record(IntegrationManifestEnvironmentSchema).optional(),
124+
envs: z.record(z.object(IntegrationManifestEnvironmentSchema.shape).partial()).optional(),
125125
})
126126
.merge(IntegrationManifestEnvironmentSchema);
127127

0 commit comments

Comments
 (0)