gitlab-radiator 3.3.11 → 3.4.0

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.
@@ -0,0 +1,434 @@
1
+ import {expect} from 'chai'
2
+ import {fetchLatestPipelines} from '../src/gitlab/pipelines'
3
+ import {fetchProjects} from '../src/gitlab/projects'
4
+ import {update} from '../src/gitlab'
5
+
6
+ const gitlab = {
7
+ url: 'https://gitlab.com',
8
+ 'access-token': 'K34Nzm3_JA1rQMML6j5h',
9
+ maxNonFailedJobsVisible: 10
10
+ }
11
+
12
+ describe('Gitlab client', () => {
13
+ it('Should find five projects with no filtering ', async () => {
14
+ const config = {...gitlab}
15
+ const projects = await fetchProjects(config)
16
+ expect(projects).to.deep.equal([
17
+ {archived: false, default_branch: 'master', group: 'gitlab-radiator-test', id: 39541352, name: 'gitlab-radiator-test/project-with-child-pipeline', nameWithoutNamespace: 'project-with-child-pipeline', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/project-with-child-pipeline'},
18
+ {archived: false, default_branch: 'master', group: 'gitlab-radiator-test', id: 5385889, name: 'gitlab-radiator-test/ci-skip-test-project', nameWithoutNamespace: 'ci-skip-test-project', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project'},
19
+ {archived: false, default_branch: 'master', group: 'gitlab-radiator-test', id: 5304923, name: 'gitlab-radiator-test/empty-test', nameWithoutNamespace: 'empty-test', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/empty-test'},
20
+ {archived: false, default_branch: 'master', group: 'gitlab-radiator-test', id: 5290928, name: 'gitlab-radiator-test/integration-test-project-2', nameWithoutNamespace: 'integration-test-project-2', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2'},
21
+ {archived: false, default_branch: 'master', group: 'gitlab-radiator-test', id: 5290865, name: 'gitlab-radiator-test/integration-test-project-1', nameWithoutNamespace: 'integration-test-project-1', tags: ['display-1'], url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1'}
22
+ ])
23
+ })
24
+
25
+ it('Should find one project with inclusive filtering', async () => {
26
+ const config = {...gitlab, projects: {include: '.*project-1'}}
27
+ const projects = await fetchProjects(config)
28
+ expect(projects).to.deep.equal([
29
+ {archived: false, default_branch: 'master', id: 5290865, group: 'gitlab-radiator-test', name: 'gitlab-radiator-test/integration-test-project-1', nameWithoutNamespace: 'integration-test-project-1', tags: ['display-1'], url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1'}
30
+ ])
31
+ })
32
+
33
+ it('Should find four projects with exclusive filtering', async () => {
34
+ const config = {...gitlab, projects: {exclude: '.*project-1'}}
35
+ const projects = await fetchProjects(config)
36
+ expect(projects).to.deep.equal([
37
+ {archived: false, default_branch: 'master', group: 'gitlab-radiator-test', id: 39541352, name: 'gitlab-radiator-test/project-with-child-pipeline', nameWithoutNamespace: 'project-with-child-pipeline', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/project-with-child-pipeline'},
38
+ {archived: false, default_branch: 'master', id: 5385889, group: 'gitlab-radiator-test', name: 'gitlab-radiator-test/ci-skip-test-project', nameWithoutNamespace: 'ci-skip-test-project', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project'},
39
+ {archived: false, default_branch: 'master', id: 5304923, group: 'gitlab-radiator-test', name: 'gitlab-radiator-test/empty-test', nameWithoutNamespace: 'empty-test', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/empty-test'},
40
+ {archived: false, default_branch: 'master', id: 5290928, group: 'gitlab-radiator-test', name: 'gitlab-radiator-test/integration-test-project-2', nameWithoutNamespace: 'integration-test-project-2', tags: [], url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2'}
41
+ ])
42
+ })
43
+
44
+ it('Should find latest non-skipped pipeline for project', async () => {
45
+ const config = {...gitlab}
46
+ const pipelines = await fetchLatestPipelines(5385889, config)
47
+ expect(pipelines).to.deep.equal(
48
+ [{
49
+ commit: {
50
+ author: 'Heikki Pora',
51
+ title: '[ci skip] do nothing'
52
+ },
53
+ id: 234495591,
54
+ ref: 'master',
55
+ stages: [{
56
+ jobs: [{
57
+ finishedAt: '2020-12-25T20:08:30.992Z',
58
+ id: 932219322,
59
+ name: 'test',
60
+ startedAt: '2020-12-25T20:07:50.812Z',
61
+ status: 'success',
62
+ url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project/-/jobs/932219322'
63
+ }],
64
+ name: 'test'
65
+ }],
66
+ status: 'success'
67
+ }]
68
+ )
69
+ })
70
+
71
+ it('Should find latest pipelines for project (feature branch + master) with stages and retried jobs merged to one entry', async () => {
72
+ const config = {...gitlab}
73
+ const pipelines = await fetchLatestPipelines(5290928, config)
74
+ expect(pipelines).to.deep.equal(
75
+ [{
76
+ id: 234613306,
77
+ status: 'success',
78
+ commit: {
79
+ title: 'Fail more',
80
+ author: 'Heikki Pora'
81
+ },
82
+ ref: 'feature/test-branch',
83
+ stages: [
84
+ {
85
+ name: 'test',
86
+ jobs: [
87
+ {
88
+ id: 932599898,
89
+ status: 'success',
90
+ name: 'fail_randomly_long_name',
91
+ startedAt: '2020-12-26T13:59:35.397Z',
92
+ finishedAt: '2020-12-26T14:00:11.845Z',
93
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599898'
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ name: 'build',
99
+ jobs: [
100
+ {
101
+ id: 932599715,
102
+ status: 'success',
103
+ name: 'build_my_stuff',
104
+ startedAt: '2020-12-26T14:00:12.710Z',
105
+ finishedAt: '2020-12-26T14:00:53.946Z',
106
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599715'
107
+ }
108
+ ]
109
+ }
110
+ ]
111
+ },
112
+ {
113
+ id: 234613296,
114
+ status: 'failed',
115
+ commit: {
116
+ author: 'Heikki Pora',
117
+ title: 'Fail more'
118
+ },
119
+ ref: 'master',
120
+ stages: [
121
+ {
122
+ jobs: [
123
+ {
124
+ finishedAt: '2020-12-26T14:01:11.815Z',
125
+ id: 932600811,
126
+ name: 'fail_randomly_long_name',
127
+ startedAt: '2020-12-26T14:00:39.928Z',
128
+ status: 'failed',
129
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932600811'
130
+ }
131
+ ],
132
+ name: 'test'
133
+ },
134
+ {
135
+ jobs: [
136
+ {
137
+ finishedAt: '2020-12-26T13:59:28.050Z',
138
+ id: 932599688,
139
+ name: 'build_my_stuff',
140
+ startedAt: '2020-12-26T13:58:54.325Z',
141
+ status: 'success',
142
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599688'
143
+ }
144
+ ],
145
+ name: 'build'
146
+ }
147
+ ]
148
+ }]
149
+ )
150
+ })
151
+
152
+ it('Should find two projects with two pipelines for the first and one for the second (and exclude projects without pipelines)', async() => {
153
+ const config = {gitlabs: [{...gitlab, projects: {exclude: '.*-with-child-pipeline'}}]}
154
+ const projects = await update(config)
155
+ expect(projects).to.deep.equal(
156
+ [
157
+ {
158
+ archived: false,
159
+ default_branch: 'master',
160
+ group: 'gitlab-radiator-test',
161
+ id: 5385889,
162
+ maxNonFailedJobsVisible: 10,
163
+ name: 'gitlab-radiator-test/ci-skip-test-project',
164
+ nameWithoutNamespace: 'ci-skip-test-project',
165
+ tags: [],
166
+ url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project',
167
+ pipelines: [
168
+ {
169
+ id: 234495591,
170
+ status: 'success',
171
+ commit: {
172
+ author: 'Heikki Pora',
173
+ title: '[ci skip] do nothing'
174
+ },
175
+ ref: 'master',
176
+ stages: [{
177
+ jobs: [{
178
+ finishedAt: '2020-12-25T20:08:30.992Z',
179
+ id: 932219322,
180
+ name: 'test',
181
+ startedAt: '2020-12-25T20:07:50.812Z',
182
+ status: 'success',
183
+ url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project/-/jobs/932219322'
184
+ }],
185
+ name: 'test'
186
+ }]
187
+ }
188
+ ],
189
+ status: 'success'
190
+ },
191
+ {
192
+ archived: false,
193
+ default_branch: 'master',
194
+ group: 'gitlab-radiator-test',
195
+ id: 5290928,
196
+ maxNonFailedJobsVisible: 10,
197
+ name: 'gitlab-radiator-test/integration-test-project-2',
198
+ nameWithoutNamespace: 'integration-test-project-2',
199
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2',
200
+ tags: [],
201
+ pipelines: [
202
+ {
203
+ id: 234613306,
204
+ status: 'success',
205
+ commit: {
206
+ title: 'Fail more',
207
+ author: 'Heikki Pora'
208
+ },
209
+ ref: 'feature/test-branch',
210
+ stages: [
211
+ {
212
+ name: 'test',
213
+ jobs: [
214
+ {
215
+ id: 932599898,
216
+ status: 'success',
217
+ name: 'fail_randomly_long_name',
218
+ startedAt: '2020-12-26T13:59:35.397Z',
219
+ finishedAt: '2020-12-26T14:00:11.845Z',
220
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599898'
221
+ }
222
+ ]
223
+ },
224
+ {
225
+ name: 'build',
226
+ jobs: [
227
+ {
228
+ id: 932599715,
229
+ status: 'success',
230
+ name: 'build_my_stuff',
231
+ startedAt: '2020-12-26T14:00:12.710Z',
232
+ finishedAt: '2020-12-26T14:00:53.946Z',
233
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599715'
234
+ }
235
+ ]
236
+ }
237
+ ]
238
+ },
239
+ {
240
+ id: 234613296,
241
+ ref: 'master',
242
+ status: 'failed',
243
+ commit: {
244
+ title: 'Fail more',
245
+ author: 'Heikki Pora'
246
+ },
247
+ stages: [
248
+ {
249
+ name: 'test',
250
+ jobs: [
251
+ {
252
+ id: 932600811,
253
+ status: 'failed',
254
+ name: 'fail_randomly_long_name',
255
+ startedAt: '2020-12-26T14:00:39.928Z',
256
+ finishedAt: '2020-12-26T14:01:11.815Z',
257
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932600811'
258
+ }
259
+ ]
260
+ },
261
+ {
262
+ name: 'build',
263
+ jobs: [
264
+ {
265
+ id: 932599688,
266
+ status: 'success',
267
+ name: 'build_my_stuff',
268
+ startedAt: '2020-12-26T13:58:54.325Z',
269
+ finishedAt: '2020-12-26T13:59:28.050Z',
270
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599688'
271
+ }
272
+ ]
273
+ }
274
+ ]
275
+ }
276
+ ],
277
+ status: 'failed'
278
+ },
279
+ {
280
+ archived: false,
281
+ default_branch: 'master',
282
+ group: 'gitlab-radiator-test',
283
+ id: 5290865,
284
+ maxNonFailedJobsVisible: 10,
285
+ name: 'gitlab-radiator-test/integration-test-project-1',
286
+ nameWithoutNamespace: 'integration-test-project-1',
287
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1',
288
+ tags: ['display-1'],
289
+ pipelines: [
290
+ {
291
+ id: 234493901,
292
+ ref: 'master',
293
+ status: 'success',
294
+ commit: {
295
+ title: 'Fail manual step',
296
+ author: 'Heikki Pora'
297
+ },
298
+ stages: [
299
+ {
300
+ name: 'test',
301
+ jobs: [
302
+ {
303
+ id: 932213321,
304
+ status: 'success',
305
+ name: 'api-test',
306
+ startedAt: '2020-12-25T20:02:42.733Z',
307
+ finishedAt: '2020-12-25T20:03:36.383Z',
308
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213321'
309
+ },
310
+ {
311
+ id: 932213322,
312
+ status: 'success',
313
+ name: 'browser-test',
314
+ startedAt: '2020-12-25T20:02:43.020Z',
315
+ finishedAt: '2020-12-25T20:03:28.386Z',
316
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213322'
317
+ },
318
+ {
319
+ id: 932213319,
320
+ status: 'success',
321
+ name: 'eslint',
322
+ startedAt: '2020-12-25T20:02:42.444Z',
323
+ finishedAt: '2020-12-25T20:03:34.931Z',
324
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213319'
325
+ },
326
+ {
327
+ id: 932213320,
328
+ status: 'success',
329
+ name: 'verify',
330
+ startedAt: '2020-12-25T20:02:42.663Z',
331
+ finishedAt: '2020-12-25T20:03:35.364Z',
332
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213320'
333
+ }
334
+ ]
335
+ },
336
+ {
337
+ name: 'build',
338
+ jobs: [
339
+ {
340
+ id: 932213323,
341
+ status: 'success',
342
+ name: 'package-my-stuff',
343
+ startedAt: '2020-12-25T20:03:37.107Z',
344
+ finishedAt: '2020-12-25T20:04:22.618Z',
345
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213323'
346
+ }
347
+ ]
348
+ },
349
+ {
350
+ name: 'deploy',
351
+ jobs: [
352
+ {
353
+ id: 932213324,
354
+ status: 'success',
355
+ name: 'deploy-my-awesome-stuff',
356
+ startedAt: '2020-12-25T20:04:23.450Z',
357
+ finishedAt: '2020-12-25T20:05:14.167Z',
358
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213324'
359
+ }
360
+ ]
361
+ },
362
+ {
363
+ name: 'finnish',
364
+ jobs: [
365
+ {
366
+ id: 932213325,
367
+ status: 'manual',
368
+ name: 'manual_step-1',
369
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213325'
370
+ },
371
+ {
372
+ id: 932213326,
373
+ status: 'manual',
374
+ name: 'manual_step-2',
375
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213326'
376
+ }
377
+ ]
378
+ }
379
+ ]
380
+ }
381
+ ],
382
+ status: 'success'
383
+ }]
384
+ )
385
+ })
386
+
387
+ it('Should include triggered child pipeline for project', async () => {
388
+ const config = {...gitlab}
389
+ const pipelines = await fetchLatestPipelines(39541352, config)
390
+ expect(pipelines).to.deep.equal(
391
+ [{
392
+ commit: {
393
+ author: 'Heikki Pora',
394
+ title: 'Initial commit'
395
+ },
396
+ id: 644417453,
397
+ ref: 'master',
398
+ stages: [{
399
+ jobs: [{
400
+ finishedAt: '2022-09-19T16:59:07.394Z',
401
+ id: 3050180428,
402
+ name: 'start-job',
403
+ startedAt: '2022-09-19T16:58:54.170Z',
404
+ status: 'success',
405
+ url: 'https://gitlab.com/gitlab-radiator-test/project-with-child-pipeline/-/jobs/3050180428'
406
+ }],
407
+ name: 'start'
408
+ }, {
409
+ jobs: [{
410
+ finishedAt: '2022-09-19T16:59:23.868Z',
411
+ id: 3050181208,
412
+ name: 'build',
413
+ startedAt: '2022-09-19T16:59:08.204Z',
414
+ status: 'success',
415
+ url: 'https://gitlab.com/gitlab-radiator-test/project-with-child-pipeline/-/jobs/3050181208'
416
+ }],
417
+ name: 'run-child:build'
418
+ },{
419
+ jobs: [{
420
+ finishedAt: '2022-09-19T16:59:36.918Z',
421
+ id: 3050181210,
422
+ name: 'test',
423
+ startedAt: '2022-09-19T16:59:24.138Z',
424
+ status: 'success',
425
+ url: 'https://gitlab.com/gitlab-radiator-test/project-with-child-pipeline/-/jobs/3050181210'
426
+ }],
427
+ name: 'run-child:test'
428
+ }],
429
+ status: 'success'
430
+ }]
431
+ )
432
+ })
433
+
434
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist/",
4
+ "target": "es5",
5
+ "lib": [
6
+ "dom",
7
+ "dom.iterable",
8
+ "esnext"
9
+ ],
10
+ "allowJs": true,
11
+ "skipLibCheck": true,
12
+ "esModuleInterop": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "strict": true,
15
+ "forceConsistentCasingInFileNames": true,
16
+ "module": "esnext",
17
+ "moduleResolution": "node",
18
+ "isolatedModules": true,
19
+ "resolveJsonModule": true,
20
+ "jsx": "react",
21
+ "sourceMap": true,
22
+ "declaration": false,
23
+ "noUnusedLocals": true,
24
+ "noUnusedParameters": true,
25
+ "incremental": true,
26
+ "noFallthroughCasesInSwitch": true
27
+ }
28
+ }
@@ -0,0 +1,25 @@
1
+ const path = require('path')
2
+ const webpack = require('webpack')
3
+
4
+ module.exports = {
5
+ module: {
6
+ rules: [
7
+ {
8
+ test: /\.(js|jsx|ts|tsx)$/,
9
+ use: 'ts-loader',
10
+ exclude: /node_modules/,
11
+ },
12
+ {
13
+ test: /\.(ttf|html)$/i,
14
+ type: 'asset/resource'
15
+ }
16
+ ]
17
+ },
18
+ output: {
19
+ filename: 'client.js',
20
+ path: path.resolve(__dirname, 'build/public')
21
+ },
22
+ resolve: {
23
+ extensions: ['.js', '.ts', '.tsx']
24
+ }
25
+ }
package/webpack.dev.js ADDED
@@ -0,0 +1,13 @@
1
+ const common = require('./webpack.common.js')
2
+ const {merge} = require('webpack-merge')
3
+ const webpack = require('webpack')
4
+
5
+ module.exports = merge(common, {
6
+ mode: 'development',
7
+ entry: [
8
+ './src/client/index.tsx',
9
+ 'webpack-hot-middleware/client'
10
+ ],
11
+ plugins: [new webpack.HotModuleReplacementPlugin()],
12
+ devtool: 'inline-source-map'
13
+ })
@@ -0,0 +1,9 @@
1
+ const common = require('./webpack.common.js')
2
+ const {merge} = require('webpack-merge')
3
+
4
+ module.exports = merge(common, {
5
+ mode: 'production',
6
+ entry: [
7
+ './src/client/index.tsx'
8
+ ]
9
+ })