vaticle / dependencies

Bazel dependency declarations for build tools reused across @vaticle repositories (only for @vaticle)
Mozilla Public License 2.0
12 stars 23 forks source link

Add a universal aspect_bazel_lib dependency for csharp and nodejs rules #547

Closed farost closed 3 weeks ago

farost commented 3 weeks ago

What is the goal of this PR?

typedb-driver and typedb-protocol builds have been broken after a recent ts rules update because of the updated aspect_bazel_lib dependency.

To fix the current issue and prevent its reproduction, we add a universal aspect_bazel_lib dependency with a specific version, which is maximal for all the dependent rules in dependencies. This dependency should be explicitly declared before using any rule that depends on aspect_bazel_lib of any version and updated every time a rule uses a newer version of it as its dependency.

What are the changes implemented in this PR?

We add a universal aspect_bazel_lib macro with a single http_archive call for this dependency. We also add invocations of this macro for all the rules' dependencies that depend on aspect_bazel_lib. It lets us not worry about the relative order of these rules declarations in WORKSPACEs as only the aspect_bazel_lib()'s version will be used for all these rules.

The fix works because Bazel uses the first declaration of a dependency. This way, if we have multiple http_archives of aspect_bazel_lib, only the first one is used for every rule depending on it.

It can be a problem if this common dependency becomes not backward-compatible and we cannot make all of our dependent rules use a single version. However, everything is fine while it works.

A similar approach can be used for any other common dependency if we face such issues in the future.

An example of a fixed build for protocol

vaticle-bot commented 3 weeks ago

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

Code

Architecture