1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const command_1 = require("@heroku-cli/command");
|
4 | const cli_ux_1 = require("cli-ux");
|
5 | const pipelines_1 = require("../../utils/pipelines");
|
6 | const test_run_1 = require("../../utils/test-run");
|
7 | const source_1 = require("../../utils/source");
|
8 | const git = require('../../utils/git');
|
9 | class 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 | }
|
33 | CiRun.description = 'run tests against current directory';
|
34 | CiRun.examples = [
|
35 | `$ heroku ci:run --app murmuring-headland-14719
|
36 | `,
|
37 | ];
|
38 | CiRun.flags = {
|
39 | app: command_1.flags.app({ required: false }),
|
40 | pipeline: command_1.flags.pipeline({ required: false })
|
41 | };
|
42 | exports.default = CiRun;
|