gitlab-radiator 3.3.11 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,3 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
1
  /**
8
2
  * @license
9
3
  * Lodash <https://lodash.com/>
@@ -13,8 +7,9 @@ object-assign
13
7
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
14
8
  */
15
9
 
16
- /** @license React v0.20.2
17
- * scheduler.production.min.js
10
+ /**
11
+ * @license React
12
+ * react-dom.production.min.js
18
13
  *
19
14
  * Copyright (c) Facebook, Inc. and its affiliates.
20
15
  *
@@ -22,8 +17,9 @@ object-assign
22
17
  * LICENSE file in the root directory of this source tree.
23
18
  */
24
19
 
25
- /** @license React v17.0.2
26
- * react-dom.production.min.js
20
+ /**
21
+ * @license React
22
+ * react.production.min.js
27
23
  *
28
24
  * Copyright (c) Facebook, Inc. and its affiliates.
29
25
  *
@@ -31,8 +27,9 @@ object-assign
31
27
  * LICENSE file in the root directory of this source tree.
32
28
  */
33
29
 
34
- /** @license React v17.0.2
35
- * react.production.min.js
30
+ /**
31
+ * @license React
32
+ * scheduler.production.min.js
36
33
  *
37
34
  * Copyright (c) Facebook, Inc. and its affiliates.
38
35
  *
@@ -23,45 +23,77 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
23
23
 
24
24
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
25
 
26
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
27
+
28
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
29
+
30
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
31
+
26
32
  function fetchLatestPipelines(_x, _x2) {
27
33
  return _fetchLatestPipelines.apply(this, arguments);
28
- }
34
+ } // eslint-disable-next-line max-statements
35
+
29
36
 
30
37
  function _fetchLatestPipelines() {
31
- _fetchLatestPipelines = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(projectId, gitlab) {
32
- var pipelines, jobsForPipelines;
33
- return _regenerator.default.wrap(function _callee$(_context) {
38
+ _fetchLatestPipelines = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(projectId, gitlab) {
39
+ var pipelines;
40
+ return _regenerator.default.wrap(function _callee2$(_context2) {
34
41
  while (1) {
35
- switch (_context.prev = _context.next) {
42
+ switch (_context2.prev = _context2.next) {
36
43
  case 0:
37
- _context.next = 2;
44
+ _context2.next = 2;
38
45
  return fetchLatestAndMasterPipeline(projectId, gitlab);
39
46
 
40
47
  case 2:
41
- pipelines = _context.sent;
42
- _context.next = 5;
43
- return fetchJobsForPipelines(projectId, pipelines, gitlab);
44
-
45
- case 5:
46
- jobsForPipelines = _context.sent;
47
- return _context.abrupt("return", pipelines.map(_ref3 => {
48
- var id = _ref3.id,
49
- ref = _ref3.ref,
50
- status = _ref3.status;
51
- var jobs = matchJobs(id, jobsForPipelines);
52
- return _objectSpread({
53
- id,
54
- ref,
55
- status
56
- }, jobs);
57
- }));
58
-
59
- case 7:
48
+ pipelines = _context2.sent;
49
+ return _context2.abrupt("return", Promise.all(pipelines.map( /*#__PURE__*/function () {
50
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
51
+ var id, ref, status, _yield$fetchJobs, commit, stages, downstreamStages;
52
+
53
+ return _regenerator.default.wrap(function _callee$(_context) {
54
+ while (1) {
55
+ switch (_context.prev = _context.next) {
56
+ case 0:
57
+ id = _ref.id, ref = _ref.ref, status = _ref.status;
58
+ _context.next = 3;
59
+ return fetchJobs(projectId, id, gitlab);
60
+
61
+ case 3:
62
+ _yield$fetchJobs = _context.sent;
63
+ commit = _yield$fetchJobs.commit;
64
+ stages = _yield$fetchJobs.stages;
65
+ _context.next = 8;
66
+ return fetchDownstreamJobs(projectId, id, gitlab);
67
+
68
+ case 8:
69
+ downstreamStages = _context.sent;
70
+ return _context.abrupt("return", {
71
+ id,
72
+ ref,
73
+ status,
74
+ commit,
75
+ stages: stages.concat(downstreamStages)
76
+ });
77
+
78
+ case 10:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }
83
+ }, _callee);
84
+ }));
85
+
86
+ return function (_x14) {
87
+ return _ref2.apply(this, arguments);
88
+ };
89
+ }())));
90
+
91
+ case 4:
60
92
  case "end":
