Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(manager): runtime version #29745

Merged
merged 15 commits into from
Jun 27, 2024
Merged
2 changes: 2 additions & 0 deletions lib/modules/manager/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import * as pub from './pub';
import * as puppet from './puppet';
import * as pyenv from './pyenv';
import * as rubyVersion from './ruby-version';
import * as runtimeVersion from './runtime-version';
import * as sbt from './sbt';
import * as scalafmt from './scalafmt';
import * as setupCfg from './setup-cfg';
Expand Down Expand Up @@ -171,6 +172,7 @@ api.set('pub', pub);
api.set('puppet', puppet);
api.set('pyenv', pyenv);
api.set('ruby-version', rubyVersion);
api.set('runtime-version', runtimeVersion);
api.set('sbt', sbt);
api.set('scalafmt', scalafmt);
api.set('setup-cfg', setupCfg);
Expand Down
22 changes: 22 additions & 0 deletions lib/modules/manager/runtime-version/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { extractPackageFile } from '.';

describe('modules/manager/runtime-version/extract', () => {
describe('extractPackageFile()', () => {
it('returns a result - python', () => {
const res = extractPackageFile('python-3.12.4');
expect(res?.deps).toEqual([
{
depName: 'python',
commitMessageTopic: 'Runtime Version',
currentValue: '3.12.4',
datasource: 'docker',
},
]);
});

it('returns no result', () => {
const res = extractPackageFile('3.12.4');
expect(res).toBeNull();
});
});
});
25 changes: 25 additions & 0 deletions lib/modules/manager/runtime-version/extract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { regEx } from '../../../util/regex';
import { DockerDatasource } from '../../datasource/docker';
import type { PackageDependency, PackageFileContent } from '../types';

export const pythonRuntimeRegex = regEx(
'^python-(?<version>\\d+\\.\\d+\\.\\d+)$',
);

export function extractPackageFile(content: string): PackageFileContent | null {
const regexResult = pythonRuntimeRegex.exec(content);
const runtimeVersion = regexResult?.groups?.version;

if (runtimeVersion) {
const dep: PackageDependency = {
depName: 'python',
commitMessageTopic: 'Runtime Version',
setchy marked this conversation as resolved.
Show resolved Hide resolved
currentValue: runtimeVersion,
datasource: DockerDatasource.id,
};

return { deps: [dep] };
}

return null;
}
15 changes: 15 additions & 0 deletions lib/modules/manager/runtime-version/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Category } from '../../../constants';
import { DockerDatasource } from '../../datasource/docker';

export { extractPackageFile } from './extract';

export const displayName = 'Runtime Version';

export const defaultConfig = {
fileMatch: ['^runtime.txt$'],
setchy marked this conversation as resolved.
Show resolved Hide resolved
pinDigests: false,
};

export const categories: Category[] = ['python'];

export const supported