Skip to content

Commit

Permalink
feat(manager): runtime version (#29745)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <[email protected]>
Co-authored-by: Sebastian Poxhofer <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2024
1 parent 9026c2d commit c14e30a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
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

0 comments on commit c14e30a

Please sign in to comment.