Skip to content

Commit

Permalink
feat(datasource): sourceUrl & releaseTimestamp support (#29122)
Browse files Browse the repository at this point in the history
  • Loading branch information
RahulGautamSingh committed May 21, 2024
1 parent 3c75e4b commit d0b77e5
Show file tree
Hide file tree
Showing 53 changed files with 338 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/modules/datasource/artifactory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class ArtifactoryDatasource extends Datasource {

override readonly registryStrategy = 'merge';

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the date-like text, next to the version hyperlink tag in the results.';

@cache({
namespace: `datasource-${datasource}`,
key: ({ registryUrl, packageName }: GetReleasesConfig) =>
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/aws-machine-image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class AwsMachineImageDataSource extends Datasource {

override readonly caching = true;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `CreationDate` field in the results.';

override readonly defaultConfig = {
// Because AMIs don't follow any versioning scheme, we override commitMessageExtra to remove the 'v'
commitMessageExtra: 'to {{{newVersion}}}',
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/bitbucket-tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export class BitbucketTagsDatasource extends Datasource {

static readonly defaultRegistryUrls = ['https://bitbucket.org'];

static readonly releaseTimestampSupport = true;
static readonly releaseTimestampNote =
'The release timestamp is determined from the `date` field in the results.';
static readonly sourceUrlSupport = 'package';
static readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

static readonly cacheNamespace: PackageCacheNamespace = `datasource-${BitbucketTagsDatasource.id}`;

constructor() {
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/cdnjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class CdnJsDatasource extends Datasource {

override readonly defaultRegistryUrls = ['https://api.cdnjs.com/'];

override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined from the `repository` field in the results.';

@cache({
namespace: `datasource-${CdnJsDatasource.id}`,
key: ({ packageName }: GetReleasesConfig) => packageName.split('/')[0],
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/conan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class ConanDatasource extends Datasource {

githubHttp: GithubHttp;

override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is supported only if the package is served from the Artifactory servers. In which case we determine it from the `properties[conan.package.url]` field in the results.';

constructor(id = ConanDatasource.id) {
super(id);
this.githubHttp = new GithubHttp(id);
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/conda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class CondaDatasource extends Datasource {

override readonly caching = true;

override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined from the `dev_url` field in the results.';

@cache({
namespace: `datasource-${datasource}`,
key: ({ registryUrl, packageName }: GetReleasesConfig) =>
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/cpan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class CpanDatasource extends Datasource {

override readonly defaultVersioning = perlVersioning.id;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `date` field in the results.';

@cache({
namespace: `datasource-${CpanDatasource.id}`,
key: ({ packageName }: GetReleasesConfig) => `${packageName}`,
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/crate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export class CrateDatasource extends Datasource {

static readonly CRATES_IO_API_BASE_URL = 'https://crates.io/api/v1/';

override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined from the `repository` field in the results.';

@cache({
namespace: `datasource-${CrateDatasource.id}`,
key: ({ registryUrl, packageName }: GetReleasesConfig) =>
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/dart-version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class DartVersionDatasource extends Datasource {

private readonly channels = ['stable', 'beta', 'dev'];

override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'We use the URL: https://github.com/dart-lang/sdk.';

async getReleases({
registryUrl,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/dart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export class DartDatasource extends Datasource {

override readonly defaultRegistryUrls = ['https://pub.dartlang.org/'];

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `published` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined from the `repository` field of the latest release object in the results.';

async getReleases({
packageName,
registryUrl,
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
GetReleasesConfig,
RegistryStrategy,
ReleaseResult,
SourceUrlSupport,
} from './types';

export abstract class Datasource implements DatasourceApi {
Expand All @@ -25,6 +26,12 @@ export abstract class Datasource implements DatasourceApi {

registryStrategy: RegistryStrategy | undefined = 'first';

releaseTimestampSupport = false;
releaseTimestampNote?: string | undefined;

sourceUrlSupport: SourceUrlSupport = 'none';
sourceUrlNote?: string | undefined;

protected http: Http;

abstract getReleases(
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/deno/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export class DenoDatasource extends Datasource {

override readonly defaultRegistryUrls = ['https://apiland.deno.dev'];

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `uploaded_at` field in the results.';
override readonly sourceUrlSupport = 'release';
override readonly sourceUrlNote =
'The source URL is determined from the `repository` field in the results.';

constructor() {
super(DenoDatasource.id);
}
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ export class DockerDatasource extends Datasource {

override readonly defaultConfig = defaultConfig;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `tag_last_pushed` field in thre results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined from the `org.opencontainers.image.source` and `org.label-schema.vcs-url` labels present in the metadata of the **latest stable** image found on the Docker registry.';

constructor() {
super(DockerDatasource.id);
}
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/dotnet-version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export class DotnetVersionDatasource extends Datasource {
'https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json',
];

override releaseTimestampSupport = true;
override releaseTimestampNote =
'The release timestamp is determined from the `release-date` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'We use the URL https://github.com/dotnet/sdk for the `dotnet-sdk` package and, the https://github.com/dotnet/runtime URL for the `dotnet-runtime` package.';

@cache({
namespace: `datasource-${DotnetVersionDatasource.id}`,
key: ({ packageName }: GetReleasesConfig) => packageName,
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/endoflife-date/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export class EndoflifeDatePackagesource extends Datasource {
override readonly caching = true;
override readonly defaultVersioning = 'loose';

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `releaseDate` field in the results.';

constructor() {
super(EndoflifeDatePackagesource.id);
}
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/flutter-version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export class FlutterVersionDatasource extends Datasource {

override readonly defaultVersioning = semverId;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `release_date` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'We use the URL: https://github.com/flutter/flutter.';

async getReleases({
registryUrl,
}: GetReleasesConfig): Promise<ReleaseResult | null> {
Expand Down
9 changes: 9 additions & 0 deletions lib/modules/datasource/galaxy-collection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ export class GalaxyCollectionDatasource extends Datasource {

override readonly defaultVersioning = pep440Versioning.id;

override readonly releaseTimestampSupport = true;
override releaseTimestampNote =
'The release timestamp is determined from the `created_at` field in the results.';
// sourceUrl is returned in each release as well as the ReleaseResult
// the one present in release result is the sourceUrl of the latest release
override readonly sourceUrlSupport = 'release';
override readonly sourceUrlNote =
'The `sourceUrl` is determined from the `repository` field in the results.';

@cache({
namespace: `datasource-${GalaxyCollectionDatasource.id}`,
key: ({ packageName }: GetReleasesConfig) => packageName,
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/galaxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export class GalaxyDatasource extends Datasource {

override readonly defaultVersioning = pep440Versioning.id;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `created` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined from the `github_user` and `github_repo` fields in the results.';

@cache({
namespace: 'datasource-galaxy',
key: (getReleasesConfig: GetReleasesConfig) =>
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/git-refs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export class GitRefsDatasource extends GitDatasource {

override readonly customRegistrySupport = false;

override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

@cache({
namespace: `datasource-${GitRefsDatasource.id}`,
key: ({ packageName }: GetReleasesConfig) => packageName,
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/datasource/git-tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export class GitTagsDatasource extends GitDatasource {
}

override readonly customRegistrySupport = false;
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

@cache({
namespace: `datasource-${GitTagsDatasource.id}`,
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/gitea-releases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export class GiteaReleasesDatasource extends Datasource {

private static readonly cacheNamespace: PackageCacheNamespace = `datasource-${GiteaReleasesDatasource.id}`;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `published_at` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

constructor() {
super(GiteaReleasesDatasource.id);
}
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/gitea-tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export class GiteaTagsDatasource extends Datasource {

private static readonly cacheNamespace: PackageCacheNamespace = `datasource-${GiteaTagsDatasource.id}`;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `created` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

constructor() {
super(GiteaTagsDatasource.id);
}
Expand Down
10 changes: 9 additions & 1 deletion lib/modules/datasource/github-release-attachments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export class GithubReleaseAttachmentsDatasource extends Datasource {

override http: GithubHttp;

override readonly releaseTimestampSupport = true;
// Note: not sure
override readonly releaseTimestampNote =
'The release timestamp is determined from the `releaseTimestamp` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

constructor() {
super(GithubReleaseAttachmentsDatasource.id);
this.http = new GithubHttp(GithubReleaseAttachmentsDatasource.id);
Expand Down Expand Up @@ -222,7 +230,7 @@ export class GithubReleaseAttachmentsDatasource extends Datasource {
}

/**
* This function can be used to fetch releases with a customisable versioning
* This function can be used to fetch releases with a customizable versioning
* (e.g. semver) and with releases.
*
* This function will:
Expand Down
8 changes: 8 additions & 0 deletions lib/modules/datasource/github-releases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export class GithubReleasesDatasource extends Datasource {

override http: GithubHttp;

override readonly releaseTimestampSupport = true;
// Note: not sure
override readonly releaseTimestampNote =
'The release timestamp is determined from the `releaseTimestamp` field from the response.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

constructor() {
super(GithubReleasesDatasource.id);
this.http = new GithubHttp(GithubReleasesDatasource.id);
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/github-runners/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
export class GithubRunnersDatasource extends Datasource {
static readonly id = 'github-runners';

override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'We use the URL: https://github.com/actions/runner-images.';

/**
* Only add stable runners to the datasource. See datasource readme for details.
*/
Expand Down
8 changes: 8 additions & 0 deletions lib/modules/datasource/github-tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export class GithubTagsDatasource extends Datasource {

override readonly registryStrategy = 'hunt';

override readonly releaseTimestampSupport = true;
// Note: not sure
override readonly releaseTimestampNote =
'The get release timestamp is determined from the `releaseTimestamp` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

override http: GithubHttp;

constructor() {
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/datasource/gitlab-packages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export class GitlabPackagesDatasource extends Datasource {

override defaultRegistryUrls = ['https://gitlab.com'];

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `created_at` field in the results.';

constructor() {
super(datasource);
this.http = new GitlabHttp(datasource);
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/gitlab-releases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export class GitlabReleasesDatasource extends Datasource {

static readonly registryStrategy = 'first';

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'The release timestamp is determined from the `released_at` field in the results.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

constructor() {
super(GitlabReleasesDatasource.id);
this.http = new GitlabHttp(GitlabReleasesDatasource.id);
Expand Down
7 changes: 7 additions & 0 deletions lib/modules/datasource/gitlab-tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ export class GitlabTagsDatasource extends Datasource {

protected override http: GitlabHttp;

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
'To get release timestamp we use the `created_at` field from the response.';
override readonly sourceUrlSupport = 'package';
override readonly sourceUrlNote =
'The source URL is determined by using the `packageName` and `registryUrl`.';

constructor() {
super(GitlabTagsDatasource.id);
this.http = new GitlabHttp(GitlabTagsDatasource.id);
Expand Down

0 comments on commit d0b77e5

Please sign in to comment.