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
65 changes: 63 additions & 2 deletions renovate-config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,67 @@
},
],
"customManagers": [
// Numeric runtime versions selected by Read the Docs.
{
"customType": "regex",
"description": "Update Read the Docs Python tool versions",
"managerFilePatterns": [
"/(^|/)\\.readthedocs\\.ya?ml$/",
],
"matchStrings": [
"(?:^|\\r?\\n)[ \\t]+python:[ \\t]*[\"']?(?<currentValue>\\d+(?:\\.\\d+)*)[\"']?[ \\t]*(?:#[^\\r\\n]*)?(?:\\r?\\n|$)",
],
"datasourceTemplate": "python-version",
"depNameTemplate": "python",
},
{
"customType": "regex",
"description": "Update Read the Docs Node.js tool versions",
"managerFilePatterns": [
"/(^|/)\\.readthedocs\\.ya?ml$/",
],
"matchStrings": [
"(?:^|\\r?\\n)[ \\t]+nodejs:[ \\t]*[\"']?(?<currentValue>\\d+(?:\\.\\d+)*)[\"']?[ \\t]*(?:#[^\\r\\n]*)?(?:\\r?\\n|$)",
],
"datasourceTemplate": "node-version",
"depNameTemplate": "node",
},
{
"customType": "regex",
"description": "Update Read the Docs Rust tool versions",
"managerFilePatterns": [
"/(^|/)\\.readthedocs\\.ya?ml$/",
],
"matchStrings": [
"(?:^|\\r?\\n)[ \\t]+rust:[ \\t]*[\"']?(?<currentValue>\\d+(?:\\.\\d+)*)[\"']?[ \\t]*(?:#[^\\r\\n]*)?(?:\\r?\\n|$)",
],
"datasourceTemplate": "rust-version",
"depNameTemplate": "rust",
},
{
"customType": "regex",
"description": "Update Read the Docs Go tool versions",
"managerFilePatterns": [
"/(^|/)\\.readthedocs\\.ya?ml$/",
],
"matchStrings": [
"(?:^|\\r?\\n)[ \\t]+golang:[ \\t]*[\"']?(?<currentValue>\\d+(?:\\.\\d+)*)[\"']?[ \\t]*(?:#[^\\r\\n]*)?(?:\\r?\\n|$)",
],
"datasourceTemplate": "golang-version",
"depNameTemplate": "go",
},
{
"customType": "regex",
"description": "Update Read the Docs Ruby tool versions",
"managerFilePatterns": [
"/(^|/)\\.readthedocs\\.ya?ml$/",
],
"matchStrings": [
"(?:^|\\r?\\n)[ \\t]+ruby:[ \\t]*[\"']?(?<currentValue>\\d+(?:\\.\\d+)*)[\"']?[ \\t]*(?:#[^\\r\\n]*)?(?:\\r?\\n|$)",
],
"datasourceTemplate": "ruby-version",
"depNameTemplate": "ruby-version",
},
// Annotated GitHub release, tag, or branch values paired with immutable commits.
{
"customType": "regex",
Expand Down Expand Up @@ -236,13 +297,13 @@
"/(^|/)environment[.]ya?ml$/",
],
"matchStrings": [
"(?<indentation>[ \\t]*)-[ \\t]*(?<depName>[A-Za-z0-9_.-]+)[ \\t]*=[ \\t]*(?<currentValue>[^=\\s#][^\\s#]*)",
"\\r?\\n(?<indentation>[ \\t]{2})-[ \\t]*(?<depName>[A-Za-z0-9_.-]+)[ \\t]*={1,2}[ \\t]*(?<currentValue>[^=\\s#][^\\s#]*)",
],
"currentValueTemplate": "=={{{currentValue}}}",
"datasourceTemplate": "conda",
"packageNameTemplate": "conda-forge/{{{depName}}}",
"versioningTemplate": "conda",
"autoReplaceStringTemplate": "{{{indentation}}}- {{{depName}}}={{{newVersion}}}",
"autoReplaceStringTemplate": "\n{{{indentation}}}- {{{depName}}}=={{{newVersion}}}",
},
// CPM Package Lock
{
Expand Down
92 changes: 91 additions & 1 deletion tests/renovate-config.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const condaEnvironmentManager = renovateConfig.customManagers.find(
manager => manager.datasourceTemplate === 'conda'
&& manager.managerFilePatterns.some(pattern => pattern.includes('environment')),
);
const readTheDocsToolManagers = renovateConfig.customManagers.filter(
manager => manager.description?.startsWith('Update Read the Docs'),
);

function matchesManagerFilePattern(fileName, patterns) {
return patterns.some(pattern => {
Expand Down Expand Up @@ -74,6 +77,17 @@ function extractCondaDependencies(fileName, content) {
return extractRegexPackageFile(content, fileName, condaEnvironmentManager)?.deps ?? [];
}

function extractReadTheDocsToolDependencies(fileName, content) {
assert.equal(readTheDocsToolManagers.length, 5, 'Expected one manager per Read the Docs runtime');
return readTheDocsToolManagers.flatMap(manager => {
assert.ok(
matchesManagerFilePattern(fileName, manager.managerFilePatterns),
`Expected the Read the Docs tool manager to scan ${fileName}`,
);
return extractRegexPackageFile(content, fileName, manager)?.deps ?? [];
});
}

test('groups highlight.js npm and GitHub dependencies', async () => {
const githubDependency = extractPackageJson({
devDependencies: {
Expand Down Expand Up @@ -148,6 +162,8 @@ channels:
dependencies:
- doxygen=1.2.3
- graphviz = 4.5.6 # Keep an inline comment.
- python==3.14.2
- uv==0.12.13
- nodejs
- pip:
- example==7.8.9
Expand Down Expand Up @@ -177,6 +193,20 @@ dependencies:
packageName: 'conda-forge/graphviz',
versioning: 'conda',
},
{
currentValue: '==3.14.2',
datasource: 'conda',
depName: 'python',
packageName: 'conda-forge/python',
versioning: 'conda',
},
{
currentValue: '==0.12.13',
datasource: 'conda',
depName: 'uv',
packageName: 'conda-forge/uv',
versioning: 'conda',
},
],
);

Expand All @@ -199,10 +229,70 @@ dependencies:
const updatedDependencies = extractCondaDependencies(fileName, updatedContent);

assert.equal(updatedDependencies[0].currentValue, newValue);
assert.match(updatedContent, new RegExp(` - doxygen=${newVersion.replaceAll('.', '\\.')}`));
assert.match(updatedContent, new RegExp(` - doxygen==${newVersion.replaceAll('.', '\\.')}`));
assert.match(updatedContent, / - graphviz = 4\.5\.6 # Keep an inline comment\./);
});

test('extracts numeric Read the Docs runtime versions', () => {
const fileName = '.readthedocs.yaml';
const content = `
version: 2
build:
os: ubuntu-24.04
tools:
python: "3.14"
nodejs: '24'
rust: 1.91
golang: "1.25" # Keep an inline comment.
ruby: "3.4"
`;
const dependencies = extractReadTheDocsToolDependencies(fileName, content);

assert.deepEqual(
dependencies.map(dependency => ({
currentValue: dependency.currentValue,
datasource: dependency.datasource,
depName: dependency.depName,
})),
[
{currentValue: '3.14', datasource: 'python-version', depName: 'python'},
{currentValue: '24', datasource: 'node-version', depName: 'node'},
{currentValue: '1.91', datasource: 'rust-version', depName: 'rust'},
{currentValue: '1.25', datasource: 'golang-version', depName: 'go'},
{currentValue: '3.4', datasource: 'ruby-version', depName: 'ruby-version'},
],
);

for (const dependency of dependencies) {
const newValue = nextTestVersion(dependency.currentValue);
const updatedContent = applyExtractedUpdate(content, dependency, newValue);
const updatedDependencies = extractReadTheDocsToolDependencies(fileName, updatedContent);
assert.ok(
updatedDependencies.some(updated => (
updated.depName === dependency.depName && updated.currentValue === newValue
)),
dependency.depName,
);
}
});

test('ignores moving Read the Docs runtime aliases', () => {
const dependencies = extractReadTheDocsToolDependencies(
'.readthedocs.yaml',
`
build:
tools:
python: miniconda-latest
nodejs: latest
rust: latest
golang: latest
ruby: 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