mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Toolkit: plugin ci needs to cooperate better with make/mage (#22588)
* cleanup * cleanup
This commit is contained in:
parent
0f8cfca4e6
commit
e688f13535
@ -168,15 +168,11 @@ export const run = (includeInternalScripts = false) => {
|
|||||||
|
|
||||||
program
|
program
|
||||||
.command('plugin:ci-build')
|
.command('plugin:ci-build')
|
||||||
.option('--backend', 'Run Makefile for backend task', false)
|
.option('--finish', 'move all results to the jobs folder', false)
|
||||||
.description('Build the plugin, leaving results in /dist and /coverage')
|
.description('Build the plugin, leaving results in /dist and /coverage')
|
||||||
.action(async cmd => {
|
.action(async cmd => {
|
||||||
if (typeof cmd === 'string') {
|
|
||||||
console.error(`Invalid argument: ${cmd}\nSee --help for a list of available commands.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
await execTask(ciBuildPluginTask)({
|
await execTask(ciBuildPluginTask)({
|
||||||
backend: cmd.backend,
|
finish: cmd.finish,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -199,9 +195,7 @@ export const run = (includeInternalScripts = false) => {
|
|||||||
.option('--full', 'run all the tests (even stuff that will break)')
|
.option('--full', 'run all the tests (even stuff that will break)')
|
||||||
.description('end-to-end test using bundle in /artifacts')
|
.description('end-to-end test using bundle in /artifacts')
|
||||||
.action(async cmd => {
|
.action(async cmd => {
|
||||||
await execTask(ciTestPluginTask)({
|
await execTask(ciTestPluginTask)({});
|
||||||
full: cmd.full,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
|
@ -31,13 +31,18 @@ const manifestRunner: TaskRunner<ManifestOptions> = async ({ folder }) => {
|
|||||||
|
|
||||||
const originalDir = __dirname;
|
const originalDir = __dirname;
|
||||||
process.chdir(folder);
|
process.chdir(folder);
|
||||||
const out = await execa('sha1sum', files);
|
const { stdout } = await execa('sha1sum', files);
|
||||||
|
|
||||||
// Write the process output
|
// Write the process output
|
||||||
fs.writeFileSync(path.join(folder, filename), out.stdout);
|
fs.writeFileSync(path.join(folder, filename), stdout);
|
||||||
|
|
||||||
// TODO:
|
// Call a signing service
|
||||||
// gpg --output doc.sig --sign doc
|
const GRAFANA_API_KEY = process.env.GRAFANA_API_KEY;
|
||||||
|
if (GRAFANA_API_KEY) {
|
||||||
|
const plugin = require('plugin.json');
|
||||||
|
const url = `https://grafana.com/api/plugins/${plugin.id}/sign`;
|
||||||
|
console.log(`TODO: sign and save: ${url}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Go back to where you were
|
// Go back to where you were
|
||||||
process.chdir(originalDir);
|
process.chdir(originalDir);
|
||||||
|
@ -30,8 +30,7 @@ import { promisify } from 'util';
|
|||||||
const rimraf = promisify(rimrafCallback);
|
const rimraf = promisify(rimrafCallback);
|
||||||
|
|
||||||
export interface PluginCIOptions {
|
export interface PluginCIOptions {
|
||||||
backend?: boolean;
|
finish?: boolean;
|
||||||
full?: boolean;
|
|
||||||
upload?: boolean;
|
upload?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,27 +45,14 @@ export interface PluginCIOptions {
|
|||||||
* Anything that should be put into the final zip file should be put in:
|
* Anything that should be put into the final zip file should be put in:
|
||||||
* ~/ci/jobs/build_xxx/dist
|
* ~/ci/jobs/build_xxx/dist
|
||||||
*/
|
*/
|
||||||
const buildPluginRunner: TaskRunner<PluginCIOptions> = async ({ backend }) => {
|
const buildPluginRunner: TaskRunner<PluginCIOptions> = async ({ finish }) => {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
const workDir = getJobFolder();
|
|
||||||
|
|
||||||
await rimraf(`${process.cwd()}/dist`);
|
if (finish) {
|
||||||
|
const workDir = getJobFolder();
|
||||||
await rimraf(workDir);
|
await rimraf(workDir);
|
||||||
fs.mkdirSync(workDir);
|
fs.mkdirSync(workDir);
|
||||||
|
|
||||||
if (backend) {
|
|
||||||
const makefile = path.resolve(process.cwd(), 'Makefile');
|
|
||||||
if (!fs.existsSync(makefile)) {
|
|
||||||
throw new Error(`Missing: ${makefile}. A Makefile is required for backend plugins.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run plugin-ci task
|
|
||||||
execa('make', ['backend-plugin-ci']).stdout!.pipe(process.stdout);
|
|
||||||
} else {
|
|
||||||
// Do regular build process with coverage
|
|
||||||
await pluginBuildRunner({ coverage: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move local folders to the scoped job folder
|
// Move local folders to the scoped job folder
|
||||||
for (const name of ['dist', 'coverage']) {
|
for (const name of ['dist', 'coverage']) {
|
||||||
const dir = path.resolve(process.cwd(), name);
|
const dir = path.resolve(process.cwd(), name);
|
||||||
@ -75,6 +61,10 @@ const buildPluginRunner: TaskRunner<PluginCIOptions> = async ({ backend }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeJobStats(start, workDir);
|
writeJobStats(start, workDir);
|
||||||
|
} else {
|
||||||
|
// Do regular build process with coverage
|
||||||
|
await pluginBuildRunner({ coverage: true });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ciBuildPluginTask = new Task<PluginCIOptions>('Build Plugin', buildPluginRunner);
|
export const ciBuildPluginTask = new Task<PluginCIOptions>('Build Plugin', buildPluginRunner);
|
||||||
@ -239,7 +229,7 @@ export const ciPackagePluginTask = new Task<PluginCIOptions>('Bundle Plugin', pa
|
|||||||
* deploy the zip to a running grafana instance
|
* deploy the zip to a running grafana instance
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const testPluginRunner: TaskRunner<PluginCIOptions> = async ({ full }) => {
|
const testPluginRunner: TaskRunner<PluginCIOptions> = async ({}) => {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
const workDir = getJobFolder();
|
const workDir = getJobFolder();
|
||||||
const results: TestResultsInfo = { job, passed: 0, failed: 0, screenshots: [] };
|
const results: TestResultsInfo = { job, passed: 0, failed: 0, screenshots: [] };
|
||||||
|
Loading…
Reference in New Issue
Block a user