Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added version flag #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .plzconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ preloadbuilddefs = build_defs/go_mock_rule.build_defs

[go]
importpath = github.com/tcncloud/wollemi
gotool = //tools/go:toolchain|go
gotool = //tools/go:toolchain|go
5 changes: 5 additions & 0 deletions BUILD.plz
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
subinclude("//build_defs:version")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the VERSION file in the root of the repo and defining a filegroup for it causes a circular dependency because //build_defs:version requires that filegroup, and the go_binary requires //build_defs:version.

I see two possibilities:

  • move the wollemi binary up a directory.
    • This would allow the VERSION file to remain in the root of the repo, which is where most people would expect it.
    • not likely to be forgotten about.
  • avoid all the genrule and build_def steps and hard code the version in the go_binary definitions attribute.
    • no major changes needed for this
    • could be easy to forget about this and forget to increment the version on a new release
    • less clear where to increment the version for new contributors


go_binary(
name = "wollemi",
srcs = ["main.go"],
visibility = ["PUBLIC"],
definitions = {
"github.com/tcncloud/wollemi/ports/wollemi.WollemiVersion": VERSION,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also just avoid the genrule and build_defs and just hard code the version here ?

},
deps = [
"//adapters/bazel",
"//adapters/cobra",
Expand Down
6 changes: 4 additions & 2 deletions adapters/cobra/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/tcncloud/wollemi/ports/ctl"
"github.com/tcncloud/wollemi/ports/logging"
"github.com/tcncloud/wollemi/ports/wollemi"
)

func RootCmd(app ctl.Application) *cobra.Command {
Expand All @@ -16,8 +17,9 @@ func RootCmd(app ctl.Application) *cobra.Command {
)

cmd := &cobra.Command{
Use: "wollemi",
Short: "cli for wollemi",
Use: "wollemi",
Version: wollemi.WollemiVersion,
Short: "cli for wollemi",
Long: Description(`
Please build file generator and formatter capable of generating go_binary,
go_library and go_test build rules from existing go code.
Expand Down
7 changes: 7 additions & 0 deletions build_defs/BUILD.plz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
genrule(
name = "version",
srcs = ["VERSION"],
outs = ["version.build_defs"],
cmd = "echo \"VERSION = '`cat $SRCS`'\" > \"$OUT\"",
visibility = ["PUBLIC"],
)
1 change: 1 addition & 0 deletions build_defs/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.7.2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would have this VERSION file in the root of the repo, but a circular dependency is formed.

5 changes: 5 additions & 0 deletions ports/wollemi/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package wollemi

// WollemiVersion is the current version of wollemi.
// Note that non-bootstrap builds replace this interim version with a real one.
var WollemiVersion = "dev-0.0.9999"