Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: store extra metadata for each sandbox test #20365

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions code/lib/cli/src/repro-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export type Template = {
renderer: string;
builder: string;
};

expectedFailures?: Array<{
feature: string;
issues: string[];
}>;

unsupportedFeatures?: Array<{
feature: string;
issues: string[];
}>;
/**
* Some sandboxes might not work properly in specific tasks temporarily, but we might
* still want to run the other tasks. Set the ones to skip in this property.
Expand All @@ -33,7 +43,7 @@ export type Template = {
inDevelopment?: boolean;
};

export const allTemplates: Record<string, Template> = {
export const allTemplates = {
'cra/default-js': {
name: 'Create React App (Javascript)',
script: 'npx create-react-app .',
Expand Down Expand Up @@ -321,7 +331,7 @@ export const allTemplates: Record<string, Template> = {
builder: '@storybook/builder-webpack5',
},
},
};
} satisfies Record<string, Template>;

export const ci: TemplateKey[] = ['cra/default-ts', 'react-vite/default-ts'];
export const pr: TemplateKey[] = [
Expand Down
13 changes: 11 additions & 2 deletions scripts/task.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable no-await-in-loop */
import type { TestCase } from 'junit-xml';
import { getJunitXml } from 'junit-xml';
import { outputFile, readFile, pathExists } from 'fs-extra';
import { join, resolve } from 'path';
import { prompt } from 'prompts';
import boxen from 'boxen';
import { dedent } from 'ts-dedent';

import type { OptionValues } from './utils/options';
Expand All @@ -29,6 +29,8 @@ import {
type Template,
} from '../code/lib/cli/src/repro-templates';

import { version } from '../code/package.json';

const sandboxDir = process.env.SANDBOX_ROOT || resolve(__dirname, '../sandbox');
const codeDir = resolve(__dirname, '../code');
const junitDir = resolve(__dirname, '../test-results');
Expand Down Expand Up @@ -192,7 +194,14 @@ async function writeJunitXml(
const name = `${taskKey} - ${templateKey}`;
const time = (Date.now() - +startTime) / 1000;
const testCase = { name, assertions: 1, time, ...errorData };
const suite = { name, timestamp: startTime, time, testCases: [testCase] };
// We store the metadata as a system-err.
// Which is a bit unfortunate but it seems that one can't store extra data when the task is successful.
// system-err won't turn the whole test suite as failing, which makes it a reasonable candidate
const metadata: TestCase = {
name: `${name} - metadata`,
systemErr: [JSON.stringify({ ...TEMPLATES[templateKey], id: templateKey, version })],
};
const suite = { name, timestamp: startTime, time, testCases: [testCase, metadata] };
const junitXml = getJunitXml({ time, name, suites: [suite] });
const path = getJunitFilename(taskKey);
await outputFile(path, junitXml);
Expand Down