1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
11 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
12 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
13 | function verb(n) { return function (v) { return step([n, v]); }; }
|
14 | function step(op) {
|
15 | if (f) throw new TypeError("Generator is already executing.");
|
16 | while (_) try {
|
17 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
18 | if (y = 0, t) op = [op[0] & 2, t.value];
|
19 | switch (op[0]) {
|
20 | case 0: case 1: t = op; break;
|
21 | case 4: _.label++; return { value: op[1], done: false };
|
22 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
23 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
24 | default:
|
25 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
26 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
27 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
28 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
29 | if (t[2]) _.ops.pop();
|
30 | _.trys.pop(); continue;
|
31 | }
|
32 | op = body.call(thisArg, _);
|
33 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
34 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
35 | }
|
36 | };
|
37 | Object.defineProperty(exports, "__esModule", { value: true });
|
38 | var types_1 = require("./types");
|
39 | var headers = { accept: 'application/vnd.github.antiope-preview+json' };
|
40 | function start(_a) {
|
41 | var context = _a.context, owner = _a.owner, repo = _a.repo, sha = _a.sha;
|
42 | return __awaiter(this, void 0, void 0, function () {
|
43 | var id, result, e_1;
|
44 | return __generator(this, function (_b) {
|
45 | switch (_b.label) {
|
46 | case 0:
|
47 | id = owner + "/" + repo + "#" + sha;
|
48 | _b.label = 1;
|
49 | case 1:
|
50 | _b.trys.push([1, 3, , 4]);
|
51 | return [4 , context.github.request({
|
52 | headers: headers,
|
53 | method: 'POST',
|
54 | url: "https://api.github.com/repos/" + owner + "/" + repo + "/check-runs",
|
55 | name: 'graphql-inspector',
|
56 | started_at: new Date().toISOString(),
|
57 | head_sha: sha,
|
58 | status: types_1.CheckStatus.InProgress,
|
59 | })];
|
60 | case 2:
|
61 | result = _b.sent();
|
62 | context.log.info("[check-start] sent - " + id);
|
63 | return [2 , result.data.url];
|
64 | case 3:
|
65 | e_1 = _b.sent();
|
66 | context.log.error("[check-start] failed - " + id);
|
67 | context.log.error(e_1);
|
68 | throw e_1;
|
69 | case 4: return [2 ];
|
70 | }
|
71 | });
|
72 | });
|
73 | }
|
74 | exports.start = start;
|
75 | function annotations(_a) {
|
76 | var context = _a.context, url = _a.url, annotations = _a.annotations, title = _a.title, summary = _a.summary;
|
77 | return __awaiter(this, void 0, void 0, function () {
|
78 | var e_2;
|
79 | return __generator(this, function (_b) {
|
80 | switch (_b.label) {
|
81 | case 0:
|
82 | _b.trys.push([0, 2, , 3]);
|
83 | return [4 , context.github.request({
|
84 | headers: headers,
|
85 | url: url,
|
86 | method: 'PATCH',
|
87 | output: {
|
88 | annotations: annotations,
|
89 | title: title,
|
90 | summary: summary,
|
91 | },
|
92 | })];
|
93 | case 1:
|
94 | _b.sent();
|
95 | context.log.info("[check-annotations] sent (" + annotations.length + ")");
|
96 | return [3 , 3];
|
97 | case 2:
|
98 | e_2 = _b.sent();
|
99 | context.log.error("[check-annotations] failed");
|
100 | context.log.error(e_2);
|
101 | throw e_2;
|
102 | case 3: return [2 ];
|
103 | }
|
104 | });
|
105 | });
|
106 | }
|
107 | exports.annotations = annotations;
|
108 | function complete(_a) {
|
109 | var context = _a.context, url = _a.url, conclusion = _a.conclusion;
|
110 | return __awaiter(this, void 0, void 0, function () {
|
111 | var e_3;
|
112 | return __generator(this, function (_b) {
|
113 | switch (_b.label) {
|
114 | case 0:
|
115 | _b.trys.push([0, 2, , 3]);
|
116 | return [4 , context.github.request({
|
117 | headers: headers,
|
118 | url: url,
|
119 | conclusion: conclusion,
|
120 | method: 'PATCH',
|
121 | completed_at: new Date().toISOString(),
|
122 | status: types_1.CheckStatus.Completed,
|
123 | })];
|
124 | case 1:
|
125 | _b.sent();
|
126 | context.log.info("[check-complete] sent");
|
127 | return [3 , 3];
|
128 | case 2:
|
129 | e_3 = _b.sent();
|
130 | context.log.error("[check-complete] failed");
|
131 | context.log.error(e_3);
|
132 | throw e_3;
|
133 | case 3: return [2 ];
|
134 | }
|
135 | });
|
136 | });
|
137 | }
|
138 | exports.complete = complete;
|
139 |
|
\ | No newline at end of file |