From 15302f7f0ebf17b035b29bb24807da41522b1b9e Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 20 Sep 2026 08:49:50 -0400 Subject: [PATCH] feat(renovate): update Read the Docs tool versions --- renovate-config.json5 | 65 +++++++++++++++++++++++- tests/renovate-config.test.mjs | 92 +++++++++++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 3 deletions(-) diff --git a/renovate-config.json5 b/renovate-config.json5 index ccb78441..0eff9ea7 100644 --- a/renovate-config.json5 +++ b/renovate-config.json5 @@ -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]*[\"']?(?\\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]*[\"']?(?\\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]*[\"']?(?\\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]*[\"']?(?\\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]*[\"']?(?\\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", @@ -236,13 +297,13 @@ "/(^|/)environment[.]ya?ml$/", ], "matchStrings": [ - "(?[ \\t]*)-[ \\t]*(?[A-Za-z0-9_.-]+)[ \\t]*=[ \\t]*(?[^=\\s#][^\\s#]*)", + "\\r?\\n(?[ \\t]{2})-[ \\t]*(?[A-Za-z0-9_.-]+)[ \\t]*={1,2}[ \\t]*(?[^=\\s#][^\\s#]*)", ], "currentValueTemplate": "=={{{currentValue}}}", "datasourceTemplate": "conda", "packageNameTemplate": "conda-forge/{{{depName}}}", "versioningTemplate": "conda", - "autoReplaceStringTemplate": "{{{indentation}}}- {{{depName}}}={{{newVersion}}}", + "autoReplaceStringTemplate": "\n{{{indentation}}}- {{{depName}}}=={{{newVersion}}}", }, // CPM Package Lock { diff --git a/tests/renovate-config.test.mjs b/tests/renovate-config.test.mjs index 8ff7ab47..090707a4 100644 --- a/tests/renovate-config.test.mjs +++ b/tests/renovate-config.test.mjs @@ -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 => { @@ -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: { @@ -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 @@ -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', + }, ], ); @@ -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}`);