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
|
||||
.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')
|
||||
.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)({
|
||||
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)')
|
||||
.description('end-to-end test using bundle in /artifacts')
|
||||
.action(async cmd => {
|
||||
await execTask(ciTestPluginTask)({
|
||||
full: cmd.full,
|
||||
});
|
||||
await execTask(ciTestPluginTask)({});
|
||||
});
|
||||
|
||||
program
|
||||
|
@ -31,13 +31,18 @@ const manifestRunner: TaskRunner<ManifestOptions> = async ({ folder }) => {
|
||||
|
||||
const originalDir = __dirname;
|
||||
process.chdir(folder);
|
||||
const out = await execa('sha1sum', files);
|
||||
const { stdout } = await execa('sha1sum', files);
|
||||
|
||||
// Write the process output
|
||||
fs.writeFileSync(path.join(folder, filename), out.stdout);
|
||||
fs.writeFileSync(path.join(folder, filename), stdout);
|
||||
|
||||
// TODO:
|
||||
// gpg --output doc.sig --sign doc
|
||||
// Call a signing service
|
||||
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
|
||||
process.chdir(originalDir);
|
||||
|
@ -30,8 +30,7 @@ import { promisify } from 'util';
|
||||
const rimraf = promisify(rimrafCallback);
|
||||
|
||||
export interface PluginCIOptions {
|
||||
backend?: boolean;
|
||||
full?: boolean;
|
||||
finish?: boolean;
|
||||
upload?: boolean;
|
||||
}
|
||||
|
||||
@ -46,35 +45,26 @@ 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 ({ backend }) => {
|
||||
const buildPluginRunner: TaskRunner<PluginCIOptions> = async ({ finish }) => {
|
||||
const start = Date.now();
|
||||
const workDir = getJobFolder();
|
||||
|
||||
await rimraf(`${process.cwd()}/dist`);
|
||||
await rimraf(workDir);
|
||||
fs.mkdirSync(workDir);
|
||||
if (finish) {
|
||||
const workDir = getJobFolder();
|
||||
await rimraf(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.`);
|
||||
// Move local folders to the scoped job folder
|
||||
for (const name of ['dist', 'coverage']) {
|
||||
const dir = path.resolve(process.cwd(), name);
|
||||
if (fs.existsSync(dir)) {
|
||||
fs.renameSync(dir, path.resolve(workDir, name));
|
||||
}
|
||||
}
|
||||
|
||||
// Run plugin-ci task
|
||||
execa('make', ['backend-plugin-ci']).stdout!.pipe(process.stdout);
|
||||
writeJobStats(start, workDir);
|
||||
} else {
|
||||
// Do regular build process with coverage
|
||||
await pluginBuildRunner({ coverage: true });
|
||||
}
|
||||
|
||||
// Move local folders to the scoped job folder
|
||||
for (const name of ['dist', 'coverage']) {
|
||||
const dir = path.resolve(process.cwd(), name);
|
||||
if (fs.existsSync(dir)) {
|
||||
fs.renameSync(dir, path.resolve(workDir, name));
|
||||
}
|
||||
}
|
||||
writeJobStats(start, workDir);
|
||||
};
|
||||
|
||||
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
|
||||
*
|
||||
*/
|
||||
const testPluginRunner: TaskRunner<PluginCIOptions> = async ({ full }) => {
|
||||
const testPluginRunner: TaskRunner<PluginCIOptions> = async ({}) => {
|
||||
const start = Date.now();
|
||||
const workDir = getJobFolder();
|
||||
const results: TestResultsInfo = { job, passed: 0, failed: 0, screenshots: [] };
|
||||
|
Loading…
Reference in New Issue
Block a user