Skip to content

Cache Gutenberg XCFramework downloads on disk#25352

Open
jkmassel wants to merge 5 commits intotrunkfrom
jkmassel/gutenberg-download-cache
Open

Cache Gutenberg XCFramework downloads on disk#25352
jkmassel wants to merge 5 commits intotrunkfrom
jkmassel/gutenberg-download-cache

Conversation

@jkmassel
Copy link
Contributor

@jkmassel jkmassel commented Mar 6, 2026

Summary

We're not quite done with Gutenberg Mobile yet, and we'll still have Aztec around for the foreseeable future. Using worktrees, it's annoying having to redownload 160MB every time, so I wanted to improve the situation.

This PR moves the logic to Bash to make it pretty much dependency-free, but for folks with rake muscle memory everything still works properly.

  • Replace Ruby download/extract logic in Rakefile with a bash script (Scripts/download-gutenberg-xcframeworks.sh) that uses curl --progress-bar for visible download feedback
  • Cache extracted XCFrameworks in ~/Library/Caches/WordPress-iOS/Gutenberg/<version>/ so subsequent runs just cp -a from cache instead of re-downloading
  • Add a Makefile with a dependencies target as a lightweight alternative to rake dependencies:gutenberg_xcframeworks
  • Remove now-unused open-uri, rubygems/package, and zlib requires from Rakefile

Test plan

  • rm -rf WordPress/Frameworks ~/Library/Caches/WordPress-iOS/Gutenberg then bundle exec rake dependencies:gutenberg_xcframeworks — should download with progress and complete successfully
  • Run the same rake task again — should print "Using cached" and skip the download
  • rm -rf WordPress/Frameworks then make dependencies — should restore frameworks from cache without downloading
  • Verify the app builds after running the script

🤖 Generated with Claude Code

Replace the Ruby download/extract logic in the Rakefile with a bash
script that caches the extracted XCFrameworks in ~/Library/Caches. On
subsequent runs the script copies from cache instead of re-downloading.
curl --progress-bar provides download feedback that was previously
missing. Also adds a Makefile with a `dependencies` target for
convenience.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jkmassel jkmassel requested a review from mokagio March 6, 2026 18:05
@jkmassel jkmassel added the Tooling Build, Release, and Validation Tools label Mar 6, 2026
@jkmassel jkmassel assigned jkmassel and unassigned dcalhoun Mar 6, 2026
@jkmassel jkmassel requested a review from dcalhoun March 6, 2026 18:06
@jkmassel jkmassel added this to the 26.8 milestone Mar 6, 2026
jkmassel and others added 2 commits March 6, 2026 11:14
Extract into a temp directory and only move it to the final cache path
after the download and extraction succeed. A partial download no longer
leaves a corrupt cache directory that would be reused on every
subsequent run.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move GUTENBERG_VERSION into the bash script and default the frameworks
directory so neither the Rakefile nor the Makefile need to know about
it. One place to update when bumping the version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 6, 2026

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

mktemp requires the parent directory to exist. Move the mkdir -p before
the mktemp call so it works on fresh CI agents where the Caches
directory doesn't exist yet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 6, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number31373
VersionPR #25352
Bundle IDcom.jetpack.alpha
Commit8b12843
Installation URL6eggpdtd3s3t0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 6, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number31373
VersionPR #25352
Bundle IDorg.wordpress.alpha
Commit8b12843
Installation URL22uedglfba7b8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

The archive also contains react-native-bundle-source-map which is
needed for Sentry sourcemap uploads. Copy everything from the cache
directory instead of only *.xcframework.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

Script looks good and tested well for me. I also smoke tested the Gutenberg mobile editor. My comments suggestions, nothing more. Merge when ready. 🚀

Copy link
Member

Choose a reason for hiding this comment

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

We might add a default help target to improve discoverability.

diff --git a/Makefile b/Makefile
index ec8f8b3bec..3539ae12d1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,7 @@
-.PHONY: dependencies
+.PHONY: help dependencies
 
-dependencies:
+help: ## Show available targets
+	@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk -F ':.*## ' '{printf "  %-20s %s\n", $$1, $$2}'
+
+dependencies: ## Download and cache Gutenberg XCFrameworks
 	./Scripts/download-gutenberg-xcframeworks.sh

fi

# Copy cached contents into the project.
rm -rf "${FRAMEWORKS_DIR}"
Copy link
Member

Choose a reason for hiding this comment

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

The likelihood of someone mistakenly passing / as an argument feels quite low, but given the severe repercussions of doing so, it may be worth guarding as Claude suggested. 😅

Suggested change
rm -rf "${FRAMEWORKS_DIR}"
if [[ -z "${FRAMEWORKS_DIR}" || "${FRAMEWORKS_DIR}" == "/" ]]; then
echo "Error: invalid frameworks directory: '${FRAMEWORKS_DIR}'" >&2
exit 1
fi

# leave a corrupt cache that persists across runs.
mkdir -p "$(dirname "${CACHE_DIR}")"
TEMP_DIR="$(mktemp -d "${CACHE_DIR}.XXXXXX")"
trap 'rm -rf "${TEMP_DIR}"' EXIT
Copy link
Member

Choose a reason for hiding this comment

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

TIL about trap. Cool!

Comment on lines +1 to +2
#!/bin/bash
set -euo pipefail
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Apps Infra recently started moving toward a more portable shebang

Suggested change
#!/bin/bash
set -euo pipefail
#!/usr/bin/env bash
set -euo pipefail

# Usage: download-gutenberg-xcframeworks.sh [frameworks_dir]
# frameworks_dir defaults to WordPress/Frameworks

VERSION="v1.121.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of making the version an input with fallback, too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually... maybe we would be better served by extracting the version in a dedicated file? It's currently duplicated.

➜ g grep v1.121.0
Rakefile:GUTENBERG_VERSION = 'v1.121.0'
fastlane/lanes/localization.rb:GUTENBERG_TAG = 'v1.121.0'

# frameworks_dir defaults to WordPress/Frameworks

VERSION="v1.121.0"
FRAMEWORKS_DIR="${1:-WordPress/Frameworks}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick.

I love that this is can be changed at call time. Nice UX. But neither rake nor make leverages this capability.

Did you consider exposing it? If not, is there value in having it configurable here?

FWIW, I think this is not an issue and we shouldn't get distracted with exposing the config. But maybe there's a good use case for it that I'm not aware of, so I thought I'd call it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tooling Build, Release, and Validation Tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants