Store extra sandbox metadata for status page

This commit is contained in:
Kasper Peulen 2022-12-21 13:08:34 +01:00
parent c2f424f702
commit 0fbf0adca6
2 changed files with 23 additions and 4 deletions

View File

@ -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.
@ -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 .',
@ -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[] = [

View File

@ -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';
@ -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');
@ -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);