feat(bazelisk): add support for bazelisk bazelversion files (#16114)

This commit is contained in:
Jason Bedard 2022-06-19 02:33:03 -04:00 committed by GitHub
parent 22d2681a6e
commit 461cbc7551
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 0 deletions

View file

@ -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);

View file

@ -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',
},
]);
});
});
});

View file

@ -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] };
}

View file

@ -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];

View file

@ -0,0 +1 @@
Simply keeps the `.bazelversion` file updated.