diff --git a/.changeset/add-tags-to-test-runs.md b/.changeset/add-tags-to-test-runs.md new file mode 100644 index 0000000..39613db --- /dev/null +++ b/.changeset/add-tags-to-test-runs.md @@ -0,0 +1,5 @@ +--- +'@smooai/testing': minor +--- + +Add tags support to test runs. Tags are flexible string arrays (e.g., `['e2e', 'brent-rager']`) for categorizing runs by type and scope. Added `--tags` CLI option to `create`, `report`, and `list` commands. Updated `SmooTestingClient.report()` to accept tags. diff --git a/src/cli/commands/runs/create.ts b/src/cli/commands/runs/create.ts index 449901f..d178cff 100644 --- a/src/cli/commands/runs/create.ts +++ b/src/cli/commands/runs/create.ts @@ -10,6 +10,7 @@ interface CreateOptions { environmentId?: string; deploymentId?: string; tool?: string; + tags?: string; runnerName?: string; runnerUrl?: string; } @@ -24,6 +25,7 @@ export async function runCreate(options: CreateOptions): Promise { if (options.environmentId) body.environmentId = options.environmentId; if (options.deploymentId) body.deploymentId = options.deploymentId; if (options.tool) body.tool = options.tool; + if (options.tags) body.tags = options.tags.split(',').map((t: string) => t.trim()); if (options.runnerName) body.runnerName = options.runnerName; if (options.runnerUrl) body.runnerUrl = options.runnerUrl; diff --git a/src/cli/commands/runs/index.ts b/src/cli/commands/runs/index.ts index 5e92d2b..875b4ad 100644 --- a/src/cli/commands/runs/index.ts +++ b/src/cli/commands/runs/index.ts @@ -10,6 +10,7 @@ export function createRunsCommand(program: Command): Command { .option('--environment-id ', 'Environment ID') .option('--deployment-id ', 'Deployment ID') .option('--tool ', 'Tool name (e.g., vitest, playwright)') + .option('--tags ', 'Comma-separated tags (e.g., e2e,brent-rager)') .option('--runner-name ', 'Runner name') .option('--runner-url ', 'Runner URL') .action(async (opts) => { @@ -22,6 +23,7 @@ export function createRunsCommand(program: Command): Command { .option('--status ', 'Filter by status') .option('--environment-id ', 'Filter by environment ID') .option('--tool ', 'Filter by tool') + .option('--tags ', 'Filter by tags (comma-separated)') .option('--limit ', 'Max results', '50') .option('--offset ', 'Offset', '0') .action(async (opts) => { @@ -53,6 +55,7 @@ export function createRunsCommand(program: Command): Command { .option('--environment ', 'Environment name') .option('--deployment-id ', 'Deployment ID') .option('--tool ', 'Override tool name from CTRF') + .option('--tags ', 'Comma-separated tags (e.g., e2e,brent-rager)') .option('--build-name ', 'Build name (e.g., git SHA)') .option('--build-url ', 'Build URL (e.g., CI run link)') .action(async (ctrfFile, opts) => { diff --git a/src/cli/commands/runs/list.ts b/src/cli/commands/runs/list.ts index cc43306..e89a8cb 100644 --- a/src/cli/commands/runs/list.ts +++ b/src/cli/commands/runs/list.ts @@ -8,6 +8,7 @@ interface ListOptions { status?: string; environmentId?: string; tool?: string; + tags?: string; limit?: string; offset?: string; } @@ -21,6 +22,7 @@ export async function runList(options: ListOptions): Promise { status: options.status, environmentId: options.environmentId, tool: options.tool, + tags: options.tags, limit: options.limit, offset: options.offset, }); diff --git a/src/cli/commands/runs/report.tsx b/src/cli/commands/runs/report.tsx index acfead8..9e62bea 100644 --- a/src/cli/commands/runs/report.tsx +++ b/src/cli/commands/runs/report.tsx @@ -15,6 +15,7 @@ interface ReportOptions { environment?: string; deploymentId?: string; tool?: string; + tags?: string; buildName?: string; buildUrl?: string; } @@ -45,6 +46,7 @@ export async function reportLogic( if (options.environment) runBody.environment = options.environment; if (options.deploymentId) runBody.deploymentId = options.deploymentId; + if (options.tags) runBody.tags = options.tags.split(',').map((t: string) => t.trim()); // Build URL from GitHub Actions context if (options.buildUrl) { @@ -112,6 +114,7 @@ function ReportUI({ ctrfFile, options }: { ctrfFile: string; options: ReportOpti }; if (options.environment) runBody.environment = options.environment; if (options.deploymentId) runBody.deploymentId = options.deploymentId; + if (options.tags) runBody.tags = options.tags.split(',').map((t: string) => t.trim()); if (options.buildUrl) { runBody.buildUrl = options.buildUrl; } else if (process.env.GITHUB_SERVER_URL && process.env.GITHUB_REPOSITORY && process.env.GITHUB_RUN_ID) { diff --git a/src/lib/index.ts b/src/lib/index.ts index 48603ec..305d84a 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -215,6 +215,7 @@ export class SmooTestingClient { environment?: string; deploymentId?: string; tool?: string; + tags?: string[]; buildName?: string; buildUrl?: string; }, @@ -227,6 +228,7 @@ export class SmooTestingClient { environment: options?.environment, deploymentId: options?.deploymentId, tool: options?.tool ?? ctrf.results.tool?.name, + tags: options?.tags, buildName: options?.buildName, buildUrl: options?.buildUrl, }); diff --git a/src/lib/types.ts b/src/lib/types.ts index bf62e6d..da49193 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -31,6 +31,7 @@ export interface TestRun { deploymentId: string | null; name: string; tool: string | null; + tags: string[] | null; status: string; summary: TestRunSummary | null; durationMs: number | null; @@ -51,6 +52,7 @@ export interface CreateTestRunInput { environmentId?: string; deploymentId?: string; tool?: string; + tags?: string[]; buildName?: string; buildUrl?: string; runnerName?: string; @@ -64,6 +66,7 @@ export interface UpdateTestRunInput { completedAt?: string; startedAt?: string; tool?: string; + tags?: string[]; metadata?: Record; } @@ -73,6 +76,7 @@ export interface ListTestRunsFilters { status?: string; environmentId?: string; tool?: string; + tags?: string; runnerName?: string; startDate?: string; endDate?: string;