Fix string to boolean conversion in bazelci.py (#1260)
* Fix string to boolean conversion in bazelci.py
I think the old code didn't actually work as intended - because os.environ can only contain strings, it didn't convert values like 'false' or '0' correctly.
* Address code review comments
* Update bazelci.py
diff --git a/buildkite/bazelci.py b/buildkite/bazelci.py
index 25f96c3..1fb9eb7 100755
--- a/buildkite/bazelci.py
+++ b/buildkite/bazelci.py
@@ -969,12 +969,16 @@
def print_expanded_group(name):
eprint("\n\n+++ {0}\n\n".format(name))
+
+def is_trueish(s):
+ return str(s).lower() in ["true", "1", "t", "y", "yes"]
+
def use_bazelisk_migrate():
"""
If USE_BAZELISK_MIGRATE is set, we use `bazelisk --migrate` to test incompatible flags.
"""
- return bool(os.environ.get("USE_BAZELISK_MIGRATE"))
+ return is_trueish(os.environ.get("USE_BAZELISK_MIGRATE"))
def bazelisk_flags():