VirtusLab / bazel-steward

A bot to keep Bazel dependencies up to date
https://virtuslab.github.io/bazel-steward/
Apache License 2.0
62 stars 6 forks source link

Support multiple WORKSPACES #290

Closed Vertexwahn closed 1 year ago

Vertexwahn commented 1 year ago

I have a repository that contains multiple Bazel WORKSPACES: https://github.com/Vertexwahn/BazelDemos

I added also a Bazel Steward job to it: https://github.com/Vertexwahn/BazelDemos/blob/main/.github/workflows/bazel_steward.yml

It seems that Bazel Steward expects a WORKSPACE file in the root directory. But this repo has many WORKSPACE files.

Would be nice if Bazel Steward would scan for all WORKSPACES and update all of them.

lukaszwawrzyk commented 1 year ago

Hi! Thanks for using Bazel Steward! We already have a ticket for this: https://github.com/VirtusLab/bazel-steward/issues/40

As a current workaround, you can use the positional argument to Bazel Steward which stands for the workspace path (see https://virtuslab.github.io/bazel-steward/docs/configuration/command-line-arguments.html). You can use additional-args to pass this in GHA https://virtuslab.github.io/bazel-steward/docs/installation.html#detailed-usage.

You should be able to safely run the action multiple times for each workspace:

      - uses: actions/checkout@v2
          with:
            fetch-depth: 0
        - uses: VirtusLab/bazel-steward@v1
          with:
            additional-args: core_principles/bzlmod
        - uses: VirtusLab/bazel-steward@v1
          with:
            additional-args: core_principles/genrule
        - uses: VirtusLab/bazel-steward@v1
          with:
            additional-args: hello_world/csharp

You'd probably need to generate this list with a script, given how many workspaces you have. I guess this is still best workaround I can offer until the ticket is implemented.

Vertexwahn commented 1 year ago

I tried it this way (see also here):

name: Bazel Steward

on:
  workflow_dispatch:
  schedule:
    - cron: '30 5 * * *' # runs every day at 5:30 am

jobs:
  bazel-steward: # Seems not to work -> https://github.com/VirtusLab/bazel-steward/issues/290
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: VirtusLab/bazel-steward@latest
        with:
          additional-args: hello_world/latex

But I get this warning:

[main] WARN org.virtuslab.bazelsteward.app.App - Error details: Could not find workspace file in /home/runner/work/BazelDemos/BazelDemos

Local run via java -jar bazel-steward.jar hello_world/latex works.

lukaszwawrzyk commented 1 year ago

There were 2 bugs causing this. It seems to be working with v1.0.2: https://github.com/lukaszwawrzyk/BazelDemos/pulls

I suspect there may be branch clashes leading to undefined behavior when 2+ repositories have the same library to update. You could try to at least disable those who would conflict:

in .bazel-steward.yaml

update-rules:
  - kinds: bazel
    enabled: false
  - dependencies:
      - bazel-skylib
      - rules_scala
    enabled: false

In my example I disabled updating bazel itself, skylib and rules_scala, just as an example. Or you could limit number of projects that you use it with. It will help to try out Bazel Steward before we implement a proper support for multiworkspace repositories.

Vertexwahn commented 1 year ago

https://github.com/Vertexwahn/BazelDemos/pulls - looks nice

looking forward to proper support for multi workspace repositories ;)