Skip to content

Commit 9e7b674

Browse files
authored
update gitbeaker in cicd-statistics and scaffolder-relation-processor (#7620)
* update gitbeaker in cicd-statistics and scaffolder-relation-processor Signed-off-by: Kashish Mittal <kmittal@redhat.com> * add changeset Signed-off-by: Kashish Mittal <kmittal@redhat.com> * fix duplicates in scaffolder-relation-processor lockfile Signed-off-by: Kashish Mittal <kmittal@redhat.com> * update api reports Signed-off-by: Kashish Mittal <kmittal@redhat.com> * yarn dedupe Signed-off-by: Kashish Mittal <kmittal@redhat.com> --------- Signed-off-by: Kashish Mittal <kmittal@redhat.com>
1 parent 7eb9734 commit 9e7b674

11 files changed

Lines changed: 110 additions & 142 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@backstage-community/plugin-cicd-statistics-module-gitlab': patch
3+
---
4+
5+
Updated dependency `@gitbeaker/rest` to `^43.0.0`.
6+
Replaced deprecated `@gitbeaker/browser` with `@gitbeaker/rest`

workspaces/cicd-statistics/plugins/cicd-statistics-module-gitlab/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"@backstage/catalog-model": "backstage:^",
5757
"@backstage/core-plugin-api": "backstage:^",
5858
"@backstage/frontend-plugin-api": "backstage:^",
59-
"@gitbeaker/browser": "^35.6.0",
60-
"@gitbeaker/core": "^35.6.0",
59+
"@gitbeaker/core": "^43.0.0",
60+
"@gitbeaker/rest": "^43.0.0",
6161
"p-limit": "^3.1.0"
6262
},
6363
"devDependencies": {

workspaces/cicd-statistics/plugins/cicd-statistics-module-gitlab/report.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CicdState } from '@backstage-community/plugin-cicd-statistics';
99
import { CicdStatisticsApi } from '@backstage-community/plugin-cicd-statistics';
1010
import { Entity } from '@backstage/catalog-model';
1111
import { FetchBuildsOptions } from '@backstage-community/plugin-cicd-statistics';
12-
import { Gitlab } from '@gitbeaker/browser';
12+
import { Gitlab } from '@gitbeaker/rest';
1313
import { OAuthApi } from '@backstage/core-plugin-api';
1414

1515
// @public

workspaces/cicd-statistics/plugins/cicd-statistics-module-gitlab/src/api/gitlab.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
FetchBuildsOptions,
2424
Stage,
2525
} from '@backstage-community/plugin-cicd-statistics';
26-
import { Gitlab } from '@gitbeaker/browser';
26+
import { Gitlab, JobSchema, PipelineSchema } from '@gitbeaker/rest';
2727
import { OAuthApi } from '@backstage/core-plugin-api';
2828
import limiterFactory from 'p-limit';
2929
import { Entity, getEntitySourceLocation } from '@backstage/catalog-model';
@@ -80,11 +80,10 @@ export class CicdStatisticsApiGitlab implements CicdStatisticsApi {
8080
owner: string,
8181
build: Build,
8282
): Promise<Stage[]> {
83-
const jobs = await gitbeaker.Jobs.showPipelineJobs(
84-
owner,
85-
parseInt(build.id, 10),
86-
);
87-
const stages = jobsToStages(jobs);
83+
const jobs = await gitbeaker.Jobs.all(owner, {
84+
pipelineId: parseInt(build.id, 10),
85+
});
86+
const stages = jobsToStages(jobs as JobSchema[]);
8887
return stages;
8988
}
9089

@@ -97,7 +96,7 @@ export class CicdStatisticsApiGitlab implements CicdStatisticsApi {
9796
owner,
9897
parseInt(build.id, 10),
9998
);
100-
return parseInt(pipeline.duration as string, 10) * 1000;
99+
return pipeline.duration * 1000;
101100
}
102101

