feat: support user defined version index (incl. pre-release)#290
feat: support user defined version index (incl. pre-release)#290
Conversation
We do not currently attempt to distinguish release from pre-release versions.
Titousensei
left a comment
There was a problem hiding this comment.
A couple of nit comments, otherwise looks good.
| return "Malformed version number '{}' in Zig SDK version index.".format(version), None | ||
|
|
||
| for platform, info in platforms.items(): | ||
| if type(info) != "dict" or not platform in PLATFORMS: |
There was a problem hiding this comment.
I don't think this can ever be true: type() returns a class, never a string.
There was a problem hiding this comment.
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.
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.
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.