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

Use the Go Jsonnet port instead of the C++ port #113

Merged
merged 4 commits into from
Sep 4, 2019

Conversation

seh
Copy link
Contributor

@seh seh commented Jul 1, 2019

The Jsonnet project's development focus has shifted to the Go language port, with all the recent performance optimizations landing there. Change rules_jsonnet to use the Go port instead of the C++ port unconditionally.

While it would be possible to expose this choice to users of this package, perhaps by way of introducing a sibling function to jsonnet_repositories, or introducing a parameter to that function, I don't think it's worth the maintenance burden to do so.

@sparkprime and @sbarzowski, your guidance would be welcome here.

@seh
Copy link
Contributor Author

seh commented Jul 1, 2019

It looks like the transitive dependencies for google/go-jsonnet (in particular, on rules_go) aren't picked up properly here. I'll look into that.

@Globegitter
Copy link
Collaborator

In my old job we already switched over to the go version because we hat compiling issues on some non LTS Ubuntu versions. While I am generally in favour of this change I also think we should be a bit more careful with it, e.g. now people need to pull in the go toolchain which they might have not have needed before. Also now the c++ version of the formatter is gone and we should think if we should pull that in separately.

So even though we are not on 1.0 yet I would still consider it a breaking change and maybe even posting something on bazel-dev or bazel-discuss. WDYT?

@seh
Copy link
Contributor Author

seh commented Jul 2, 2019

I figured out what was keeping the tests from passing here. I opened google/go-jsonnet#292, which I'll show use of from here as well shortly.

@seh
Copy link
Contributor Author

seh commented Jul 2, 2019

@Globegitter, where does this repository use jsonnetfmt?

As you said, I do consider this to be a breaking change, at least to consuming projects' WORKSPACE files. The use of the jsonnet_library, jsonnet_to_json, and jsonnet_to_json_test rules shouldn't need to change at all.

The release numbers have been low here, seeming far away from 1.0. It's tempting to say that we could keep the existing WORKSPACE "interface" to the C++ Jsonnet port the same, and introduce new macros to use the Go port instead, with the threat of deprecating the former. I don't know whether I'll have enough time in the coming week or two to work through that complexity, though.

@seh seh force-pushed the use-go-jsonnet-port branch from 61609e6 to d121631 Compare July 2, 2019 15:58
jsonnet/jsonnet.bzl Outdated Show resolved Hide resolved
@@ -25,13 +25,22 @@ external repositories for Jsonnet:
```python
http_archive(
name = "io_bazel_rules_jsonnet",
# TODO: Update this to reflect a later release.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB: I'm publishing this here in advance. Some subsequent coordination is necessary.

@Globegitter
Copy link
Collaborator

Yeah I know that this repository has not been depending on the formatter, but at my previous company we where depending on it and other people might have made use of it as well, so it might still be nice to provide the c++ formatter for those cases.

Yeah I like the idea of keeping both at the same time for a migration window. I am happy to deprecate the c++ version immediately though. I won't have much time the next couple of weeks, but might also be able to spend some time on this after if you don't get around to it.

@seh seh force-pushed the use-go-jsonnet-port branch from d121631 to 86d5165 Compare July 6, 2019 02:35
By default, Bazel will use the Go port of Jsonnet. To use the C++ port
of Jsonnet instead, invoke Bazel with the "--define jsonnet_port=cpp"
command-line flag. To select the Go port explicitly, invoke Bazel with
the "--define jsonnet_port=go" command-line flag.
@seh
Copy link
Contributor Author

seh commented Jul 7, 2019

@Globegitter, please see my most recent commit a0444b9. It makes both ports of Jsonnet available, with selection via command-line flag. I didn't see an easier way to use Bazel's configurable build attributes system without relying on a command-line flag.

The default choice is the Go port. If you feel strongly that we should retain the C++ port as the default choice, I can do that. My proposal here—including the deprecation warning in the README.md file—indicates my preference for switching to the Go port.

@seh
Copy link
Contributor Author

seh commented Jul 7, 2019

Note that we could add more CI targets to the .bazelci/presubmit.yml file to exercise this repository with the possible --define jsonnet_port=(cpp|go) flag values. It would be repetitious, doubling the size of that file, but could catch problems faster. Let me know if you'd like me to add those.

@seh
Copy link
Contributor Author

seh commented Jul 15, 2019

I've been using this to good effect in a couple of projects of mine. Has anyone else tried it? Is there anything to adjust before merging it?

@Globegitter
Copy link
Collaborator

@seh Sorry this dropped of my radar I will take a look again in the next couple of days.

@Globegitter
Copy link
Collaborator

Globegitter commented Aug 14, 2019

@seh This looks really good to me can we just swap the default back to cpp for now, so we can release it fully backwards-compatible and then we can change it in a subsequent commit and make another release. So people have one release to test things out and report any potential issues.

@seh
Copy link
Contributor Author

seh commented Aug 16, 2019

@seh can we just swap the default back to cpp for now, so we can release it fully backwards-compatible

Yes, I think it will be a small code change to do so. It's slightly more work to adjust the documentation, but I'll take care of it. I will share a separate patch (along this same branch) for the change in default, so that we retain the current head as a destination for the follow-on release when we really commit to the Go port being the default.

Retain use of C++ as the default port for one more release, with the
intention to change the default to the Go port and eventually remove
support for the C++ port.
@seh
Copy link
Contributor Author

seh commented Aug 24, 2019

Please see commit 0670955 for the requested change in the default Jsonnet port.

The selected commit is the latest along the "master" branch as of 24
August 2019.
@seh
Copy link
Contributor Author

seh commented Aug 27, 2019

@Globegitter, do you have any other suggestions here?

We've had to switch over to using my own fork in our internal projects, but I'd prefer to rely on this repository instead.

@Globegitter Globegitter merged commit b9c0208 into bazel-contrib:master Sep 4, 2019
@Globegitter
Copy link
Collaborator

@seh Sorry for the delay,and thanks for the great contribution.

@Globegitter
Copy link
Collaborator

@seh sorry again for the delay, I also released version 0.2.0 now. If you want you can already submit a PR to flip the default back again and if there are now issues reported I can release it in one or two weeks time.

@seh
Copy link
Contributor Author

seh commented Sep 4, 2019

Thank you! I expect that I can post that follow-on patch to switch the default within a couple of days.

seh added a commit to seh/rules_jsonnet that referenced this pull request Mar 5, 2020
As threatened in bazel-contrib#113 in mid-2019, change the default Jsonnet tool to
the Go port, leaving the C++ port available for selection via the
"--define" command-line flag to set the "jsonnet_port" build variable
accordingly.
@seh
Copy link
Contributor Author

seh commented Mar 5, 2020

See #129 for following through on changing the default Jsonnet port.

seh added a commit to seh/rules_jsonnet that referenced this pull request Apr 29, 2020
As threatened in bazel-contrib#113 in mid-2019, change the default Jsonnet tool to
the Go port, leaving the C++ port available for selection via the
"--define" command-line flag to set the "jsonnet_port" build variable
accordingly.
Globegitter pushed a commit that referenced this pull request May 5, 2020
As threatened in #113 in mid-2019, change the default Jsonnet tool to
the Go port, leaving the C++ port available for selection via the
"--define" command-line flag to set the "jsonnet_port" build variable
accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants