diff --git a/dist/main/index.js b/dist/main/index.js index 6f9c8d6..2b5f559 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -4052,7 +4052,8 @@ var runAction = function (_a) { log.error("::error ::" + msg); return new Error(msg); }; - if (!(env.GITHUB_EVENT_NAME === 'push')) return [3 /*break*/, 3]; + if (!(env.GITHUB_EVENT_NAME === 'push' || + env.GITHUB_EVENT_NAME === 'schedule')) return [3 /*break*/, 3]; dir = env.FOLDER ? path.join(cwd, env.FOLDER) : cwd; return [4 /*yield*/, libyear_1.runLibyear(dir)]; case 2: diff --git a/src/index.ts b/src/index.ts index 4e77842..3b37895 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,10 @@ export const runAction = async ({ return new Error(msg); }; - if (env.GITHUB_EVENT_NAME === 'push') { + if ( + env.GITHUB_EVENT_NAME === 'push' || + env.GITHUB_EVENT_NAME === 'schedule' + ) { const dir = env.FOLDER ? path.join(cwd, env.FOLDER) : cwd; const report = await runLibyear(dir); diff --git a/test/cron-workflow.spec.ts b/test/cron-workflow.spec.ts new file mode 100644 index 0000000..984900c --- /dev/null +++ b/test/cron-workflow.spec.ts @@ -0,0 +1,41 @@ +import { loadSpec } from './spec'; +import { getResultsTable, getTotals } from '../src/libyear'; + +import { runAction } from './util'; + +describe('cron-workflow', () => { + it('basic-config', async () => { + const run = await runAction({ + eventJson: {}, + eventName: 'schedule', + logToConsole: false, + copySpec: { + spec: '001', + }, + }); + + const spec = await loadSpec('001'); + const specTotals = getTotals(spec); + + // Ensure that table is printed out + expect(run.stdout).toMatch( + `TABLE: ${JSON.stringify(getResultsTable(spec))}` + ); + + // Ensure that variables are set + for (const metric of ['drift', 'pulse'] as const) { + expect(specTotals.get(metric)).toBeTruthy(); + expect(run.stdout).toMatch( + `::set-output name=${metric}::${Number(specTotals.get(metric)).toFixed( + 2 + )}` + ); + } + for (const metric of ['releases', 'major', 'minor', 'patch'] as const) { + expect(specTotals.get(metric)).toBeTruthy(); + expect(run.stdout).toMatch( + `::set-output name=${metric}::${specTotals.get(metric)}` + ); + } + }); +});