Skip to content

Commit

Permalink
Merge branch 'feat/datasource-release-interception' into feat/maven-r…
Browse files Browse the repository at this point in the history
…elease-post-fetch-check
  • Loading branch information
zharinov committed Sep 7, 2024
2 parents 718f187 + a4686d8 commit daf40aa
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
12 changes: 6 additions & 6 deletions lib/modules/datasource/postprocess-release.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('modules/datasource/postprocess-release', () => {
expect(release).toBe(releaseOrig);
});

it('returns original release for datasource with missing `interceptRelease` method', async () => {
it('returns original release for datasource with missing `postprocessRelease` method', async () => {
const releaseOrig: Release = { version: '1.2.3' };
getDatasourceFor.mockReturnValueOnce(new DummyDatasource());

Expand All @@ -53,11 +53,11 @@ describe('modules/datasource/postprocess-release', () => {
expect(release).toBe(releaseOrig);
});

it('updates release via `interceptRelease` method', async () => {
it('updates release via `postprocessRelease` method', async () => {
const releaseOrig: Release = { version: '1.2.3' };

class SomeDatasource extends DummyDatasource {
interceptRelease(
postprocessRelease(
_config: PostprocessReleaseConfig,
release: Release,
): Promise<Release | null> {
Expand All @@ -78,11 +78,11 @@ describe('modules/datasource/postprocess-release', () => {
});
});

it('rejects release via `interceptRelease` method', async () => {
it('rejects release via `postprocessRelease` method', async () => {
const releaseOrig: Release = { version: '1.2.3' };

class SomeDatasource extends DummyDatasource {
interceptRelease(
postprocessRelease(
_config: PostprocessReleaseConfig,
_release: Release,
): Promise<Release | null> {
Expand All @@ -103,7 +103,7 @@ describe('modules/datasource/postprocess-release', () => {
const releaseOrig: Release = { version: '1.2.3' };

class SomeDatasource extends DummyDatasource {
interceptRelease(
postprocessRelease(
_config: PostprocessReleaseConfig,
_release: Release,
): Promise<Release | null> {
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/datasource/postprocess-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ export async function postprocessRelease(
return release;
}

if (!ds.interceptRelease) {
if (!ds.postprocessRelease) {
return release;
}

try {
const result = await ds.interceptRelease(
const result = await ds.postprocessRelease(
{
packageName: config.packageName,
registryUrl: config.registryUrl,
currentValue: config.currentValue,
},
release,
);
Expand Down
5 changes: 2 additions & 3 deletions lib/modules/datasource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export interface PostprocessReleaseConfig {
datasource?: string;
packageName?: string;
registryUrl?: string;
currentValue?: string;
}

export type RegistryStrategy = 'first' | 'hunt' | 'merge';
Expand Down Expand Up @@ -153,9 +152,9 @@ export interface DatasourceApi extends ModuleApi {
* via some datasource-specific external call.
*
* In case of reject, the next candidate release is selected,
* and `interceptRelease` is called again.
* and `postprocessRelease` is called again.
*/
interceptRelease?(
postprocessRelease?(
config: PostprocessReleaseConfig,
release: Release,
): Promise<Release | null>;
Expand Down
18 changes: 9 additions & 9 deletions lib/workers/repository/process/lookup/filter-checks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeFalse();
expect(res.pendingReleases).toHaveLength(0);
expect(res.release.version).toBe('1.0.4');
expect(res.release?.version).toBe('1.0.4');
});

it('uses datasource-level interception mechanism', async () => {
config.datasource = 'some-datasource';
config.internalChecksFilter = 'strict';

class SomeDatasource extends DummyDatasource {
interceptRelease(
postprocessRelease(
_: PostprocessReleaseConfig,
release: Release,
): Promise<Release | null> {
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeFalse();
expect(res.pendingReleases).toHaveLength(0);
expect(res.release.version).toBe('1.0.4');
expect(res.release?.version).toBe('1.0.4');
});

it('returns pending latest release if internalChecksFilter=strict and none pass checks', async () => {
Expand All @@ -144,7 +144,7 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeTrue();
expect(res.pendingReleases).toHaveLength(0);
expect(res.release.version).toBe('1.0.4');
expect(res.release?.version).toBe('1.0.4');
});

it('returns non-latest release if internalChecksFilter=strict and some pass checks', async () => {
Expand All @@ -159,7 +159,7 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeFalse();
expect(res.pendingReleases).toHaveLength(2);
expect(res.release.version).toBe('1.0.2');
expect(res.release?.version).toBe('1.0.2');
});

it('returns non-latest release if internalChecksFilter=flexible and some pass checks', async () => {
Expand All @@ -174,7 +174,7 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeFalse();
expect(res.pendingReleases).toHaveLength(2);
expect(res.release.version).toBe('1.0.2');
expect(res.release?.version).toBe('1.0.2');
});

it('picks up minimumReleaseAge settings from hostRules', async () => {
Expand All @@ -192,7 +192,7 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeFalse();
expect(res.pendingReleases).toHaveLength(0);
expect(res.release.version).toBe('1.0.4');
expect(res.release?.version).toBe('1.0.4');
});

it('picks up minimumReleaseAge settings from updateType', async () => {
Expand All @@ -207,7 +207,7 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeFalse();
expect(res.pendingReleases).toHaveLength(1);
expect(res.release.version).toBe('1.0.3');
expect(res.release?.version).toBe('1.0.3');
});

it('picks up minimumConfidence settings from updateType', async () => {
Expand All @@ -227,7 +227,7 @@ describe('workers/repository/process/lookup/filter-checks', () => {
expect(res).toMatchSnapshot();
expect(res.pendingChecks).toBeFalse();
expect(res.pendingReleases).toHaveLength(3);
expect(res.release.version).toBe('1.0.1');
expect(res.release?.version).toBe('1.0.1');
});
});
});
5 changes: 2 additions & 3 deletions lib/workers/repository/process/lookup/filter-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { LookupUpdateConfig, UpdateResult } from './types';
import { getUpdateType } from './update-type';

export interface InternalChecksResult {
release: Release;
release?: Release;
pendingChecks: boolean;
pendingReleases?: Release[];
}
Expand Down Expand Up @@ -128,6 +128,5 @@ export async function filterInternalChecks(
}
}

// TODO #22198
return { release: release!, pendingChecks, pendingReleases };
return { release, pendingChecks, pendingReleases };
}

0 comments on commit daf40aa

Please sign in to comment.