gitlab-radiator 3.3.8 → 3.3.9

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,384 @@
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 four 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: 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'},
18
+ {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'},
19
+ {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'},
20
+ {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'}
21
+ ])
22
+ })
23
+
24
+ it('Should find one project with inclusive filtering', async () => {
25
+ const config = {...gitlab, projects: {include: '.*project-1'}}
26
+ const projects = await fetchProjects(config)
27
+ expect(projects).to.deep.equal([
28
+ {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'}
29
+ ])
30
+ })
31
+
32
+ it('Should find three projects with exclusive filtering', async () => {
33
+ const config = {...gitlab, projects: {exclude: '.*project-1'}}
34
+ const projects = await fetchProjects(config)
35
+ expect(projects).to.deep.equal([
36
+ {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'},
37
+ {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'},
38
+ {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'}
39
+ ])
40
+ })
41
+
42
+ it('Should find latest non-skipped pipeline for project', async () => {
43
+ const config = {...gitlab}
44
+ const pipelines = await fetchLatestPipelines(5385889, config)
45
+ expect(pipelines).to.deep.equal(
46
+ [{
47
+ commit: {
48
+ author: 'Heikki Pora',
49
+ title: '[ci skip] do nothing'
50
+ },
51
+ id: 234495591,
52
+ ref: 'master',
53
+ stages: [{
54
+ jobs: [{
55
+ finishedAt: '2020-12-25T20:08:30.992Z',
56
+ id: 932219322,
57
+ name: 'test',
58
+ startedAt: '2020-12-25T20:07:50.812Z',
59
+ status: 'success',
60
+ url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project/-/jobs/932219322'
61
+ }],
62
+ name: 'test'
63
+ }],
64
+ status: 'success'
65
+ }]
66
+ )
67
+ })
68
+
69
+ it('Should find latest pipelines for project (feature branch + master) with stages and retried jobs merged to one entry', async () => {
70
+ const config = {...gitlab}
71
+ const pipelines = await fetchLatestPipelines(5290928, config)
72
+ expect(pipelines).to.deep.equal(
73
+ [{
74
+ id: 234613306,
75
+ status: 'success',
76
+ commit: {
77
+ title: 'Fail more',
78
+ author: 'Heikki Pora'
79
+ },
80
+ ref: 'feature/test-branch',
81
+ stages: [
82
+ {
83
+ name: 'test',
84
+ jobs: [
85
+ {
86
+ id: 932599898,
87
+ status: 'success',
88
+ name: 'fail_randomly_long_name',
89
+ startedAt: '2020-12-26T13:59:35.397Z',
90
+ finishedAt: '2020-12-26T14:00:11.845Z',
91
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599898'
92
+ }
93
+ ]
94
+ },
95
+ {
96
+ name: 'build',
97
+ jobs: [
98
+ {
99
+ id: 932599715,
100
+ status: 'success',
101
+ name: 'build_my_stuff',
102
+ startedAt: '2020-12-26T14:00:12.710Z',
103
+ finishedAt: '2020-12-26T14:00:53.946Z',
104
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599715'
105
+ }
106
+ ]
107
+ }
108
+ ]
109
+ },
110
+ {
111
+ id: 234613296,
112
+ status: 'failed',
113
+ commit: {
114
+ author: 'Heikki Pora',
115
+ title: 'Fail more'
116
+ },
117
+ ref: 'master',
118
+ stages: [
119
+ {
120
+ jobs: [
121
+ {
122
+ finishedAt: '2020-12-26T14:01:11.815Z',
123
+ id: 932600811,
124
+ name: 'fail_randomly_long_name',
125
+ startedAt: '2020-12-26T14:00:39.928Z',
126
+ status: 'failed',
127
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932600811'
128
+ }
129
+ ],
130
+ name: 'test'
131
+ },
132
+ {
133
+ jobs: [
134
+ {
135
+ finishedAt: '2020-12-26T13:59:28.050Z',
136
+ id: 932599688,
137
+ name: 'build_my_stuff',
138
+ startedAt: '2020-12-26T13:58:54.325Z',
139
+ status: 'success',
140
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599688'
141
+ }
142
+ ],
143
+ name: 'build'
144
+ }
145
+ ]
146
+ }]
147
+ )
148
+ })
149
+
150
+ it('Should find two projects with two pipelines for the first and one for the second (and exclude projects without pipelines)', async() => {
151
+ const config = {gitlabs: [{...gitlab}]}
152
+ const projects = await update(config)
153
+ expect(projects).to.deep.equal(
154
+ [
155
+ {
156
+ archived: false,
157
+ default_branch: 'master',
158
+ group: 'gitlab-radiator-test',
159
+ id: 5385889,
160
+ maxNonFailedJobsVisible: 10,
161
+ name: 'gitlab-radiator-test/ci-skip-test-project',
162
+ nameWithoutNamespace: 'ci-skip-test-project',
163
+ tags: [],
164
+ url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project',
165
+ pipelines: [
166
+ {
167
+ id: 234495591,
168
+ status: 'success',
169
+ commit: {
170
+ author: 'Heikki Pora',
171
+ title: '[ci skip] do nothing'
172
+ },
173
+ ref: 'master',
174
+ stages: [{
175
+ jobs: [{
176
+ finishedAt: '2020-12-25T20:08:30.992Z',
177
+ id: 932219322,
178
+ name: 'test',
179
+ startedAt: '2020-12-25T20:07:50.812Z',
180
+ status: 'success',
181
+ url: 'https://gitlab.com/gitlab-radiator-test/ci-skip-test-project/-/jobs/932219322'
182
+ }],
183
+ name: 'test'
184
+ }]
185
+ }
186
+ ],
187
+ status: 'success'
188
+ },
189
+ {
190
+ archived: false,
191
+ default_branch: 'master',
192
+ group: 'gitlab-radiator-test',
193
+ id: 5290928,
194
+ maxNonFailedJobsVisible: 10,
195
+ name: 'gitlab-radiator-test/integration-test-project-2',
196
+ nameWithoutNamespace: 'integration-test-project-2',
197
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2',
198
+ tags: [],
199
+ pipelines: [
200
+ {
201
+ id: 234613306,
202
+ status: 'success',
203
+ commit: {
204
+ title: 'Fail more',
205
+ author: 'Heikki Pora'
206
+ },
207
+ ref: 'feature/test-branch',
208
+ stages: [
209
+ {
210
+ name: 'test',
211
+ jobs: [
212
+ {
213
+ id: 932599898,
214
+ status: 'success',
215
+ name: 'fail_randomly_long_name',
216
+ startedAt: '2020-12-26T13:59:35.397Z',
217
+ finishedAt: '2020-12-26T14:00:11.845Z',
218
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599898'
219
+ }
220
+ ]
221
+ },
222
+ {
223
+ name: 'build',
224
+ jobs: [
225
+ {
226
+ id: 932599715,
227
+ status: 'success',
228
+ name: 'build_my_stuff',
229
+ startedAt: '2020-12-26T14:00:12.710Z',
230
+ finishedAt: '2020-12-26T14:00:53.946Z',
231
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599715'
232
+ }
233
+ ]
234
+ }
235
+ ]
236
+ },
237
+ {
238
+ id: 234613296,
239
+ ref: 'master',
240
+ status: 'failed',
241
+ commit: {
242
+ title: 'Fail more',
243
+ author: 'Heikki Pora'
244
+ },
245
+ stages: [
246
+ {
247
+ name: 'test',
248
+ jobs: [
249
+ {
250
+ id: 932600811,
251
+ status: 'failed',
252
+ name: 'fail_randomly_long_name',
253
+ startedAt: '2020-12-26T14:00:39.928Z',
254
+ finishedAt: '2020-12-26T14:01:11.815Z',
255
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932600811'
256
+ }
257
+ ]
258
+ },
259
+ {
260
+ name: 'build',
261
+ jobs: [
262
+ {
263
+ id: 932599688,
264
+ status: 'success',
265
+ name: 'build_my_stuff',
266
+ startedAt: '2020-12-26T13:58:54.325Z',
267
+ finishedAt: '2020-12-26T13:59:28.050Z',
268
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-2/-/jobs/932599688'
269
+ }
270
+ ]
271
+ }
272
+ ]
273
+ }
274
+ ],
275
+ status: 'failed'
276
+ },
277
+ {
278
+ archived: false,
279
+ default_branch: 'master',
280
+ group: 'gitlab-radiator-test',
281
+ id: 5290865,
282
+ maxNonFailedJobsVisible: 10,
283
+ name: 'gitlab-radiator-test/integration-test-project-1',
284
+ nameWithoutNamespace: 'integration-test-project-1',
285
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1',
286
+ tags: ['display-1'],
287
+ pipelines: [
288
+ {
289
+ id: 234493901,
290
+ ref: 'master',
291
+ status: 'success',
292
+ commit: {
293
+ title: 'Fail manual step',
294
+ author: 'Heikki Pora'
295
+ },
296
+ stages: [
297
+ {
298
+ name: 'test',
299
+ jobs: [
300
+ {
301
+ id: 932213321,
302
+ status: 'success',
303
+ name: 'api-test',
304
+ startedAt: '2020-12-25T20:02:42.733Z',
305
+ finishedAt: '2020-12-25T20:03:36.383Z',
306
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213321'
307
+ },
308
+ {
309
+ id: 932213322,
310
+ status: 'success',
311
+ name: 'browser-test',
312
+ startedAt: '2020-12-25T20:02:43.020Z',
313
+ finishedAt: '2020-12-25T20:03:28.386Z',
314
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213322'
315
+ },
316
+ {
317
+ id: 932213319,
318
+ status: 'success',
319
+ name: 'eslint',
320
+ startedAt: '2020-12-25T20:02:42.444Z',
321
+ finishedAt: '2020-12-25T20:03:34.931Z',
322
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213319'
323
+ },
324
+ {
325
+ id: 932213320,
326
+ status: 'success',
327
+ name: 'verify',
328
+ startedAt: '2020-12-25T20:02:42.663Z',
329
+ finishedAt: '2020-12-25T20:03:35.364Z',
330
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213320'
331
+ }
332
+ ]
333
+ },
334
+ {
335
+ name: 'build',
336
+ jobs: [
337
+ {
338
+ id: 932213323,
339
+ status: 'success',
340
+ name: 'package-my-stuff',
341
+ startedAt: '2020-12-25T20:03:37.107Z',
342
+ finishedAt: '2020-12-25T20:04:22.618Z',
343
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213323'
344
+ }
345
+ ]
346
+ },
347
+ {
348
+ name: 'deploy',
349
+ jobs: [
350
+ {
351
+ id: 932213324,
352
+ status: 'success',
353
+ name: 'deploy-my-awesome-stuff',
354
+ startedAt: '2020-12-25T20:04:23.450Z',
355
+ finishedAt: '2020-12-25T20:05:14.167Z',
356
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213324'
357
+ }
358
+ ]
359
+ },
360
+ {
361
+ name: 'finnish',
362
+ jobs: [
363
+ {
364
+ id: 932213325,
365
+ status: 'manual',
366
+ name: 'manual_step-1',
367
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213325'
368
+ },
369
+ {
370
+ id: 932213326,
371
+ status: 'manual',
372
+ name: 'manual_step-2',
373
+ url: 'https://gitlab.com/gitlab-radiator-test/integration-test-project-1/-/jobs/932213326'
374
+ }
375
+ ]
376
+ }
377
+ ]
378
+ }
379
+ ],
380
+ status: 'success'
381
+ }]
382
+ )
383
+ })
384
+ })
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
+ })