-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager): runtime version (#29745)
Co-authored-by: Michael Kriese <[email protected]> Co-authored-by: Sebastian Poxhofer <[email protected]>
- Loading branch information
1 parent
9026c2d
commit c14e30a
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |