-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(datasource/custom): Support digest in custom datasource #26299
Changes from all commits
08edb90
e04f88f
3f379ba
0eabe34
a318a24
3e55527
981f0af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,7 +2,7 @@ import is from '@sindresorhus/is'; | |||
import jsonata from 'jsonata'; | ||||
import { logger } from '../../../logger'; | ||||
import { Datasource } from '../datasource'; | ||||
import type { GetReleasesConfig, ReleaseResult } from '../types'; | ||||
import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types'; | ||||
import { fetchers } from './formats'; | ||||
import { ReleaseResultZodSchema } from './schema'; | ||||
import { getCustomConfig } from './utils'; | ||||
|
@@ -57,4 +57,13 @@ export class CustomDatasource extends Datasource { | |||
return null; | ||||
} | ||||
} | ||||
|
||||
override getDigest( | ||||
{ packageName }: DigestConfig, | ||||
newValue?: string, | ||||
): Promise<string | null> { | ||||
// Return null here to support setting a digest: value can be provided digest in getReleases | ||||
// istanbul ignore next | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
return Promise.resolve(null); | ||||
} | ||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||||||||||||||||||||||||||||||||||||||||
import { partial } from '../../../../../test/util'; | ||||||||||||||||||||||||||||||||||||||||||||
import { getConfig } from '../../../../config/defaults'; | ||||||||||||||||||||||||||||||||||||||||||||
import { CONFIG_VALIDATION } from '../../../../constants/error-messages'; | ||||||||||||||||||||||||||||||||||||||||||||
import { CustomDatasource } from '../../../../modules/datasource/custom'; | ||||||||||||||||||||||||||||||||||||||||||||
import { DockerDatasource } from '../../../../modules/datasource/docker'; | ||||||||||||||||||||||||||||||||||||||||||||
import { GitRefsDatasource } from '../../../../modules/datasource/git-refs'; | ||||||||||||||||||||||||||||||||||||||||||||
import { GithubReleasesDatasource } from '../../../../modules/datasource/github-releases'; | ||||||||||||||||||||||||||||||||||||||||||||
|
@@ -62,6 +63,11 @@ | |||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
const getMavenReleases = jest.spyOn(MavenDatasource.prototype, 'getReleases'); | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
const getCustomDatasourceReleases = jest.spyOn( | ||||||||||||||||||||||||||||||||||||||||||||
CustomDatasource.prototype, | ||||||||||||||||||||||||||||||||||||||||||||
'getReleases', | ||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
const getDockerDigest = jest.spyOn(DockerDatasource.prototype, 'getDigest'); | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
beforeEach(() => { | ||||||||||||||||||||||||||||||||||||||||||||
|
@@ -3849,6 +3855,31 @@ | |||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
it('handles digest update for custom datasource', async () => { | ||||||||||||||||||||||||||||||||||||||||||||
config.currentValue = '1.0.0'; | ||||||||||||||||||||||||||||||||||||||||||||
config.packageName = 'my-package'; | ||||||||||||||||||||||||||||||||||||||||||||
config.datasource = CustomDatasource.id; | ||||||||||||||||||||||||||||||||||||||||||||
config.currentDigest = 'zzzzzzzzzzzzzzz'; | ||||||||||||||||||||||||||||||||||||||||||||
getCustomDatasourceReleases.mockResolvedValueOnce({ | ||||||||||||||||||||||||||||||||||||||||||||
releases: [ | ||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||
version: '1.0.0', | ||||||||||||||||||||||||||||||||||||||||||||
newDigest: '0123456789abcdef', | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
const res = await lookup.lookupUpdates(config); | ||||||||||||||||||||||||||||||||||||||||||||
expect(res).toMatchObject({ | ||||||||||||||||||||||||||||||||||||||||||||
Check failure on line 3872 in lib/workers/repository/process/lookup/index.spec.ts GitHub Actions / test (10/16)workers/repository/process/lookup/index › .lookupUpdates() › handles digest update for custom datasource
|
||||||||||||||||||||||||||||||||||||||||||||
updates: [ | ||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||
newDigest: '0123456789abcdef', | ||||||||||||||||||||||||||||||||||||||||||||
newValue: '1.0.0', | ||||||||||||||||||||||||||||||||||||||||||||
updateType: 'digest', | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+3871
to
+3880
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
it('handles digest update for non-version', async () => { | ||||||||||||||||||||||||||||||||||||||||||||
config.currentValue = 'alpine'; | ||||||||||||||||||||||||||||||||||||||||||||
config.packageName = 'node'; | ||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed, it seems there's a test for it
This comment was marked as outdated.
Sorry, something went wrong.