kratos icon indicating copy to clipboard operation
kratos copied to clipboard

[Proposal] Add Bazel support

Open commure-stabai opened this issue 2 years ago • 2 comments

Proposal

Add support for users on the Bazel build system by creating Bazel build files and refactorings in Kratos repositories. This will allow users of the Kratos framework who use Bazel to avoid messy custom patching that has to be redone each version, by instead allowing them to be added as dependencies automatically using Gazelle.

The following process would need to be run for each Kratos repository (and possibly each Go module within each repository):

  1. Add a basic Bazel WORKSPACE file and run Gazelle on the repository itself. This will generate several of the necessary artifacts automatically (but many will have errors that need manual fixing).
  2. Fix errors in Bazel build files generated by Gazelle. This may in some cases require Go code changes, but hopefully these will be minimal.
  3. After getting the repository working properly in Bazel, add Gazelle directives to ensure that future Gazelle runs work normally
  4. Document the new process for module updates (e.g. any time you run go mod tidy, also run bazel run :gazelle)
  5. Add a CI check to make sure the Bazel builds work properly after future updates. The check should give details on how to fix common problems when something fails.

commure-stabai avatar Nov 22 '21 18:11 commure-stabai

If it helps add context, we are currently using Kratos with a Bazel project. We've had to manually patch the following Kratos repositories (may be more as we continue on our project):

  • https://github.com/go-kratos/kratos
  • https://github.com/go-kratos/grpc-gateway
  • https://github.com/go-kratos/swagger-api

commure-stabai avatar Nov 22 '21 19:11 commure-stabai

sgtm

Windfarer avatar Nov 23 '21 03:11 Windfarer

Hi, @commure-stabai! I'm Dosu, and I'm helping the kratos team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, the proposal suggests adding Bazel support to the Kratos repositories, which would allow users to avoid manual patching and instead add dependencies automatically using Gazelle. You mentioned that you are currently using Kratos with a Bazel project and have had to manually patch certain Kratos repositories. Windfarer also agrees with the proposal.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the kratos repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself or it will be automatically closed in 7 days.

Thank you for your contribution to the kratos repository!

dosubot[bot] avatar Nov 02 '23 16:11 dosubot[bot]