CDN build compatible with CloudFlare v3 build image#77
Open
philpennock wants to merge 2 commits intomainfrom
Open
CDN build compatible with CloudFlare v3 build image#77philpennock wants to merge 2 commits intomainfrom
philpennock wants to merge 2 commits intomainfrom
Conversation
Claude rewrote make-json-files as a .py file for me, for issue #76. Claude's summary below the cut. ----- Everything looks correct. The output matches what the shell script would produce: - %NIGHTLY% placeholders are preserved in nightly URLs (to be substituted by the installer at runtime) - .exe extension appears only on windows-arm6 and windows-arm64 (matching the original PLATFORM_EXE_EXTENSION map exactly) - Key ordering in every object matches the jq insertion order - The channels JSON has unexpanded templates; the platforms JSON has fully-expanded URLs A few design notes on the implementation: - parse_conf — straight key=value regex, skips comments and blank lines, no shell evaluation - expand — sequential str.replace calls, faithfully replicating the shell expand_config_value/expand_all chain (order matters in theory, though none of the current templates require cascading) - ToolTemplates / ChannelSpec — frozen dataclasses; immutable after construction since they're read-only config - build_channels_json / build_platforms_json — separate functions with matching loop structure (tools outer, platforms inner) to preserve the exact dict insertion order that determines JSON key order - json.dumps(data, indent=2) + "\n" — matches jq's default pretty-print format with a trailing newline from printf '%s\n' - No subprocess, no shutil, no third-party packages — pure stdlib
The bash script took almost 2s to run, the Python is under 0.15s. Note though that the bash script explicitly wasn't trying to be efficient, but to be manageable with known-working primitives which could be repeatedly invoked. This Python should let our CDN build flow be compatible with CloudFlare's v3 build images. The only changes to the Python code were comments or doc-strings. I've reviewed the AI-written Python and am happy with the quality and have done a diff of the output directory `public` between the shell-built JSON and the Python-built; the contents are identical, so this is a solid replacement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per issue #76 we need to replace the
make-json-filesimplementation becauseit relied upon the
jqbinary being available, which was true in thedeprecated v1 build images but is not true in v2 onwards (v3 is current).
I got Claude to reimplement the script in Python. First commit is just the
script added as a
.pyfile, the second commit has me replace the bash filewith the .py, with comment/doc-string changes, after reviewing the code and
validating that the results are identical.
I had previously set the Preview environment in CloudFlare to use the v3
image, which is what exposed this issue. You can see the build now succeeding
at:
https://dash.cloudflare.com/32578e55e8e251552382924d4855e414/pages/view/nats-tools/87c40415-7c11-4af0-ae28-f77b705862a8
The resulting contents are, at time of writing, previewable at:
https://pdp-python-make-json-files.nats-tools.pages.dev/
which does not include the live handlers for /current-nightly or serving
assets but does have all the "static" assets.
Commits: