From 7e8256eb832221f8e91ed3265f59720386442c07 Mon Sep 17 00:00:00 2001 From: Mike Glazer Date: Thu, 19 Dec 2024 07:53:53 -0800 Subject: [PATCH 1/3] minor: Add support for internal CircleCI Registries --- .../orb/__snapshots__/index.spec.ts.snap | 53 ++++++++++++++++++- lib/modules/datasource/orb/index.spec.ts | 14 +++++ lib/modules/datasource/orb/index.ts | 8 ++- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap b/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap index b3583fe0121db5..8e14604934a922 100644 --- a/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap +++ b/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap @@ -4,7 +4,7 @@ exports[`modules/datasource/orb/index getReleases processes homeUrl 1`] = ` { "homepage": "https://google.com", "isPrivate": false, - "registryUrl": "https://circleci.com/", + "registryUrl": "https://circleci.com", "releases": [ { "releaseTimestamp": "2018-12-11T05:28:14.080Z", @@ -53,7 +53,56 @@ exports[`modules/datasource/orb/index getReleases processes real data 1`] = ` { "homepage": "https://circleci.com/developer/orbs/orb/hyper-expanse/library-release-workflows", "isPrivate": false, - "registryUrl": "https://circleci.com/", + "registryUrl": "https://circleci.com", + "releases": [ + { + "releaseTimestamp": "2018-12-11T05:28:14.080Z", + "version": "3.0.0", + }, + { + "releaseTimestamp": "2018-12-11T17:41:26.595Z", + "version": "4.0.0", + }, + { + "releaseTimestamp": "2018-12-11T18:14:41.116Z", + "version": "4.1.0", + }, + { + "version": "4.1.1", + }, + { + "releaseTimestamp": "2018-12-11T21:28:37.846Z", + "version": "4.1.2", + }, + { + "releaseTimestamp": "2018-12-11T21:40:44.870Z", + "version": "4.1.3", + }, + { + "releaseTimestamp": "2018-12-11T22:13:29.297Z", + "version": "4.1.4", + }, + { + "releaseTimestamp": "2018-12-12T17:13:31.542Z", + "version": "4.1.5", + }, + { + "releaseTimestamp": "2018-12-12T18:56:42.563Z", + "version": "4.1.6", + }, + { + "releaseTimestamp": "2018-12-13T23:19:09.356Z", + "version": "4.2.0", + }, + ], +} +`; + +exports[`modules/datasource/orb/index getReleases supports other registries 1`] = ` +{ + "homepage": "https://google.com", + "isPrivate": false, + "registryUrl": "https://cci.internal.dev", "releases": [ { "releaseTimestamp": "2018-12-11T05:28:14.080Z", diff --git a/lib/modules/datasource/orb/index.spec.ts b/lib/modules/datasource/orb/index.spec.ts index e2dd13dd7b817c..fb5bd1cfed638f 100644 --- a/lib/modules/datasource/orb/index.spec.ts +++ b/lib/modules/datasource/orb/index.spec.ts @@ -92,5 +92,19 @@ describe('modules/datasource/orb/index', () => { expect(res).toMatchSnapshot(); expect(res?.homepage).toBe('https://google.com'); }); + + it('supports other registries', async () => { + httpMock + .scope('https://cci.internal.dev') + .post('/graphql-unstable') + .reply(200, orbData); + const res = await getPkgReleases({ + datasource, + packageName: 'hyper-expanse/library-release-workflows', + registryUrls: ['https://cci.internal.dev'], + }); + expect(res).toMatchSnapshot(); + expect(res).not.toBeNull(); + }); }); }); diff --git a/lib/modules/datasource/orb/index.ts b/lib/modules/datasource/orb/index.ts index 12e3bc834d5eee..9881071e739405 100644 --- a/lib/modules/datasource/orb/index.ts +++ b/lib/modules/datasource/orb/index.ts @@ -27,9 +27,10 @@ export class OrbDatasource extends Datasource { super(OrbDatasource.id); } - override readonly customRegistrySupport = false; + override readonly customRegistrySupport = true; override readonly defaultRegistryUrls = ['https://circleci.com/']; + override readonly registryStrategy = 'merge'; override readonly releaseTimestampSupport = true; override readonly releaseTimestampNote = @@ -47,7 +48,10 @@ export class OrbDatasource extends Datasource { if (!registryUrl) { return null; } - const url = `${registryUrl}graphql-unstable`; + const path = registryUrl.endsWith('/') + ? 'graphql-unstable' + : '/graphql-unstable'; + const url = `${registryUrl}${path}`; const body = { query, variables: { packageName, maxVersions: MAX_VERSIONS }, From b8b0607b01545af1a5f90fd2ada2bd3bbd7d84e2 Mon Sep 17 00:00:00 2001 From: Mike Glazer Date: Thu, 19 Dec 2024 15:03:54 -0800 Subject: [PATCH 2/3] CR --- .../orb/__snapshots__/index.spec.ts.snap | 49 ------------------- lib/modules/datasource/orb/index.spec.ts | 2 +- lib/modules/datasource/orb/index.ts | 8 ++- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap b/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap index 8e14604934a922..b6f1650795302d 100644 --- a/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap +++ b/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap @@ -97,52 +97,3 @@ exports[`modules/datasource/orb/index getReleases processes real data 1`] = ` ], } `; - -exports[`modules/datasource/orb/index getReleases supports other registries 1`] = ` -{ - "homepage": "https://google.com", - "isPrivate": false, - "registryUrl": "https://cci.internal.dev", - "releases": [ - { - "releaseTimestamp": "2018-12-11T05:28:14.080Z", - "version": "3.0.0", - }, - { - "releaseTimestamp": "2018-12-11T17:41:26.595Z", - "version": "4.0.0", - }, - { - "releaseTimestamp": "2018-12-11T18:14:41.116Z", - "version": "4.1.0", - }, - { - "version": "4.1.1", - }, - { - "releaseTimestamp": "2018-12-11T21:28:37.846Z", - "version": "4.1.2", - }, - { - "releaseTimestamp": "2018-12-11T21:40:44.870Z", - "version": "4.1.3", - }, - { - "releaseTimestamp": "2018-12-11T22:13:29.297Z", - "version": "4.1.4", - }, - { - "releaseTimestamp": "2018-12-12T17:13:31.542Z", - "version": "4.1.5", - }, - { - "releaseTimestamp": "2018-12-12T18:56:42.563Z", - "version": "4.1.6", - }, - { - "releaseTimestamp": "2018-12-13T23:19:09.356Z", - "version": "4.2.0", - }, - ], -} -`; diff --git a/lib/modules/datasource/orb/index.spec.ts b/lib/modules/datasource/orb/index.spec.ts index fb5bd1cfed638f..e78df32d7be8a5 100644 --- a/lib/modules/datasource/orb/index.spec.ts +++ b/lib/modules/datasource/orb/index.spec.ts @@ -103,8 +103,8 @@ describe('modules/datasource/orb/index', () => { packageName: 'hyper-expanse/library-release-workflows', registryUrls: ['https://cci.internal.dev'], }); - expect(res).toMatchSnapshot(); expect(res).not.toBeNull(); + expect(res?.registryUrl).toBe('https://cci.internal.dev'); }); }); }); diff --git a/lib/modules/datasource/orb/index.ts b/lib/modules/datasource/orb/index.ts index 9881071e739405..80fa61e4e93204 100644 --- a/lib/modules/datasource/orb/index.ts +++ b/lib/modules/datasource/orb/index.ts @@ -1,5 +1,6 @@ import { logger } from '../../../logger'; import { cache } from '../../../util/cache/package/decorator'; +import { joinUrlParts } from '../../../util/url'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; import type { OrbResponse } from './types'; @@ -30,7 +31,7 @@ export class OrbDatasource extends Datasource { override readonly customRegistrySupport = true; override readonly defaultRegistryUrls = ['https://circleci.com/']; - override readonly registryStrategy = 'merge'; + override readonly registryStrategy = 'hunt'; override readonly releaseTimestampSupport = true; override readonly releaseTimestampNote = @@ -48,10 +49,7 @@ export class OrbDatasource extends Datasource { if (!registryUrl) { return null; } - const path = registryUrl.endsWith('/') - ? 'graphql-unstable' - : '/graphql-unstable'; - const url = `${registryUrl}${path}`; + const url = joinUrlParts(registryUrl, 'graphql-unstable'); const body = { query, variables: { packageName, maxVersions: MAX_VERSIONS }, From 8c9d7f41042dcb1779198dc61d62ce389e5ba4b9 Mon Sep 17 00:00:00 2001 From: Mike Glazer Date: Fri, 20 Dec 2024 07:45:15 -0800 Subject: [PATCH 3/3] Update lib/modules/datasource/orb/index.spec.ts Co-authored-by: Michael Kriese --- lib/modules/datasource/orb/index.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/modules/datasource/orb/index.spec.ts b/lib/modules/datasource/orb/index.spec.ts index e78df32d7be8a5..1cb1e8519d4ac5 100644 --- a/lib/modules/datasource/orb/index.spec.ts +++ b/lib/modules/datasource/orb/index.spec.ts @@ -103,7 +103,6 @@ describe('modules/datasource/orb/index', () => { packageName: 'hyper-expanse/library-release-workflows', registryUrls: ['https://cci.internal.dev'], }); - expect(res).not.toBeNull(); expect(res?.registryUrl).toBe('https://cci.internal.dev'); }); });