61
- return _context.stop();
93
+ return _context2.stop();
62
94
  }
63
95
  }
64
- }, _callee);
96
+ }, _callee2);
65
97
  }));
66
98
  return _fetchLatestPipelines.apply(this, arguments);
67
99
  }
@@ -71,183 +103,255 @@ function fetchLatestAndMasterPipeline(_x3, _x4) {
71
103
  }
72
104
 
73
105
  function _fetchLatestAndMasterPipeline() {
74
- _fetchLatestAndMasterPipeline = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(projectId, config) {
75
- var _yield$fetchNonSkippe, _yield$fetchNonSkippe2, latestPipeline, _yield$fetchNonSkippe3, _yield$fetchNonSkippe4, latestMasterPipeline;
76
-
77
- return _regenerator.default.wrap(function _callee2$(_context2) {
106
+ _fetchLatestAndMasterPipeline = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(projectId, config) {
107
+ var pipelines, latestPipeline, latestMasterPipeline, masterPipelines;
108
+ return _regenerator.default.wrap(function _callee3$(_context3) {
78
109
  while (1) {
79
- switch (_context2.prev = _context2.next) {
110
+ switch (_context3.prev = _context3.next) {
80
111
  case 0:
81
- _context2.next = 2;
82
- return fetchNonSkippedPipelines(projectId, config, {
112
+ _context3.next = 2;
113
+ return fetchPipelines(projectId, config, {
83
114
  per_page: 100
84
115
  });
85
116
 
86
117
  case 2:
87
- _yield$fetchNonSkippe = _context2.sent;
88
- _yield$fetchNonSkippe2 = (0, _slicedToArray2.default)(_yield$fetchNonSkippe, 1);
89
- latestPipeline = _yield$fetchNonSkippe2[0];
118
+ pipelines = _context3.sent;
90
119
 
91
- if (latestPipeline) {
92
- _context2.next = 7;
120
+ if (!(pipelines.length === 0)) {
121
+ _context3.next = 5;
93
122
  break;
94
123
  }
95
124
 
96
- return _context2.abrupt("return", []);
125
+ return _context3.abrupt("return", []);
126
+
127
+ case 5:
128
+ latestPipeline = _lodash.default.take(pipelines, 1);
97
129
 
98
- case 7:
99
- if (!(latestPipeline.ref === 'master')) {
100
- _context2.next = 9;
130
+ if (!(latestPipeline[0].ref === 'master')) {
131
+ _context3.next = 8;
101
132
  break;
102
133
  }
103
134
 
104
- return _context2.abrupt("return", [latestPipeline]);
135
+ return _context3.abrupt("return", latestPipeline);
105
136
 
106
- case 9:
107
- _context2.next = 11;
108
- return fetchNonSkippedPipelines(projectId, config, {
137
+ case 8:
138
+ latestMasterPipeline = (0, _lodash.default)(pipelines).filter({
139
+ ref: 'master'
140
+ }).take(1).value();
141
+
142
+ if (!(latestMasterPipeline.length > 0)) {
143
+ _context3.next = 11;
144
+ break;
145
+ }
146
+
147
+ return _context3.abrupt("return", latestPipeline.concat(latestMasterPipeline));
148
+
149
+ case 11:
150
+ _context3.next = 13;
151
+ return fetchPipelines(projectId, config, {
109
152
  per_page: 50,
110
153
  ref: 'master'
111
154
  });
112
155
 
113
- case 11:
114
- _yield$fetchNonSkippe3 = _context2.sent;
115
- _yield$fetchNonSkippe4 = (0, _slicedToArray2.default)(_yield$fetchNonSkippe3, 1);
116
- latestMasterPipeline = _yield$fetchNonSkippe4[0];
117
- return _context2.abrupt("return", [latestPipeline].concat(latestMasterPipeline || []));
156
+ case 13:
157
+ masterPipelines = _context3.sent;
158
+ return _context3.abrupt("return", latestPipeline.concat(_lodash.default.take(masterPipelines, 1)));
118
159
 
119
160
  case 15:
120
161
  case "end":
121
- return _context2.stop();
162
+ return _context3.stop();
122
163
  }
123
164
  }
124
- }, _callee2);
165
+ }, _callee3);
125
166
  }));
126
167
  return _fetchLatestAndMasterPipeline.apply(this, arguments);
127
168
  }
128
169
 
129
- function fetchNonSkippedPipelines(_x5, _x6, _x7) {
130
- return _fetchNonSkippedPipelines.apply(this, arguments);
131
- } // GitLab API endpoint `/projects/${projectId}/pipelines/${pipelineId}/jobs` is broken and not returning all jobs
132
- // Need to fetch all jobs for the project (from newer to older) and match later
133
-
170
+ function fetchPipelines(_x5, _x6, _x7) {
171
+ return _fetchPipelines.apply(this, arguments);
172
+ }
134
173
 
135
- function _fetchNonSkippedPipelines() {
136
- _fetchNonSkippedPipelines = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(projectId, config, options) {
174
+ function _fetchPipelines() {
175
+ _fetchPipelines = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(projectId, config, options) {
137
176
  var _yield$gitlabRequest, pipelines;
138
177
 
139
- return _regenerator.default.wrap(function _callee3$(_context3) {
178
+ return _regenerator.default.wrap(function _callee4$(_context4) {
140
179
  while (1) {
141
- switch (_context3.prev = _context3.next) {
180
+ switch (_context4.prev = _context4.next) {
142
181
  case 0:
143
- _context3.next = 2;
182
+ _context4.next = 2;
144
183
  return (0, _client.gitlabRequest)("/projects/".concat(projectId, "/pipelines"), options, config);
145
184
 
146
185
  case 2:
147
- _yield$gitlabRequest = _context3.sent;
186
+ _yield$gitlabRequest = _context4.sent;
148
187
  pipelines = _yield$gitlabRequest.data;
149
- return _context3.abrupt("return", pipelines.filter(pipeline => pipeline.status !== 'skipped'));
188
+ return _context4.abrupt("return", pipelines.filter(pipeline => pipeline.status !== 'skipped'));
150
189
 
151
190
  case 5:
152
191
  case "end":
153
- return _context3.stop();
192
+ return _context4.stop();
154
193
  }
155
194
  }
156
- }, _callee3);
195
+ }, _callee4);
157
196
  }));
158
- return _fetchNonSkippedPipelines.apply(this, arguments);
197
+ return _fetchPipelines.apply(this, arguments);
159
198
  }
160
199
 
161
- function fetchJobsForPipelines(_x8, _x9, _x10) {
162
- return _fetchJobsForPipelines.apply(this, arguments);
200
+ function fetchDownstreamJobs(_x8, _x9, _x10) {
201
+ return _fetchDownstreamJobs.apply(this, arguments);
163
202
  }
164
203
 
165
- function _fetchJobsForPipelines() {
166
- _fetchJobsForPipelines = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(projectId, pipelines, config) {
167
- var includedPipelineIds, _pipelines$map$sort, _pipelines$map$sort2, oldestCreatedAt, jobs, SAFETY_MAX_PAGE, page, _yield$gitlabRequest2, jobsBatch;
204
+ function _fetchDownstreamJobs() {
205
+ _fetchDownstreamJobs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(projectId, pipelineId, config) {
206
+ var _yield$gitlabRequest2, gitlabBridgeJobs, childPipelines, downstreamStages, _iterator, _step, _loop;
168
207
 
169
- return _regenerator.default.wrap(function _callee4$(_context4) {
208
+ return _regenerator.default.wrap(function _callee5$(_context6) {
170
209
  while (1) {
171
- switch (_context4.prev = _context4.next) {
210
+ switch (_context6.prev = _context6.next) {
172
211
  case 0:
173
- includedPipelineIds = pipelines.map(pipeline => pipeline.id);
174
- _pipelines$map$sort = pipelines.map(pipeline => pipeline.created_at).sort(), _pipelines$map$sort2 = (0, _slicedToArray2.default)(_pipelines$map$sort, 1), oldestCreatedAt = _pipelines$map$sort2[0];
175
- jobs = [];
176
- SAFETY_MAX_PAGE = 10;
177
- page = 1;
178
-
179
- case 5:
180
- if (!(page <= SAFETY_MAX_PAGE)) {
181
- _context4.next = 16;
182
- break;
183
- }
184
-
185
- _context4.next = 8;
186
- return (0, _client.gitlabRequest)("/projects/".concat(projectId, "/jobs"), {
187
- page,
212
+ _context6.next = 2;
213
+ return (0, _client.gitlabRequest)("/projects/".concat(projectId, "/pipelines/").concat(pipelineId, "/bridges"), {
188
214
  per_page: 100
189
215
  }, config);
190
216
 
191
- case 8:
192
- _yield$gitlabRequest2 = _context4.sent;
193
- jobsBatch = _yield$gitlabRequest2.data;
194
- jobs.push(jobsBatch.filter(job => includedPipelineIds.includes(job.pipeline.id)).filter(job => job.created_at >= oldestCreatedAt));
217
+ case 2:
218
+ _yield$gitlabRequest2 = _context6.sent;
219
+ gitlabBridgeJobs = _yield$gitlabRequest2.data;
220
+ childPipelines = gitlabBridgeJobs.filter(bridge => bridge.downstream_pipeline.status !== 'skipped');
221
+ downstreamStages = [];
222
+ _iterator = _createForOfIteratorHelper(childPipelines);
223
+ _context6.prev = 7;
224
+ _loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
225
+ var childPipeline, _yield$fetchJobs2, stages;
226
+
227
+ return _regenerator.default.wrap(function _loop$(_context5) {
228
+ while (1) {
229
+ switch (_context5.prev = _context5.next) {
230
+ case 0:
231
+ childPipeline = _step.value;
232
+ _context5.next = 3;
233
+ return fetchJobs(projectId, childPipeline.downstream_pipeline.id, config);
234
+
235
+ case 3:
236
+ _yield$fetchJobs2 = _context5.sent;
237
+ stages = _yield$fetchJobs2.stages;
238
+ downstreamStages.push(stages.map(stage => _objectSpread(_objectSpread({}, stage), {}, {
239
+ name: "".concat(childPipeline.stage, ":").concat(stage.name)
240
+ })));
241
+
242
+ case 6:
243
+ case "end":
244
+ return _context5.stop();
245
+ }
246
+ }
247
+ }, _loop);
248
+ });
249
+
250
+ _iterator.s();
195
251
 
196
- if (!(jobsBatch.length === 0 || jobsBatch[jobsBatch.length - 1].created_at < oldestCreatedAt)) {
197
- _context4.next = 13;
252
+ case 10:
253
+ if ((_step = _iterator.n()).done) {
254
+ _context6.next = 14;
198
255
  break;
199
256
  }
200
257
 
201
- return _context4.abrupt("break", 16);
258
+ return _context6.delegateYield(_loop(), "t0", 12);
202
259
 
203
- case 13:
204
- page += 1;
205
- _context4.next = 5;
260
+ case 12:
261
+ _context6.next = 10;
262
+ break;
263
+
264
+ case 14:
265
+ _context6.next = 19;
206
266
  break;
207
267
 
208
268
  case 16:
209
- return _context4.abrupt("return", jobs.flat());
269
+ _context6.prev = 16;
270
+ _context6.t1 = _context6["catch"](7);
271
+
272
+ _iterator.e(_context6.t1);
210
273
 
211
- case 17:
274
+ case 19:
275
+ _context6.prev = 19;
276
+
277
+ _iterator.f();
278
+
279
+ return _context6.finish(19);
280
+
281
+ case 22:
282
+ return _context6.abrupt("return", downstreamStages.flat());
283
+
284
+ case 23:
212
285
  case "end":
213
- return _context4.stop();
286
+ return _context6.stop();
214
287
  }
215
288
  }
216
- }, _callee4);
289
+ }, _callee5, null, [[7, 16, 19, 22]]);
217
290
  }));
218
- return _fetchJobsForPipelines.apply(this, arguments);
291
+ return _fetchDownstreamJobs.apply(this, arguments);
219
292
  }
220
293
 
221
- function matchJobs(pipelineId, gitlabJobsForMultiplePipelines) {
222
- var gitlabJobs = gitlabJobsForMultiplePipelines.filter(job => job.pipeline.id === pipelineId);
294
+ function fetchJobs(_x11, _x12, _x13) {
295
+ return _fetchJobs.apply(this, arguments);
296
+ }
223
297
 
224
- if (gitlabJobs.length === 0) {
225
- return {};
226
- }
298
+ function _fetchJobs() {
299
+ _fetchJobs = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(projectId, pipelineId, config) {
300
+ var _yield$gitlabRequest3, gitlabJobs, commit, stages;
227
301
 
228
- var commit = findCommit(gitlabJobs);
229
- var stages = (0, _lodash.default)(gitlabJobs).map(job => ({
230
- id: job.id,
231
- status: job.status,
232
- stage: job.stage,
233
- name: job.name,
234
- startedAt: job.started_at,
235
- finishedAt: job.finished_at,
236
- url: job.web_url
237
- })).orderBy('id').groupBy('stage').mapValues(mergeRetriedJobs).mapValues(cleanup).toPairs().map(_ref => {
238
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
239
- name = _ref2[0],
240
- jobs = _ref2[1];
241
-
242
- return {
243
- name,
244
- jobs: _lodash.default.sortBy(jobs, 'name')
245
- };
246
- }).value();
247
- return {
248
- commit,
249
- stages
250
- };
302
+ return _regenerator.default.wrap(function _callee6$(_context7) {
303
+ while (1) {
304
+ switch (_context7.prev = _context7.next) {
305
+ case 0:
306
+ _context7.next = 2;
307
+ return (0, _client.gitlabRequest)("/projects/".concat(projectId, "/pipelines/").concat(pipelineId, "/jobs?include_retried=true"), {
308
+ per_page: 100
309
+ }, config);
310
+
311
+ case 2:
312
+ _yield$gitlabRequest3 = _context7.sent;
313
+ gitlabJobs = _yield$gitlabRequest3.data;
314
+
315
+ if (!(gitlabJobs.length === 0)) {
316
+ _context7.next = 6;
317
+ break;
318
+ }
319
+
320
+ return _context7.abrupt("return", {});
321
+
322
+ case 6:
323
+ commit = findCommit(gitlabJobs);
324
+ stages = (0, _lodash.default)(gitlabJobs).map(job => ({
325
+ id: job.id,
326
+ status: job.status,
327
+ stage: job.stage,
328
+ name: job.name,
329
+ startedAt: job.started_at,
330
+ finishedAt: job.finished_at,
331
+ url: job.web_url
332
+ })).orderBy('id').groupBy('stage').mapValues(mergeRetriedJobs).mapValues(cleanup).toPairs().map(_ref3 => {
333
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
334
+ name = _ref4[0],
335
+ jobs = _ref4[1];
336
+
337
+ return {
338
+ name,
339
+ jobs: _lodash.default.sortBy(jobs, 'name')
340
+ };
341
+ }).value();
342
+ return _context7.abrupt("return", {
343
+ commit,
344
+ stages
345
+ });
346
+
347
+ case 9:
348
+ case "end":
349
+ return _context7.stop();
350
+ }
351
+ }
352
+ }, _callee6);
353
+ }));
354
+ return _fetchJobs.apply(this, arguments);
251
355
  }
252
356
 
253
357
  function findCommit(jobs) {