Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions renovate-config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
"matchCurrentValue": "/^(?:[a-z]+|\\d+)(?:-[a-z]+)?$/",
"allowedVersions": "/^(?:[a-z]+|\\d+)(?:-[a-z]+)?$/"
},
// Read the Docs accepts Ubuntu LTS release names, not arbitrary Docker tags.
{
"matchDatasources": ["docker"],
"matchDepNames": ["readthedocs/ubuntu"],
"allowedVersions": "/^\\d{2}\\.04$/",
},
// Group GitHub maintained actions
{
"groupName": "Official GitHub Actions",
Expand Down Expand Up @@ -228,6 +234,20 @@
"datasourceTemplate": "ruby-version",
"depNameTemplate": "ruby-version",
},
{
"customType": "regex",
"description": "Update Read the Docs Ubuntu build images",
"managerFilePatterns": [
"/(^|/)\\.readthedocs\\.ya?ml$/",
],
"matchStrings": [
"(?:^|\\r?\\n)[ \\t]+os:[ \\t]*[\"']?ubuntu-(?<currentValue>\\d{2}\\.04)[\"']?[ \\t]*(?:#[^\\r\\n]*)?(?:\\r?\\n|$)",
],
"datasourceTemplate": "docker",
"packageNameTemplate": "ubuntu",
"depNameTemplate": "readthedocs/ubuntu",
"versioningTemplate": "loose",
},
// Annotated GitHub release, tag, or branch values paired with immutable commits.
{
"customType": "regex",
Expand Down
65 changes: 64 additions & 1 deletion tests/renovate-config.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const condaEnvironmentManager = renovateConfig.customManagers.find(
&& manager.managerFilePatterns.some(pattern => pattern.includes('environment')),
);
const readTheDocsToolManagers = renovateConfig.customManagers.filter(
manager => manager.description?.startsWith('Update Read the Docs'),
manager => manager.description?.endsWith('tool versions'),
);
const readTheDocsOsManager = renovateConfig.customManagers.find(
manager => manager.description === 'Update Read the Docs Ubuntu build images',
);

function matchesManagerFilePattern(fileName, patterns) {
Expand Down Expand Up @@ -88,6 +91,15 @@ function extractReadTheDocsToolDependencies(fileName, content) {
});
}

function extractReadTheDocsOsDependencies(fileName, content) {
assert.ok(readTheDocsOsManager, 'Expected to find the Read the Docs OS manager');
assert.ok(
matchesManagerFilePattern(fileName, readTheDocsOsManager.managerFilePatterns),
`Expected the Read the Docs OS manager to scan ${fileName}`,
);
return extractRegexPackageFile(content, fileName, readTheDocsOsManager)?.deps ?? [];
}

test('groups highlight.js npm and GitHub dependencies', async () => {
const githubDependency = extractPackageJson({
devDependencies: {
Expand Down Expand Up @@ -293,6 +305,57 @@ build:
assert.deepEqual(dependencies, []);
});

test('extracts and updates pinned Read the Docs Ubuntu build images', async () => {
const fileName = '.readthedocs.yaml';
const content = `
version: 2
build:
os: ubuntu-24.04 # Keep an inline comment.
tools:
python: "3.14"
`;
const dependencies = extractReadTheDocsOsDependencies(fileName, content);

assert.deepEqual(
dependencies.map(dependency => ({
currentValue: dependency.currentValue,
datasource: dependency.datasource,
depName: dependency.depName,
packageName: dependency.packageName,
versioning: dependency.versioning,
})),
[{
currentValue: '24.04',
datasource: 'docker',
depName: 'readthedocs/ubuntu',
packageName: 'ubuntu',
versioning: 'loose',
}],
);

const updatedContent = applyExtractedUpdate(content, dependencies[0], '26.04');
assert.match(updatedContent, /os: ubuntu-26\.04 # Keep an inline comment\./);
assert.equal(extractReadTheDocsOsDependencies(fileName, updatedContent)[0].currentValue, '26.04');

const resolved = await applyPackageRules({
...dependencies[0],
packageRules: renovateConfig.packageRules,
});
assert.equal(resolved.allowedVersions, '/^\\d{2}\\.04$/');
});

test('ignores moving Read the Docs Ubuntu build image aliases', () => {
const dependencies = extractReadTheDocsOsDependencies(
'.readthedocs.yaml',
`
build:
os: ubuntu-lts-latest
`,
);

assert.deepEqual(dependencies, []);
});

function nextTestVersion(currentValue) {
const match = /^(.*?)(\d+)$/.exec(currentValue);
assert.ok(match, `Expected a version ending in a number: ${currentValue}`);
Expand Down
Loading