buf-setup-action icon indicating copy to clipboard operation
buf-setup-action copied to clipboard

feat: add go_version_file support

Open stevenh opened this issue 2 years ago • 7 comments

Add support for determining the version of buf to use from go.mod including full test for the functionality.

This allows go projects to have a single source for go module versions.

Also:

  • Fixes from lint issues in README.md.

Fixes #155

stevenh avatar Aug 15 '23 00:08 stevenh

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 15 '23 00:08 CLAassistant

Thanks for the PR. A few notes:

  • We can't promise we will merge this, but will consider it as a feature. We don't recommend adding github.com/bufbuild/buf as a way to install the CLI - this installation method is not officially supported.
  • I've added a few comments to start with some questions.
  • If we do accept this as a feature, revert all changes not related to the feature (ie changes to makefile, eslint, readme lint, etc), so that the PR only relates to the feature.

Thanks for the review, wasn't expecting that as I left it in draft to finish off this morning ;-)

I've responded to all your notes with few questions and some clarification of the choices, looking forward to your feedback.

stevenh avatar Aug 15 '23 10:08 stevenh

@bufdev any feedback on this?

stevenh avatar Sep 07 '23 10:09 stevenh

Hey @stevenh - thanks for the PR, but we can't consider this at the moment. This isn't an officially supported installation path, and adding it as one isn't something we can budget for at this time unfortunately. We can revisit this in the future.

bufdev avatar Sep 07 '23 14:09 bufdev

Thanks for the feedback.

It's obviously a shame as it means people either have to not use your action or when incrementing buf versions have to change in multiple places.

In case you haven't seen it versioning tools using go.mod is one of the recommended practices details on the official go wiki in answer to How can I track tool dependencies for a module?.

stevenh avatar Sep 07 '23 23:09 stevenh

We've seen that, but we don't think it's a good practice, and isn't one we support - we've seen numerous issues with users installing tools in this manner with dependencies overlapping with their own code's dependencies, causing builds of the buf binary to use untested dependencies.

bufdev avatar Sep 07 '23 23:09 bufdev

Hey @bufdev,

Could you elaborate on this point:

We don't recommend adding github.com/bufbuild/buf as a way to install the CLI - this installation method is not officially supported.

The installation docs do call out installation from source using go install as one of the primary install methods - https://buf.build/docs/installation

Agree with the take from @stevenh on this one. In a project where one is using the bufbuild GitHub actions alongside allowing folks to use buf locally, you can end up in a situation of maintaining the buf version in two different places. One in the GitHub action and another perhaps in a Makefile or shell script for local usage.

Another pattern we've used in the past to help with this is using GOBIN to set a local toolchain directory, avoiding the risk of overloading local versions of tools across many projects. Coupling that with being able to unify the version of buf from go.mod would make for quite a nice developer experience.

danmrichards avatar Nov 07 '23 09:11 danmrichards

The new buf-action supports versioning commands from the buf installed on the runner. This can be used to install the version in the go.mod file by calling the following:

go install github.com/bufbuild/buf/cmd/buf@$(go list -f '{{.Version}}' -m github.com/bufbuild/buf)

This removes the edge case of go.mod having a non-release but version. Closing for now, please raise an issue in buf-action if this doesn't solve your usecase.

emcfarlane avatar Aug 01 '24 20:08 emcfarlane