CLI: Add option to skip tests and linting for grafana-toolkit plugin:build (#35068)
* Add option to skip tests and linting for plugin:build Our plugin has a separate step of CI that tests and lints, so we'd like to be able to control whether the build step will run it too. defaults to continuing with lint and tests. update README for grafana-toolkit * remove accidental duplicate documentation of coverage
This commit is contained in:
@@ -104,6 +104,8 @@ This command creates a production-ready build of your plugin.
|
||||
|
||||
Available options:
|
||||
|
||||
- `--skipTest` - Skip running tests as part of build. Useful if you're running the build as part of a larger pipeline.
|
||||
- `--skipLint` - Skip linting as part of build. Useful if you're running the build as part of a larger pipeline.
|
||||
- `--coverage` - Reports code coverage after the test step of the build.
|
||||
- `--preserveConsole` - Preserves console statements in the code.
|
||||
|
||||
|
||||
@@ -148,6 +148,8 @@ export const run = (includeInternalScripts = false) => {
|
||||
.command('plugin:build')
|
||||
.option('--maxJestWorkers <num>|<string>', 'Limit number of Jest workers spawned')
|
||||
.option('--coverage', 'Run code coverage', false)
|
||||
.option('--skipTest', 'Skip running tests (for pipelines that run it separate)', false)
|
||||
.option('--skipLint', 'Skip running lint (for pipelines that run it separate)', false)
|
||||
.option('--preserveConsole', 'Preserves console calls', false)
|
||||
.description('Prepares plugin dist package')
|
||||
.action(async (cmd) => {
|
||||
@@ -156,6 +158,8 @@ export const run = (includeInternalScripts = false) => {
|
||||
silent: true,
|
||||
maxJestWorkers: cmd.maxJestWorkers,
|
||||
preserveConsole: cmd.preserveConsole,
|
||||
skipLint: cmd.skipLint,
|
||||
skipTest: cmd.skipTest,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ interface PluginBuildOptions {
|
||||
coverage: boolean;
|
||||
maxJestWorkers?: string;
|
||||
preserveConsole?: boolean;
|
||||
skipTest?: boolean;
|
||||
skipLint?: boolean;
|
||||
}
|
||||
|
||||
interface Fixable {
|
||||
@@ -132,11 +134,17 @@ export const pluginBuildRunner: TaskRunner<PluginBuildOptions> = async ({
|
||||
coverage,
|
||||
maxJestWorkers,
|
||||
preserveConsole,
|
||||
skipTest,
|
||||
skipLint,
|
||||
}) => {
|
||||
await versions();
|
||||
await prepare();
|
||||
await lintPlugin({ fix: false });
|
||||
await testPlugin({ updateSnapshot: false, coverage, maxWorkers: maxJestWorkers, watch: false });
|
||||
if (!skipLint) {
|
||||
await lintPlugin({ fix: false });
|
||||
}
|
||||
if (!skipTest) {
|
||||
await testPlugin({ updateSnapshot: false, coverage, maxWorkers: maxJestWorkers, watch: false });
|
||||
}
|
||||
await bundlePlugin({ watch: false, production: true, preserveConsole });
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user