mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-09 13:36:26 +00:00
Merge 73605b0773
into c04c64f5e7
This commit is contained in:
commit
c5c2324fc1
7 changed files with 151 additions and 2 deletions
|
@ -145,6 +145,19 @@ archive_override(
|
||||||
Renovate ignores [`multiple_version_override`](https://bazel.build/rules/lib/globals/module#multiple_version_override).
|
Renovate ignores [`multiple_version_override`](https://bazel.build/rules/lib/globals/module#multiple_version_override).
|
||||||
`multiple_version_override` does not affect the processing of version updates for a module.
|
`multiple_version_override` does not affect the processing of version updates for a module.
|
||||||
|
|
||||||
|
### `git_repository`
|
||||||
|
|
||||||
|
If Renovate finds a [`git_repository`](https://bazel.build/rules/lib/repo/git#git_repository), it evaluates the `commit` value at the specified `remote`.
|
||||||
|
`remote` is limited to github repos: `https://github.com/<owner>/<repo>.git`
|
||||||
|
|
||||||
|
```python
|
||||||
|
git_repository(
|
||||||
|
name = "rules_foo",
|
||||||
|
remote = "https://github.com/fooexample/rules_foo.git",
|
||||||
|
commit = "8c94e11c2b05b6f25ced5f23cd07d0cfd36edc1a",
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
## Legacy `WORKSPACE` files
|
## Legacy `WORKSPACE` files
|
||||||
|
|
||||||
Renovate extracts dependencies from the following repository rules:
|
Renovate extracts dependencies from the following repository rules:
|
||||||
|
@ -160,7 +173,7 @@ Renovate extracts dependencies from the following repository rules:
|
||||||
It also recognizes when these repository rule names are prefixed with an underscore.
|
It also recognizes when these repository rule names are prefixed with an underscore.
|
||||||
For example, `_http_archive` is treated the same as `http_archive`.
|
For example, `_http_archive` is treated the same as `http_archive`.
|
||||||
|
|
||||||
### `git_repository`
|
### `git_repository` (legacy)
|
||||||
|
|
||||||
Renovate updates any `git_repository` declaration that has the following:
|
Renovate updates any `git_repository` declaration that has the following:
|
||||||
|
|
||||||
|
|
|
@ -392,5 +392,31 @@ describe('modules/manager/bazel-module/extract', () => {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns git_repository dependencies', async () => {
|
||||||
|
const input = codeBlock`
|
||||||
|
git_repository(
|
||||||
|
name = "rules_foo",
|
||||||
|
commit = "850cb49c8649e463b80ef7984e7c744279746170",
|
||||||
|
remote = "https://github.com/example/rules_foo.git",
|
||||||
|
)
|
||||||
|
`;
|
||||||
|
const result = await extractPackageFile(input, 'MODULE.bazel');
|
||||||
|
if (!result) {
|
||||||
|
throw new Error('Expected a result.');
|
||||||
|
}
|
||||||
|
expect(result.deps).toHaveLength(1);
|
||||||
|
expect(result.deps).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{
|
||||||
|
datasource: GithubTagsDatasource.id,
|
||||||
|
depType: 'git_repository',
|
||||||
|
depName: 'rules_foo',
|
||||||
|
currentDigest: '850cb49c8649e463b80ef7984e7c744279746170',
|
||||||
|
packageName: 'example/rules_foo',
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,10 @@ import type { RecordFragment } from './fragments';
|
||||||
import { parse } from './parser';
|
import { parse } from './parser';
|
||||||
import { RuleToMavenPackageDep, fillRegistryUrls } from './parser/maven';
|
import { RuleToMavenPackageDep, fillRegistryUrls } from './parser/maven';
|
||||||
import { RuleToDockerPackageDep } from './parser/oci';
|
import { RuleToDockerPackageDep } from './parser/oci';
|
||||||
import { RuleToBazelModulePackageDep } from './rules';
|
import {
|
||||||
|
GitRepositoryToPackageDep,
|
||||||
|
RuleToBazelModulePackageDep,
|
||||||
|
} from './rules';
|
||||||
import * as rules from './rules';
|
import * as rules from './rules';
|
||||||
|
|
||||||
export async function extractPackageFile(
|
export async function extractPackageFile(
|
||||||
|
@ -18,9 +21,14 @@ export async function extractPackageFile(
|
||||||
try {
|
try {
|
||||||
const records = parse(content);
|
const records = parse(content);
|
||||||
const pfc = await extractBazelPfc(records, packageFile);
|
const pfc = await extractBazelPfc(records, packageFile);
|
||||||
|
const gitRepositoryDeps = extractGitRepositoryDeps(records);
|
||||||
const mavenDeps = extractMavenDeps(records);
|
const mavenDeps = extractMavenDeps(records);
|
||||||
const dockerDeps = LooseArray(RuleToDockerPackageDep).parse(records);
|
const dockerDeps = LooseArray(RuleToDockerPackageDep).parse(records);
|
||||||
|
|
||||||
|
if (gitRepositoryDeps.length) {
|
||||||
|
pfc.deps.push(...gitRepositoryDeps);
|
||||||
|
}
|
||||||
|
|
||||||
if (mavenDeps.length) {
|
if (mavenDeps.length) {
|
||||||
pfc.deps.push(...mavenDeps);
|
pfc.deps.push(...mavenDeps);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +65,12 @@ async function extractBazelPfc(
|
||||||
return pfc;
|
return pfc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractGitRepositoryDeps(
|
||||||
|
records: RecordFragment[],
|
||||||
|
): PackageDependency[] {
|
||||||
|
return LooseArray(GitRepositoryToPackageDep).parse(records);
|
||||||
|
}
|
||||||
|
|
||||||
function extractMavenDeps(records: RecordFragment[]): PackageDependency[] {
|
function extractMavenDeps(records: RecordFragment[]): PackageDependency[] {
|
||||||
return LooseArray(RuleToMavenPackageDep)
|
return LooseArray(RuleToMavenPackageDep)
|
||||||
.transform(fillRegistryUrls)
|
.transform(fillRegistryUrls)
|
||||||
|
|
|
@ -315,5 +315,37 @@ describe('modules/manager/bazel-module/parser/index', () => {
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('finds the git_repository', () => {
|
||||||
|
const input = codeBlock`
|
||||||
|
git_repository(
|
||||||
|
name = "rules_foo",
|
||||||
|
remote = "https://github.com/example/rules_foo.git",
|
||||||
|
commit = "6a2c2e22849b3e6b33d5ea9aa72222d4803a986a",
|
||||||
|
patches = ["//:rules_foo.patch"],
|
||||||
|
patch_strip = 1,
|
||||||
|
)
|
||||||
|
`;
|
||||||
|
const res = parse(input);
|
||||||
|
expect(res).toEqual([
|
||||||
|
fragments.record(
|
||||||
|
{
|
||||||
|
rule: fragments.string('git_repository'),
|
||||||
|
name: fragments.string('rules_foo'),
|
||||||
|
patches: fragments.array(
|
||||||
|
[fragments.string('//:rules_foo.patch')],
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
commit: fragments.string(
|
||||||
|
'6a2c2e22849b3e6b33d5ea9aa72222d4803a986a',
|
||||||
|
),
|
||||||
|
remote: fragments.string(
|
||||||
|
'https://github.com/example/rules_foo.git',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,6 +9,7 @@ const supportedRules = [
|
||||||
'git_override',
|
'git_override',
|
||||||
'local_path_override',
|
'local_path_override',
|
||||||
'single_version_override',
|
'single_version_override',
|
||||||
|
'git_repository',
|
||||||
];
|
];
|
||||||
const supportedRulesRegex = regEx(`^${supportedRules.join('|')}$`);
|
const supportedRulesRegex = regEx(`^${supportedRules.join('|')}$`);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import type {
|
||||||
OverridePackageDep,
|
OverridePackageDep,
|
||||||
} from './rules';
|
} from './rules';
|
||||||
import {
|
import {
|
||||||
|
GitRepositoryToPackageDep,
|
||||||
RuleToBazelModulePackageDep,
|
RuleToBazelModulePackageDep,
|
||||||
bazelModulePackageDepToPackageDependency,
|
bazelModulePackageDepToPackageDependency,
|
||||||
processModulePkgDeps,
|
processModulePkgDeps,
|
||||||
|
@ -72,6 +73,19 @@ const singleVersionOverrideWithoutVersionAndRegistryPkgDep: BasePackageDep = {
|
||||||
depName: 'rules_foo',
|
depName: 'rules_foo',
|
||||||
skipReason: 'ignored',
|
skipReason: 'ignored',
|
||||||
};
|
};
|
||||||
|
const gitRepositoryForGithubPkgDep: BasePackageDep = {
|
||||||
|
datasource: GithubTagsDatasource.id,
|
||||||
|
depType: 'git_repository',
|
||||||
|
depName: 'rules_foo',
|
||||||
|
packageName: 'example/rules_foo',
|
||||||
|
currentDigest: '850cb49c8649e463b80ef7984e7c744279746170',
|
||||||
|
};
|
||||||
|
const gitRepositoryForUnsupportedPkgDep: BasePackageDep = {
|
||||||
|
depType: 'git_repository',
|
||||||
|
depName: 'rules_foo',
|
||||||
|
currentDigest: '850cb49c8649e463b80ef7984e7c744279746170',
|
||||||
|
skipReason: 'unsupported-datasource',
|
||||||
|
};
|
||||||
|
|
||||||
describe('modules/manager/bazel-module/rules', () => {
|
describe('modules/manager/bazel-module/rules', () => {
|
||||||
describe('RuleToBazelModulePackageDep', () => {
|
describe('RuleToBazelModulePackageDep', () => {
|
||||||
|
@ -129,6 +143,30 @@ describe('modules/manager/bazel-module/rules', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('GitRepositoryToPackageDep', () => {
|
||||||
|
const gitRepositoryWithGihubHost = fragments.record({
|
||||||
|
rule: fragments.string('git_repository'),
|
||||||
|
name: fragments.string('rules_foo'),
|
||||||
|
remote: fragments.string('https://github.com/example/rules_foo.git'),
|
||||||
|
commit: fragments.string('850cb49c8649e463b80ef7984e7c744279746170'),
|
||||||
|
});
|
||||||
|
const gitRepositoryWithUnsupportedHost = fragments.record({
|
||||||
|
rule: fragments.string('git_repository'),
|
||||||
|
name: fragments.string('rules_foo'),
|
||||||
|
remote: fragments.string('https://nobuenos.com/example/rules_foo.git'),
|
||||||
|
commit: fragments.string('850cb49c8649e463b80ef7984e7c744279746170'),
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each`
|
||||||
|
msg | a | exp
|
||||||
|
${'git_repository, GitHub host'} | ${gitRepositoryWithGihubHost} | ${gitRepositoryForGithubPkgDep}
|
||||||
|
${'git_repository, unsupported host'} | ${gitRepositoryWithUnsupportedHost} | ${gitRepositoryForUnsupportedPkgDep}
|
||||||
|
`('.parse() with $msg', ({ a, exp }) => {
|
||||||
|
const pkgDep = GitRepositoryToPackageDep.parse(a);
|
||||||
|
expect(pkgDep).toEqual(exp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('.toPackageDependencies()', () => {
|
describe('.toPackageDependencies()', () => {
|
||||||
const expectedBazelDepNoOverrides: PackageDependency[] = [bazelDepPkgDep];
|
const expectedBazelDepNoOverrides: PackageDependency[] = [bazelDepPkgDep];
|
||||||
const expectedBazelDepAndGitOverride: PackageDependency[] = [
|
const expectedBazelDepAndGitOverride: PackageDependency[] = [
|
||||||
|
|
|
@ -242,3 +242,28 @@ export function toPackageDependencies(
|
||||||
): PackageDependency[] {
|
): PackageDependency[] {
|
||||||
return collectByModule(packageDeps).map(processModulePkgDeps).flat();
|
return collectByModule(packageDeps).map(processModulePkgDeps).flat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const GitRepositoryToPackageDep = RecordFragmentSchema.extend({
|
||||||
|
children: z.object({
|
||||||
|
rule: StringFragmentSchema.extend({
|
||||||
|
value: z.literal('git_repository'),
|
||||||
|
}),
|
||||||
|
name: StringFragmentSchema,
|
||||||
|
remote: StringFragmentSchema,
|
||||||
|
commit: StringFragmentSchema,
|
||||||
|
}),
|
||||||
|
}).transform(({ children: { rule, name, remote, commit } }): BasePackageDep => {
|
||||||
|
const gitRepo: BasePackageDep = {
|
||||||
|
depType: rule.value,
|
||||||
|
depName: name.value,
|
||||||
|
currentDigest: commit.value,
|
||||||
|
};
|
||||||
|
const ghPackageName = githubPackageName(remote.value);
|
||||||
|
if (is.nonEmptyString(ghPackageName)) {
|
||||||
|
gitRepo.datasource = GithubTagsDatasource.id;
|
||||||
|
gitRepo.packageName = ghPackageName;
|
||||||
|
} else {
|
||||||
|
gitRepo.skipReason = 'unsupported-datasource';
|
||||||
|
}
|
||||||
|
return gitRepo;
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue