Skip to content

Commit

Permalink
feat(bazel-module): support bazel_dep dependencies without the `ver…
Browse files Browse the repository at this point in the history
…sion` parameter (#33496)

Co-authored-by: Rhys Arkins <[email protected]>
Co-authored-by: Michael Kriese <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2025
1 parent 3f88df2 commit 4ca76e4
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 120 deletions.
26 changes: 26 additions & 0 deletions docs/usage/bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ If Renovate finds a newer version, it updates `0.15.0` to match that version.
#### `git_override`

If Renovate finds a [`git_override`](https://bazel.build/rules/lib/globals/module#git_override), it ignores the related `bazel_dep` entry and instead evaluates the `commit` value at the specified `remote`.
When using `git_override`, the `version` parameter on the `bazel_dep` is optional.

```python
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.15.0")
Expand All @@ -89,6 +90,13 @@ git_override(
commit = "fb47f0e9f7c376a7700fc9fe3319231ae57880df",
remote = "https://github.com/cgrindel/bazel-starlib.git",
)

bazel_dep(name = "rules_foo")
git_override(
module_name = "rules_foo",
remote = "https://github.com/foo/rules_foo.git",
commit = "8a1e9abe415eda7cd7f2a744fdac7499ce42cdca",
)
```

If the primary branch has a newer commit than in the list, Renovate updates the `commit` value.
Expand All @@ -101,6 +109,7 @@ Renovate only evaluates _two_ attributes from this declaration: `version` and `r
If a `version` is specified, it overrides the version in the `bazel_dep`.
In the following example, Renovate notices that the version is pinned to `1.2.3`.
This results in `rules_foo` being ignored for update evaluation.
When using `single_version_override`, the `version` parameter on the `bazel_dep` is optional.

```python
bazel_dep(name = "rules_foo", version = "1.2.4")
Expand All @@ -109,6 +118,13 @@ single_version_override(
module_name = "rules_foo",
version = "1.2.3",
)

bazel_dep(name = "rules_bar")

single_version_override(
module_name = "rules_bar",
version = "1.2.3",
)
```

If a `registry` is specified, Renovate uses the specified registry URL to check for a new version.
Expand All @@ -128,6 +144,7 @@ single_version_override(

If Renovate finds an [`archive_override`](https://bazel.build/rules/lib/globals/module#archive_override) or a [`local_path_override`](https://bazel.build/rules/lib/globals/module#local_path_override), it ignores the related `bazel_dep`.
Because these declarations lack versionable attributes, Renovate does not update them.
When using `archive_override` and `local_path_override`, the `version` parameter on the `bazel_dep` is optional.

```python
bazel_dep(name = "rules_foo", version = "1.2.3")
Expand All @@ -138,6 +155,15 @@ archive_override(
"https://example.com/archive.tar.gz",
],
)

bazel_dep(name = "rules_bar")

archive_override(
module_name = "rules_bar",
urls = [
"https://example.com/archive.tar.gz",
],
)
```

#### `multiple_version_override`
Expand Down
18 changes: 18 additions & 0 deletions lib/modules/manager/bazel-module/context.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ describe('modules/manager/bazel-module/context', () => {
]);
});

it('construct simple bazel_dep with no version', () => {
const ctx = new Ctx()
.startRule('bazel_dep')
.startAttribute('name')
.addString('rules_foo')
.endRule();

expect(ctx.results).toEqual([
fragments.record(
{
rule: fragments.string('bazel_dep'),
name: fragments.string('rules_foo'),
},
true,
),
]);
});

it('construct a rule with array arg', () => {
const ctx = new Ctx()
.startRule('foo_library')
Expand Down
Loading

0 comments on commit 4ca76e4

Please sign in to comment.