diff --git a/lib/modules/manager/api.ts b/lib/modules/manager/api.ts index ebe04c9b60ce0f4591b39f05fb271e8be6c96a7e..59f8d9c223771e2fd4dd51036f0f08540b37d49f 100644 --- a/lib/modules/manager/api.ts +++ b/lib/modules/manager/api.ts @@ -5,6 +5,7 @@ import * as azurePipelines from './azure-pipelines'; import * as batect from './batect'; import * as batectWrapper from './batect-wrapper'; import * as bazel from './bazel'; +import * as bazelisk from './bazelisk'; import * as bitbucketPipelines from './bitbucket-pipelines'; import * as buildkite from './buildkite'; import * as bundler from './bundler'; @@ -79,6 +80,7 @@ api.set('azure-pipelines', azurePipelines); api.set('batect', batect); api.set('batect-wrapper', batectWrapper); api.set('bazel', bazel); +api.set('bazelisk', bazelisk); api.set('bitbucket-pipelines', bitbucketPipelines); api.set('buildkite', buildkite); api.set('bundler', bundler); diff --git a/lib/modules/manager/bazelisk/extract.spec.ts b/lib/modules/manager/bazelisk/extract.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..dde5e2aa84f9c6d216b70ed5cb7e8f5b7cd48bdd --- /dev/null +++ b/lib/modules/manager/bazelisk/extract.spec.ts @@ -0,0 +1,53 @@ +import { extractPackageFile } from '.'; + +describe('modules/manager/bazelisk/extract', () => { + describe('extractPackageFile()', () => { + it('returns a result', () => { + const res = extractPackageFile('5.2.0\n'); + expect(res.deps).toEqual([ + { + currentValue: '5.2.0', + datasource: 'github-releases', + depName: 'bazel', + packageName: 'bazelbuild/bazel', + }, + ]); + }); + + it('supports ranges', () => { + const res = extractPackageFile('5.2\n'); + expect(res.deps).toEqual([ + { + currentValue: '5.2', + datasource: 'github-releases', + depName: 'bazel', + packageName: 'bazelbuild/bazel', + }, + ]); + }); + + it('skips non ranges', () => { + const res = extractPackageFile('latestn'); + expect(res.deps).toEqual([ + { + currentValue: 'latestn', + datasource: 'github-releases', + depName: 'bazel', + packageName: 'bazelbuild/bazel', + }, + ]); + }); + + it('ignores comments past the first line', () => { + const res = extractPackageFile('5.2.0\n# comment1\n\n# comment2'); + expect(res.deps).toEqual([ + { + currentValue: '5.2.0', + datasource: 'github-releases', + depName: 'bazel', + packageName: 'bazelbuild/bazel', + }, + ]); + }); + }); +}); diff --git a/lib/modules/manager/bazelisk/extract.ts b/lib/modules/manager/bazelisk/extract.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4376a57694e867a14641744efeb5c62e1091610 --- /dev/null +++ b/lib/modules/manager/bazelisk/extract.ts @@ -0,0 +1,12 @@ +import { GithubReleasesDatasource } from '../../datasource/github-releases'; +import type { PackageDependency, PackageFile } from '../types'; + +export function extractPackageFile(content: string): PackageFile { + const dep: PackageDependency = { + depName: 'bazel', + currentValue: content.split('\n', 2)[0].trim(), + datasource: GithubReleasesDatasource.id, + packageName: 'bazelbuild/bazel', + }; + return { deps: [dep] }; +} diff --git a/lib/modules/manager/bazelisk/index.ts b/lib/modules/manager/bazelisk/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..345989e1b4c99ad6ff567a52539657670301dc2c --- /dev/null +++ b/lib/modules/manager/bazelisk/index.ts @@ -0,0 +1,10 @@ +import { GithubReleasesDatasource } from '../../datasource/github-releases'; + +export { extractPackageFile } from './extract'; + +export const defaultConfig = { + fileMatch: ['(^|\\/)\\.bazelversion$'], + pinDigests: false, +}; + +export const supportedDatasources = [GithubReleasesDatasource.id]; diff --git a/lib/modules/manager/bazelisk/readme.md b/lib/modules/manager/bazelisk/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..cb720c0992d8ee0c0b53e1108a7734736139d713 --- /dev/null +++ b/lib/modules/manager/bazelisk/readme.md @@ -0,0 +1 @@ +Simply keeps the `.bazelversion` file updated.