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

Check bazel version: print a warning if version not in range #1277

Merged
merged 3 commits into from
Mar 23, 2020

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Mar 11, 2020

PR for issue #741

As discussed on slack, we don't to fail if the actual bazel version is not the expected one, we prefer to issue a warning. As a consequence, the code doesn't write anything if it cannot find the version (don't want to issue a warning about a possible warning..).

For a reason detailed here: bazelbuild/bazel#8305 checking bazel's version cannot be done anywhere, that is why it is done in haskell/repositories.bzl.

I did not find a preferred way how to issue a warning message, so I'm simply using Starlark's print function for our messages, please reconsider this.

Tests

In rules_haskell/tutorial, with bazel from APT

> sudo apt install bazel=1.2.1
> bazel --version
bazel 1.2.1
> bazel build //...
Starting local Bazel server and connecting to it...
DEBUG: /home/churlin/.cache/bazel/_bazel_churlin/b8c8fe86b6cf2c554ee68454e2b527a7/external/rules_haskell/haskell/private/versions.bzl:28:9: WARNING: bazel version is too old. Expected 2.0.0, but found: 1.2.1
... usual output
> sudo apt purge bazel; sudo apt install bazel=2.0.0
> bazel --version
bazel 2.0.0
> bazel build //...
Starting local Bazel server and connecting to it...
... usual output
> sudo apt purge bazel; sudo apt install bazel=2.1.0
> bazel --version
bazel 2.1.0
> bazel build //...
DEBUG: /home/churlin/.cache/bazel/_bazel_churlin/b8c8fe86b6cf2c554ee68454e2b527a7/external/rules_haskell/haskell/private/versions.bzl:31:9: WARNING: bazel version is too recent. Expected 2.0.0, but found: 2.1.0
... usual output

At the repo's root, with bazel from nix-shell

> bazel --version
bazel 2.0.0- (@non-git)
> bazel test //...
# tests pass
> bazel run //:buildifier
# nothing to format

Then with a modified nixkpgs/default.nix, to have bazel 2.1.0:

-  # 2020-01-29
-  sha256 = "1iy3iz91xx58k9wgswalipa8gxxdafqq82lisg6s16ml8y232f00";
-  rev = "42a195919a10ce70309c3666dfe8206e380fae1b";
+  # 2020-03-10
+  sha256 = "1kvyrs8g1zidrcs714k8g1gawrqln9x1nndpbfnblkglnzvvrac5";
+  rev = "3eea746d74d1fdfa57eef62b9159f5a51f23562a";
> bazel --version
bazel 2.1.0- (@non-git)
> bazel test //...
Starting local Bazel server and connecting to it...
DEBUG: /media/crypt1/repos/rules_haskell_741/haskell/private/versions.bzl:31:9: WARNING: bazel version is too recent. Expected 2.0.0, but found: 2.1.0- (@non-git)
# tests fail, because of an unexpected version of ghc (8.8.2 available, 8.6.5 expected)
> bazel run //:buildifier
DEBUG: /media/crypt1/repos/rules_haskell_741/haskell/private/versions.bzl:31:9: WARNING: bazel version is too recent. Expected 2.0.0, but found: 2.1.0- (@non-git)
# nothing to format

@smelc smelc changed the title Check bazel version: issue a warning if version differs from 2.0.0 Check bazel version: print a warning if version not in range Mar 18, 2020
@smelc smelc force-pushed the ch/check-bazel-version branch from fccd1ae to a0a7299 Compare March 18, 2020 15:21
@smelc smelc requested a review from aherrmann March 20, 2020 21:12
Copy link
Member

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

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

Thank you, looks good.

haskell/private/versions.bzl Outdated Show resolved Hide resolved
haskell/private/versions.bzl Show resolved Hide resolved
@smelc smelc added the merge-queue merge on green CI label Mar 23, 2020
@smelc smelc force-pushed the ch/check-bazel-version branch from 9caec1b to 80d1fac Compare March 23, 2020 13:45
@mergify mergify bot merged commit dd7f33b into master Mar 23, 2020
@mergify mergify bot deleted the ch/check-bazel-version branch March 23, 2020 15:15
@mergify mergify bot removed the merge-queue merge on green CI label Mar 23, 2020
@smelc smelc mentioned this pull request Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants