UNPKG

1.83 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const command_1 = require("@heroku-cli/command");
4const cli_ux_1 = require("cli-ux");
5const pipelines_1 = require("../../utils/pipelines");
6const test_run_1 = require("../../utils/test-run");
7const source_1 = require("../../utils/source");
8const git = require('../../utils/git');
9class CiRun extends command_1.Command {
10 async run() {
11 const { flags } = this.parse(CiRun);
12 const pipeline = await pipelines_1.getPipeline(flags, this);
13 const commit = await git.readCommit('HEAD');
14 cli_ux_1.default.action.start('Preparing source');
15 const sourceBlobUrl = await source_1.createSourceBlob(commit.ref, this);
16 cli_ux_1.default.action.stop();
17 cli_ux_1.default.action.start('Starting test run');
18 const { body: pipelineRepository } = await this.heroku.get(`https://kolkrabbi.heroku.com/pipelines/${pipeline.id}/repository`);
19 const organization = pipelineRepository.organization && pipelineRepository.organization.name;
20 const { body: testRun } = await this.heroku.post('/test-runs', { body: {
21 commit_branch: commit.branch,
22 commit_message: commit.message,
23 commit_sha: commit.ref,
24 pipeline: pipeline.id,
25 organization,
26 source_blob_url: sourceBlobUrl
27 }
28 });
29 cli_ux_1.default.action.stop();
30 await test_run_1.displayAndExit(pipeline, testRun.number, this);
31 }
32}
33CiRun.description = 'run tests against current directory';
34CiRun.examples = [
35 `$ heroku ci:run --app murmuring-headland-14719
36`,
37];
38CiRun.flags = {
39 app: command_1.flags.app({ required: false }),
40 pipeline: command_1.flags.pipeline({ required: false })
41};
42exports.default = CiRun;