-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: support user defined version index (incl. pre-release) #290
Conversation
We do not currently attempt to distinguish release from pre-release versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nit comments, otherwise looks good.
for platform, info in platforms.items(): | ||
if type(info) != "dict" or not platform in PLATFORMS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this can ever be true: type() returns a class, never a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is Starlark, not Python. type returns a string in this case https://bazel.build/rules/lib/globals/all#type
data = json.decode(json_string, default = None) | ||
|
||
if data == None: | ||
return "Invalid JSON format in Zig SDK version index.", None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please consider raising a custom exception instead of returning an error string: that way you don't have to repeat the error strings in tests, and the control flow is more explicit with try-except.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately there is no try catch in Starlark. This code uses something akin to go style error returns to make error cases testable.
Depends on #291
Closes #76
To register a nightly toolchain a user must add a version index JSON file (as a available on https://ziglang.org/download/index.json) to their project, register it using the
zig.index(file = ...)
tag, and then register the version usingzig.toolchain(zig_version = ...)
.This also provides support for the broader interpretation of #72.