mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
a3d265d45d
* refactor(datasource): stop double-caching releases at the index level 15 datasources set `caching = true`, which makes the registry wrapper in `lib/modules/datasource/index.ts` store every `getReleases` result under `datasource-releases-<id>` for 15 minutes, while their own `cached()` wrapper already stores the same result under `datasource-<id>` with a longer TTL and stale-fallback. Drop `caching` from those 15; the four that rely on the index cache alone (dart-version, flutter-version, maven, pypi) keep it. `caching` is documented as requiring the datasource to return the `isPrivate` flag, and none of these 15 ever set it, so the index layer was caching private results unconditionally. The remaining `cached()` layer honours `cachePrivatePackages` as before. Also fix two cache-key/registry defects found alongside: - `galaxy-collection` declares `registryStrategy = 'hunt'` but keyed its cache on the package name only, so a `null` from the first hunted registry was replayed for the second one. The registry URL is now part of the key, which invalidates existing entries once. - `typst` ignores `config.registryUrl` and always reads its default registry, so it now sets `customRegistrySupport = false`. A configured `registryUrls` for typst is now warned about and ignored instead of being silently dropped. * Merge branch 'main' into secustor/refactor/datasource-remove-index-caching
108 lines
3.2 KiB
TypeScript
108 lines
3.2 KiB
TypeScript
import { logger } from '../../../logger/index.ts';
|
|
import { asTimestamp } from '../../../util/timestamp.ts';
|
|
import * as rustVersioning from '../../versioning/rust-release-channel/index.ts';
|
|
import { Datasource } from '../datasource.ts';
|
|
import type { GetReleasesConfig, ReleaseResult } from '../types.ts';
|
|
import { parseManifestUrl } from './parse.ts';
|
|
import type { ParsedManifestUrl } from './types.ts';
|
|
|
|
export class RustVersionDatasource extends Datasource {
|
|
static readonly id = 'rust-version';
|
|
|
|
override supportsCustomRegistry(_packageName: string): boolean {
|
|
return false;
|
|
}
|
|
|
|
override getDefaultRegistryUrls(_packageName: string): string[] {
|
|
return ['https://static.rust-lang.org'];
|
|
}
|
|
|
|
override readonly defaultVersioning = rustVersioning.id;
|
|
|
|
override readonly releaseTimestampSupport = true;
|
|
override readonly releaseTimestampNote =
|
|
'The release timestamp is parsed from the release manifest URL.';
|
|
|
|
override readonly sourceUrlSupport = 'package';
|
|
|
|
constructor() {
|
|
super(RustVersionDatasource.id);
|
|
}
|
|
|
|
private async getManifests(url: URL): Promise<ParsedManifestUrl[]> {
|
|
const response = await this.http.getText(url);
|
|
const lines = response.body.split('\n');
|
|
|
|
const parsedResults = [];
|
|
for (const line of lines) {
|
|
// skip trailing empty element from .split('\n') upstream
|
|
if (!line.trim()) {
|
|
continue;
|
|
}
|
|
const parsed = parseManifestUrl(line);
|
|
if (parsed) {
|
|
parsedResults.push(parsed);
|
|
} else {
|
|
logger.warn({ line }, 'Failed to parse manifest URL');
|
|
}
|
|
}
|
|
|
|
return parsedResults;
|
|
}
|
|
|
|
async fetchReleases({
|
|
registryUrl,
|
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
const url = new URL('manifests.txt', registryUrl);
|
|
|
|
let parsedResults: ParsedManifestUrl[];
|
|
try {
|
|
parsedResults = await this.getManifests(url);
|
|
} catch (err) {
|
|
this.handleGenericErrors(err);
|
|
}
|
|
|
|
// Filter out dated stable and beta channel releases
|
|
// (not supported by the `rust-release-channel` versioning)
|
|
const filteredResults = parsedResults.filter(
|
|
(result) => result.version !== 'stable' && result.version !== 'beta',
|
|
);
|
|
|
|
// Transform to version strings and deduplicate
|
|
const versionMap = new Map<string, string>();
|
|
for (const parsed of filteredResults) {
|
|
const version =
|
|
parsed.version === 'nightly'
|
|
? `nightly-${parsed.date}`
|
|
: parsed.version;
|
|
|
|
// Keep latest date for each version
|
|
versionMap.set(version, parsed.date);
|
|
}
|
|
|
|
const releaseResult: ReleaseResult = {
|
|
releases: [],
|
|
homepage: 'https://rust-lang.org/',
|
|
sourceUrl: 'https://github.com/rust-lang/rust',
|
|
changelogUrl: 'https://github.com/rust-lang/rust/blob/main/RELEASES.md',
|
|
};
|
|
|
|
for (const [version, date] of versionMap.entries()) {
|
|
const releaseTimestamp = asTimestamp(date);
|
|
releaseResult.releases.push({ version, releaseTimestamp });
|
|
}
|
|
|
|
return releaseResult;
|
|
}
|
|
|
|
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
return this.cached(
|
|
{
|
|
key: config.registryUrl!,
|
|
cacheable: true,
|
|
},
|
|
() => this.fetchReleases(config),
|
|
);
|
|
}
|
|
}
|