103102
private static async getDefaultBranch(
@@ -126,21 +125,23 @@ export class CicdStatisticsApiGitlab implements CicdStatisticsApi {
126125
: undefined;
127126
const pipelines = await api.Pipelines.all(owner, {
128127
perPage: 25,
129-
updated_after: timeFrom.toISOString(),
130-
updated_before: timeTo.toISOString(),
128+
updatedAfter: timeFrom.toISOString(),
129+
updatedBefore: timeTo.toISOString(),
131130
ref: branch,
132131
});
133132

134133
const limiter = limiterFactory(10);
135-
const builds = pipelinesToBuilds(pipelines).map(async build => ({
136-
...build,
137-
duration: await limiter(() =>
138-
CicdStatisticsApiGitlab.getDurationOfBuild(api, owner, build),
139-
),
140-
stages: await limiter(() =>
141-
CicdStatisticsApiGitlab.updateBuildWithStages(api, owner, build),
142-
),
143-
}));
134+
const builds = pipelinesToBuilds(pipelines as PipelineSchema[]).map(
135+
async build => ({
136+
...build,
137+
duration: await limiter(() =>
138+
CicdStatisticsApiGitlab.getDurationOfBuild(api, owner, build),
139+
),
140+
stages: await limiter(() =>
141+
CicdStatisticsApiGitlab.updateBuildWithStages(api, owner, build),
142+
),
143+
}),
144+
);
144145
const promisedBuilds = (await Promise.all(builds)).filter(b =>
145146
filterStatus.includes(b.status),
146147
);

workspaces/cicd-statistics/plugins/cicd-statistics-module-gitlab/src/api/utils.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
import { pipelinesToBuilds, jobsToStages } from './utils';
18-
import { Types } from '@gitbeaker/core';
18+
import { PipelineSchema, JobSchema } from '@gitbeaker/core';
1919

20-
const pipelineMock: Types.PipelineSchema[] = [
20+
const pipelineMock: PipelineSchema[] = [
2121
{
2222
id: 1000,
2323
iid: 1,
@@ -52,7 +52,7 @@ const jobMock = [
5252
duration: 21.199465,
5353
queued_duration: 0.976313,
5454
},
55-
] as unknown as Array<Types.JobSchema>;
55+
] as unknown as Array<JobSchema>;
5656

5757
describe('util functionality', () => {
5858
it('transforms the pipeline object to the build object', () => {

workspaces/cicd-statistics/plugins/cicd-statistics-module-gitlab/src/api/utils.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
TriggerReason,
2121
Stage,
2222
} from '@backstage-community/plugin-cicd-statistics';
23-
import { Types } from '@gitbeaker/core';
23+
import { PipelineSchema, JobSchema } from '@gitbeaker/core';
2424

2525
const statusMap: Record<string, FilterStatusType> = {
2626
manual: 'unknown',
@@ -51,9 +51,7 @@ const triggerReasonMap: Record<string, TriggerReason> = {
5151
*
5252
* @public
5353
*/
54-
export function pipelinesToBuilds(
55-
pipelines: Array<Types.PipelineSchema>,
56-
): Build[] {
54+
export function pipelinesToBuilds(pipelines: Array<PipelineSchema>): Build[] {
5755
return pipelines.map(pipeline => {
5856
return {
5957
id: pipeline.id.toString(),
@@ -84,7 +82,7 @@ export function pipelinesToBuilds(
8482
* Furthermore, we don't add the job to the sub-stage if it is has the same name as the parent stage
8583
* We then assume that the stage has no sub-stages
8684
*/
87-
export function jobsToStages(jobs: Array<Types.JobSchema>): Stage[] {
85+
export function jobsToStages(jobs: Array<JobSchema>): Stage[] {
8886
return jobs.map(job => {
8987
const status = statusMap[job.status] ? statusMap[job.status] : 'unknown';
9088
const duration = job.duration ? ((job.duration * 1000) as number) : 0;

workspaces/cicd-statistics/plugins/cicd-statistics/report-alpha.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ const _default: OverridableFrontendPlugin<
8888
defaultGroup?: [Error: "Use the 'group' param instead"] | undefined;
8989
group?:
9090
| (string & {})
91+
| 'development'
9192
| 'overview'
9293
| 'documentation'
93-
| 'development'
9494
| 'deployment'
9595
| 'operation'
9696
| 'observability'

workspaces/cicd-statistics/yarn.lock

Lines changed: 36 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,8 +1410,8 @@ __metadata:
14101410
"@backstage/cli": "backstage:^"
14111411
"@backstage/core-plugin-api": "backstage:^"
14121412
"@backstage/frontend-plugin-api": "backstage:^"
1413-
"@gitbeaker/browser": "npm:^35.6.0"
1414-
"@gitbeaker/core": "npm:^35.6.0"
1413+
"@gitbeaker/core": "npm:^43.0.0"
1414+
"@gitbeaker/rest": "npm:^43.0.0"
14151415
"@types/react": "npm:^16.13.1 || ^17.0.0"
14161416
"@types/react-dom": "npm:^18.2.19"
14171417
p-limit: "npm:^3.1.0"
@@ -4229,40 +4229,36 @@ __metadata:
42294229
languageName: node
42304230
linkType: hard
42314231

4232-
"@gitbeaker/browser@npm:^35.6.0":
4233-
version: 35.8.1
4234-
resolution: "@gitbeaker/browser@npm:35.8.1"
4232+
"@gitbeaker/core@npm:^43.0.0, @gitbeaker/core@npm:^43.8.0":
4233+
version: 43.8.0
4234+
resolution: "@gitbeaker/core@npm:43.8.0"
42354235
dependencies:
4236-
"@gitbeaker/core": "npm:^35.8.1"
4237-
"@gitbeaker/requester-utils": "npm:^35.8.1"
4238-
delay: "npm:^5.0.0"
4239-
ky: "npm:0.28.7"
4240-
checksum: 10/92cd70614789bbe225ddfbbcd17ea0b002c2eca9019b11c324ac11899b77d00c7b6ec5bc16b44e83150315d603d5a3feaaeb7b52e3edd86886557103c344fe20
4236+
"@gitbeaker/requester-utils": "npm:^43.8.0"
4237+
qs: "npm:^6.14.0"
4238+
xcase: "npm:^2.0.1"
4239+
checksum: 10/1c935ffec246c854d7d543cc4ccb97271c322ea506c02ccf60774bffd42462c36cd3324d6876082da706d25e444878f76714746b1fbd77c202b0e3766ef5f4ae
42414240
languageName: node
42424241
linkType: hard
42434242

4244-
"@gitbeaker/core@npm:^35.6.0, @gitbeaker/core@npm:^35.8.1":
4245-
version: 35.8.1
4246-
resolution: "@gitbeaker/core@npm:35.8.1"
4243+
"@gitbeaker/requester-utils@npm:^43.8.0":
4244+
version: 43.8.0
4245+
resolution: "@gitbeaker/requester-utils@npm:43.8.0"
42474246
dependencies:
4248-
"@gitbeaker/requester-utils": "npm:^35.8.1"
4249-
form-data: "npm:^4.0.0"
4250-
li: "npm:^1.3.0"
4251-
mime: "npm:^3.0.0"
4252-
query-string: "npm:^7.0.0"
4247+
picomatch-browser: "npm:^2.2.6"
4248+
qs: "npm:^6.14.0"
4249+
rate-limiter-flexible: "npm:^8.0.1"
42534250
xcase: "npm:^2.0.1"
4254-
checksum: 10/5e3eda56f74678ceaec6d494318a0fa9b20d587f307e4d269206cf3ffb6363c8361effd43ef465f7b19f467d7a2caea0e95705a5af88c0bede06bfd897a463f0
4251+
checksum: 10/529685994676068a18f4bf6329252c66a62c1ef160f6e9d4b3a916330189cc1628fb30c983625d38295cef2999438e14ecb611fcd8a484b7c479b6dcf29f7679
42554252
languageName: node
42564253
linkType: hard
42574254

4258-
"@gitbeaker/requester-utils@npm:^35.8.1":
4259-
version: 35.8.1
4260-
resolution: "@gitbeaker/requester-utils@npm:35.8.1"
4255+
"@gitbeaker/rest@npm:^43.0.0":
4256+
version: 43.8.0
4257+
resolution: "@gitbeaker/rest@npm:43.8.0"
42614258
dependencies:
4262-
form-data: "npm:^4.0.0"
4263-
qs: "npm:^6.10.1"
4264-
xcase: "npm:^2.0.1"
4265-
checksum: 10/f939216443682303b80b72fa59158cf3fb4a95d31251bb0b4cffa83bd0e0ad0e949645aaaa08fe4dfcd7d06ea5a1547e5688c02b608e8bc76b1e12286935c265
4259+
"@gitbeaker/core": "npm:^43.8.0"
4260+
"@gitbeaker/requester-utils": "npm:^43.8.0"
4261+
checksum: 10/a29493ee1e0e789a0fa4307108c616bb287f33a390262a57025461140a284ae1284918ff4d4e91d3351e61b050eea55ffe2ca7551ffcb6be29ae22c67136a463
42664262
languageName: node
42674263
linkType: hard
42684264

@@ -15336,13 +15332,6 @@ __metadata:
1533615332
languageName: node
1533715333
linkType: hard
1533815334

15339-
"decode-uri-component@npm:^0.2.2":
15340-
version: 0.2.2
15341-
resolution: "decode-uri-component@npm:0.2.2"
15342-
checksum: 10/17a0e5fa400bf9ea84432226e252aa7b5e72793e16bf80b907c99b46a799aeacc139ec20ea57121e50c7bd875a1a4365928f884e92abf02e21a5a13790a0f33e
15343-
languageName: node
15344-
linkType: hard
15345-
1534615335
"decompress-response@npm:^6.0.0":
1534715336
version: 6.0.0
1534815337
resolution: "decompress-response@npm:6.0.0"
@@ -15488,13 +15477,6 @@ __metadata:
1548815477
languageName: node
1548915478
linkType: hard
1549015479

15491-
"delay@npm:^5.0.0":
15492-
version: 5.0.0
15493-
resolution: "delay@npm:5.0.0"
15494-
checksum: 10/62f151151ecfde0d9afbb8a6be37a6d103c4cb24f35a20ef3fe56f920b0d0d0bb02bc9c0a3084d0179ef669ca332b91155f2ee4d9854622cd2cdba5fc95285f9
15495-
languageName: node
15496-
linkType: hard
15497-
1549815480
"delayed-stream@npm:~1.0.0":
1549915481
version: 1.0.0
1550015482
resolution: "delayed-stream@npm:1.0.0"
@@ -17187,13 +17169,6 @@ __metadata:
1718717169
languageName: node
1718817170
linkType: hard
1718917171

17190-
"filter-obj@npm:^1.1.0":
17191-
version: 1.1.0
17192-
resolution: "filter-obj@npm:1.1.0"
17193-
checksum: 10/9d681939eec2b4b129cb4f307b7e93d954a0657421d4e5357d86093b26d3f4f570909ed43717dcfd62428b3cf8cddd9841b35f9d40d12ac62cfabaa677942593
17194-
languageName: node
17195-
linkType: hard
17196-
1719717172
"finalhandler@npm:1.1.2":
1719817173
version: 1.1.2
1719917174
resolution: "finalhandler@npm:1.1.2"
@@ -20503,13 +20478,6 @@ __metadata:
2050320478
languageName: node
2050420479
linkType: hard
2050520480

20506-
"ky@npm:0.28.7":
20507-
version: 0.28.7
20508-
resolution: "ky@npm:0.28.7"
20509-
checksum: 10/d9d8da51a337943c6133d4188f9e895ff17280cdb40f012213a9fbfbe9e66116dbeaa36372cc676fe01b98120161e83bb400ee6a6afbda4fb5ef8f66669ce8b0
20510-
languageName: node
20511-
linkType: hard
20512-
2051320481
"language-subtag-registry@npm:^0.3.20":
2051420482
version: 0.3.23
2051520483
resolution: "language-subtag-registry@npm:0.3.23"
@@ -20572,13 +20540,6 @@ __metadata:
2057220540
languageName: node
2057320541
linkType: hard
2057420542

20575-
"li@npm:^1.3.0":
20576-
version: 1.3.0
20577-
resolution: "li@npm:1.3.0"
20578-
checksum: 10/825a1e132da5263e16cf24df92b787c5030c6549be66a8b2087e74ca56474aa681183f3a11b5f14e61d5d583af5f776ecf3b320ad689842511f36030339f6a0c
20579-
languageName: node
20580-
linkType: hard
20581-
2058220543
"lilconfig@npm:^2.0.3, lilconfig@npm:^2.0.5":
2058320544
version: 2.1.0
2058420545
resolution: "lilconfig@npm:2.1.0"
@@ -23655,6 +23616,13 @@ __metadata:
2365523616
languageName: node
2365623617
linkType: hard
2365723618

23619+
"picomatch-browser@npm:^2.2.6":
23620+
version: 2.2.6
23621+
resolution: "picomatch-browser@npm:2.2.6"
23622+
checksum: 10/0136abee4bbef256e9b6b20676873807e11cc6d04d52d4cd4e9e5c7b48b0888e67f224873eb7eaba6da2a5356647e5aa9a2ef62ad98a675c7940344bfae0238e
23623+
languageName: node
23624+
linkType: hard
23625+
2365823626
"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.3, picomatch@npm:^2.3.1":
2365923627
version: 2.3.1
2366023628
resolution: "picomatch@npm:2.3.1"
@@ -24538,18 +24506,6 @@ __metadata:
2453824506
languageName: node
2453924507
linkType: hard
2454024508

24541-
"query-string@npm:^7.0.0":
24542-
version: 7.1.3
24543-
resolution: "query-string@npm:7.1.3"
24544-
dependencies:
24545-
decode-uri-component: "npm:^0.2.2"
24546-
filter-obj: "npm:^1.1.0"
24547-
split-on-first: "npm:^1.0.0"
24548-
strict-uri-encode: "npm:^2.0.0"
24549-
checksum: 10/3b6f2c167e76ca4094c5f1a9eb276efcbb9ebfd8b1a28c413f3c4e4e7d6428c8187bf46c8cbc9f92a229369dd0015de10a7fd712c8cee98d5d84c2ac6140357e
24550-
languageName: node
24551-
linkType: hard
24552-
2455324509
"querystring-es3@npm:^0.2.1":
2455424510
version: 0.2.1
2455524511
resolution: "querystring-es3@npm:0.2.1"
@@ -24667,6 +24623,13 @@ __metadata:
2466724623
languageName: node
2466824624
linkType: hard
2466924625

24626+
"rate-limiter-flexible@npm:^8.0.1":
24627+
version: 8.3.0
24628+
resolution: "rate-limiter-flexible@npm:8.3.0"
24629+
checksum: 10/9c8d7a3224e3a57fdf7da721dabdb4942eb7dd7b5f3aa4cd57e2185928d5842855a8dc2e1db5e0403987d369972d0567e98aade2c2daa71436ebdae704e5a8ff
24630+
languageName: node
24631+
linkType: hard
24632+
2467024633
"raw-body@npm:^2.4.1, raw-body@npm:~2.5.3":
2467124634
version: 2.5.3
2467224635
resolution: "raw-body@npm:2.5.3"
@@ -26861,13 +26824,6 @@ __metadata:
2686126824
languageName: node
2686226825
linkType: hard
2686326826

26864-
"split-on-first@npm:^1.0.0":
26865-
version: 1.1.0
26866-
resolution: "split-on-first@npm:1.1.0"
26867-
checksum: 10/16ff85b54ddcf17f9147210a4022529b343edbcbea4ce977c8f30e38408b8d6e0f25f92cd35b86a524d4797f455e29ab89eb8db787f3c10708e0b47ebf528d30
26868-
languageName: node
26869-
linkType: hard
26870-
2687126827
"split2@npm:^4.1.0":
2687226828
version: 4.2.0
2687326829
resolution: "split2@npm:4.2.0"
@@ -27082,13 +27038,6 @@ __metadata:
2708227038
languageName: node
2708327039
linkType: hard
2708427040

27085-
"strict-uri-encode@npm:^2.0.0":
27086-
version: 2.0.0
27087-
resolution: "strict-uri-encode@npm:2.0.0"
27088-
checksum: 10/eaac4cf978b6fbd480f1092cab8b233c9b949bcabfc9b598dd79a758f7243c28765ef7639c876fa72940dac687181b35486ea01ff7df3e65ce3848c64822c581
27089-
languageName: node
27090-
linkType: hard
27091-
2709227041
"string-argv@npm:~0.3.1":
2709327042
version: 0.3.2
2709427043
resolution: "string-argv@npm:0.3.2"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor': patch
3+
---
4+
5+
Updated dependency `@gitbeaker/rest` to `^43.0.0`.

workspaces/scaffolder-relation-processor/plugins/catalog-backend-module-scaffolder-relation-processor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@backstage/plugin-events-node": "^0.4.18",
4949
"@backstage/plugin-notifications-common": "^0.2.0",
5050
"@backstage/plugin-notifications-node": "^0.2.22",
51-
"@gitbeaker/rest": "^42.0.0",
51+
"@gitbeaker/rest": "^43.0.0",
5252
"@octokit/core": "^6.0.0",
5353
"git-url-parse": "^16.1.0",
5454
"octokit-plugin-create-pull-request": "^6.0.1"

0 commit comments

Comments
 (0)