diff --git a/packages/grafana-toolkit/README.md b/packages/grafana-toolkit/README.md index aac605e6614..a63160458f2 100644 --- a/packages/grafana-toolkit/README.md +++ b/packages/grafana-toolkit/README.md @@ -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. diff --git a/packages/grafana-toolkit/src/cli/index.ts b/packages/grafana-toolkit/src/cli/index.ts index ec08668a801..5aa698874be 100644 --- a/packages/grafana-toolkit/src/cli/index.ts +++ b/packages/grafana-toolkit/src/cli/index.ts @@ -148,6 +148,8 @@ export const run = (includeInternalScripts = false) => { .command('plugin:build') .option('--maxJestWorkers |', '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, }); }); diff --git a/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts b/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts index 974c1c40ce8..7594bfdf9ab 100644 --- a/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts +++ b/packages/grafana-toolkit/src/cli/tasks/plugin.build.ts @@ -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 = 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 }); };