Skip to content

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

test(docs): validate workflow YAML shape

jkomyno8ff9e73b2b78
diff --git a/docs/tests/static/docs-data-workflow.test.ts b/docs/tests/static/docs-data-workflow.test.ts
index ba19ff317..1734daeef 100644
--- a/docs/tests/static/docs-data-workflow.test.ts
+++ b/docs/tests/static/docs-data-workflow.test.ts
@@ -1,25 +1,43 @@
import { describe, expect, test } from 'bun:test';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
+import { z } from 'zod';
const workflowPath = resolve(process.cwd(), '..', '.github', 'workflows', 'docs-update-data.yml');
-interface WorkflowStep {
- name?: string;
- id?: string;
- uses?: string;
- if?: string;
- 'continue-on-error'?: boolean;
- 'working-directory'?: string;
- env?: Record<string, unknown>;
- with?: Record<string, unknown>;
- run?: string;
-}
+const workflowStepSchema = z
+ .object({
+ name: z.string().optional(),
+ id: z.string().optional(),
+ uses: z.string().optional(),
+ if: z.string().optional(),
+ 'continue-on-error': z.boolean().optional(),
+ 'working-directory': z.string().optional(),
+ env: z.record(z.string(), z.unknown()).optional(),
+ with: z.record(z.string(), z.unknown()).optional(),
+ run: z.string().optional(),
+ })
+ .passthrough();
+
+const workflowSchema = z
+ .object({
+ jobs: z
+ .record(
+ z.string(),
+ z
+ .object({
+ steps: z.array(workflowStepSchema).optional(),
+ })
+ .passthrough()
+ )
+ .optional(),
+ })
+ .passthrough();
+
+type WorkflowStep = z.infer<typeof workflowStepSchema>;
function workflowSteps(path: string, job: string): WorkflowStep[] {
- const workflow = Bun.YAML.parse(readFileSync(path, 'utf8')) as {
- jobs?: Record<string, { steps?: WorkflowStep[] }>;
- };
+ const workflow = workflowSchema.parse(Bun.YAML.parse(readFileSync(path, 'utf8')));
return workflow.jobs?.[job]?.steps ?? [];
}