mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
toolkit: expose maxWorkers option for plugin build & test tasks (#27724)
This commit is contained in:
parent
22b2d4d412
commit
bd9add72de
@ -93,6 +93,7 @@ Available options:
|
||||
- `-u`, `--updateSnapshot` - Performs snapshots update.
|
||||
- `--testNamePattern=<regex>` - Runs test with names that match provided regex (https://jestjs.io/docs/en/cli#testnamepattern-regex).
|
||||
- `--testPathPattern=<regex>` - Runs test with paths that match provided regex (https://jestjs.io/docs/en/cli#testpathpattern-regex).
|
||||
- `--maxWorkers=<num>|<string>` - Limit number of Jest workers spawned (https://jestjs.io/docs/en/cli#--maxworkersnumstring)
|
||||
|
||||
### Build your plugin
|
||||
|
||||
|
@ -138,10 +138,11 @@ export const run = (includeInternalScripts = false) => {
|
||||
|
||||
program
|
||||
.command('plugin:build')
|
||||
.option('--maxJestWorkers <num>|<string>', 'Limit number of Jest workers spawned')
|
||||
.description('Prepares plugin dist package')
|
||||
.option('--coverage', 'Run code coverage', false)
|
||||
.action(async cmd => {
|
||||
await execTask(pluginBuildTask)({ coverage: cmd.coverage, silent: true });
|
||||
await execTask(pluginBuildTask)({ coverage: cmd.coverage, silent: true, maxJestWorkers: cmd.maxJestWorkers });
|
||||
});
|
||||
|
||||
program
|
||||
@ -164,6 +165,7 @@ export const run = (includeInternalScripts = false) => {
|
||||
.option('--watch', 'Run tests in interactive watch mode')
|
||||
.option('--testPathPattern <regex>', 'Run only tests with a path that matches the regex')
|
||||
.option('--testNamePattern <regex>', 'Run only tests with a name that matches the regex')
|
||||
.option('--maxWorkers <num>|<string>', 'Limit number of workers spawned')
|
||||
.description('Executes plugin tests')
|
||||
.action(async cmd => {
|
||||
await execTask(pluginTestTask)({
|
||||
@ -172,6 +174,7 @@ export const run = (includeInternalScripts = false) => {
|
||||
watch: !!cmd.watch,
|
||||
testPathPattern: cmd.testPathPattern,
|
||||
testNamePattern: cmd.testNamePattern,
|
||||
maxWorkers: cmd.maxWorkers,
|
||||
silent: true,
|
||||
});
|
||||
});
|
||||
@ -179,10 +182,12 @@ export const run = (includeInternalScripts = false) => {
|
||||
program
|
||||
.command('plugin:ci-build')
|
||||
.option('--finish', 'move all results to the jobs folder', false)
|
||||
.option('--maxJestWorkers <num>|<string>', 'Limit number of Jest workers spawned')
|
||||
.description('Build the plugin, leaving results in /dist and /coverage')
|
||||
.action(async cmd => {
|
||||
await execTask(ciBuildPluginTask)({
|
||||
finish: cmd.finish,
|
||||
maxJestWorkers: cmd.maxJestWorkers,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -16,6 +16,7 @@ const rimraf = promisify(rimrafCallback);
|
||||
|
||||
interface PluginBuildOptions {
|
||||
coverage: boolean;
|
||||
maxJestWorkers?: string;
|
||||
}
|
||||
|
||||
interface Fixable {
|
||||
@ -111,10 +112,10 @@ export const lintPlugin = ({ fix }: Fixable = {}) =>
|
||||
}
|
||||
});
|
||||
|
||||
export const pluginBuildRunner: TaskRunner<PluginBuildOptions> = async ({ coverage }) => {
|
||||
export const pluginBuildRunner: TaskRunner<PluginBuildOptions> = async ({ coverage, maxJestWorkers }) => {
|
||||
await prepare();
|
||||
await lintPlugin({ fix: false });
|
||||
await testPlugin({ updateSnapshot: false, coverage, watch: false });
|
||||
await testPlugin({ updateSnapshot: false, coverage, maxWorkers: maxJestWorkers, watch: false });
|
||||
await bundlePlugin({ watch: false, production: true });
|
||||
};
|
||||
|
||||
|
@ -27,6 +27,7 @@ export interface PluginCIOptions {
|
||||
finish?: boolean;
|
||||
upload?: boolean;
|
||||
signingAdmin?: boolean;
|
||||
maxJestWorkers?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +41,7 @@ export interface PluginCIOptions {
|
||||
* Anything that should be put into the final zip file should be put in:
|
||||
* ~/ci/jobs/build_xxx/dist
|
||||
*/
|
||||
const buildPluginRunner: TaskRunner<PluginCIOptions> = async ({ finish }) => {
|
||||
const buildPluginRunner: TaskRunner<PluginCIOptions> = async ({ finish, maxJestWorkers }) => {
|
||||
const start = Date.now();
|
||||
|
||||
if (finish) {
|
||||
@ -58,7 +59,7 @@ const buildPluginRunner: TaskRunner<PluginCIOptions> = async ({ finish }) => {
|
||||
writeJobStats(start, workDir);
|
||||
} else {
|
||||
// Do regular build process with coverage
|
||||
await pluginBuildRunner({ coverage: true });
|
||||
await pluginBuildRunner({ coverage: true, maxJestWorkers });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -8,9 +8,17 @@ export interface PluginTestOptions {
|
||||
watch: boolean;
|
||||
testPathPattern?: string;
|
||||
testNamePattern?: string;
|
||||
maxWorkers?: string;
|
||||
}
|
||||
|
||||
export const testPlugin = ({ updateSnapshot, coverage, watch, testPathPattern, testNamePattern }: PluginTestOptions) =>
|
||||
export const testPlugin = ({
|
||||
updateSnapshot,
|
||||
coverage,
|
||||
watch,
|
||||
testPathPattern,
|
||||
testNamePattern,
|
||||
maxWorkers,
|
||||
}: PluginTestOptions) =>
|
||||
useSpinner('Running tests', async () => {
|
||||
const testConfig = loadJestPluginConfig();
|
||||
|
||||
@ -22,6 +30,7 @@ export const testPlugin = ({ updateSnapshot, coverage, watch, testPathPattern, t
|
||||
testPathPattern: testPathPattern ? [testPathPattern] : [],
|
||||
testNamePattern: testNamePattern ? [testNamePattern] : [],
|
||||
passWithNoTests: true,
|
||||
maxWorkers,
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
|
Loading…
Reference in New Issue
Block a user