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
21 changes: 21 additions & 0 deletions lib/modules/manager/runtime-version/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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',
currentValue: '3.12.4',
datasource: 'docker',
},
]);
});

it('returns no result', () => {
const res = extractPackageFile('3.12.4');
expect(res).toBeNull();
});
});
});
24 changes: 24 additions & 0 deletions lib/modules/manager/runtime-version/extract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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',
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$'],
pinDigests: false,
};

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

export const supportedDatasources = [DockerDatasource.id];
8 changes: 8 additions & 0 deletions lib/modules/manager/runtime-version/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Keep `runtime.txt` files updated.

Currently supports `Python` runtime updates, commonly used by platforms such as

- [Heroku](https://devcenter.heroku.com/articles/python-runtimes)
- [CloudFoundry](https://docs.cloudfoundry.org/buildpacks/python/index.html)
- [Koyeb](https://www.koyeb.com/docs/build-and-deploy/build-from-git/python)
- and more