Skip to content
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

Test – Point Gutenberg to a commit to verify XCFramework setup #20741

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d70c55b
Add a local `podspec` to download Gutenberg XCFramework commit builds
mokagio May 17, 2023
a4d2fea
Add check to fail `pod install` if Gutenberg ZIP doesn't exist at URL
mokagio May 17, 2023
6be7ffe
Use latest CocoaPods version
mokagio May 17, 2023
a51b916
Switch to tar.gz for the Gutenberg XCFramework archive
mokagio May 17, 2023
0c01fe6
Use same license as the main project for the Gutenberg pod
mokagio May 18, 2023
0ffbd75
Work around CP not finding XCFrameworks by downloading manually
mokagio May 22, 2023
05e1dd0
Add a couple of newly required `import React`
mokagio May 22, 2023
08e0312
Address new warnings introduced by the Gutenberg via XCFramework
mokagio May 22, 2023
aae9a1e
Update `CopyGutenbergJS` build phase script to account for XCFramework
mokagio May 23, 2023
e9dca95
Use relative paths when importing the local Gutenberg podspec
mokagio May 25, 2023
ba408aa
Use latest a8c-ci-toolkit, 2.17.0
mokagio May 30, 2023
7c440b4
Use Xcode 14.3 and CocoaPods 1.12.1
mokagio May 31, 2023
d46f258
WIP – Replace bespoke download code with `prepare_command`
mokagio Jun 1, 2023
18d815f
Test – Download Gutenberg from commit version
mokagio Jun 1, 2023
4b2a612
Test - Add spec with hardcoded address to test remote validation
mokagio Jun 1, 2023
3281e0d
Test: Verify remote spec with `prepare_command` downloading archive w…
mokagio Jun 1, 2023
d782a0c
Test – Remove `prepare_command` from local hardcoded spec
mokagio Jun 1, 2023
346dabf
Test – Build with spec without `prepare_command` (works locally 🎉)
mokagio Jun 1, 2023
6fd8285
Remove `prepare_command` from local spec
mokagio Jun 1, 2023
1e6b0ec
Restore `prepare_command` in local spec
mokagio Jun 1, 2023
0d25a30
Track result of running `pod install`
mokagio Jun 1, 2023
1a26964
Remove an absolute path that messed up the checksum
mokagio Jun 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .buildkite/cache-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.15.1
- automattic/a8c-ci-toolkit#2.17.0
- automattic/git-s3-cache#1.1.4:
bucket: "a8c-repo-mirrors"
repo: "automattic/wordpress-ios/"
# Common environment values to use with the `env` key.
- &common_env
# Be sure to also update the `.xcode-version` file when updating the Xcode image/version here
IMAGE_ID: xcode-14.2
IMAGE_ID: xcode-14.3

steps:

Expand Down
4 changes: 2 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.15.1
- automattic/a8c-ci-toolkit#2.17.0
- automattic/git-s3-cache#1.1.4:
bucket: "a8c-repo-mirrors"
repo: "automattic/wordpress-ios/"
# Common environment values to use with the `env` key.
- &common_env
# Be sure to also update the `.xcode-version` file when updating the Xcode image/version here
IMAGE_ID: xcode-14.2
IMAGE_ID: xcode-14.3

# This is the default pipeline – it will build and test the app
steps:
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
common_params:
# Common plugin settings to use with the `plugins` key.
- &common_plugins
- automattic/a8c-ci-toolkit#2.15.1
- automattic/a8c-ci-toolkit#2.17.0
- automattic/git-s3-cache#1.1.4:
bucket: "a8c-repo-mirrors"
repo: "automattic/wordpress-ios/"
# Common environment values to use with the `env` key.
- &common_env
# Be sure to also update the `.xcode-version` file when updating the Xcode image/version here
IMAGE_ID: xcode-14.2
IMAGE_ID: xcode-14.3

steps:

Expand Down
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Metrics/MethodLength:
Max: 30
Exclude: *xfiles

Metrics/BlockLength:
Exclude: *.podspec

Layout/LineLength:
Max: 180
Exclude: *xfiles
Expand All @@ -37,3 +40,4 @@ Style/AsciiComments:
Naming/FileName:
Exclude:
- fastlane/Matchfile
- Gutenberg/Gutenberg.podspec
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

source 'https://rubygems.org'

gem 'cocoapods', '~> 1.11'
gem 'archive-tar-minitar'
gem 'cocoapods', '~> 1.12', '>= 1.12.1'
gem 'commonmarker'
gem 'danger', '~> 9.3'
gem 'danger-rubocop', '~> 0.10'
Expand Down
35 changes: 22 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ GEM
specs:
CFPropertyList (3.0.6)
rexml
activesupport (6.1.7.3)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
archive-tar-minitar (0.8)
minitar (~> 0.8)
minitar-cli (~> 0.8)
artifactory (3.0.15)
ast (2.4.2)
atomos (0.1.3)
Expand Down Expand Up @@ -43,26 +45,26 @@ GEM
cork
nap
open4 (~> 1.3)
cocoapods (1.11.3)
cocoapods (1.12.1)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.11.3)
cocoapods-core (= 1.12.1)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.4.0, < 2.0)
cocoapods-downloader (>= 1.6.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.4.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 1.0, < 3.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.21.0, < 2.0)
cocoapods-core (1.11.3)
activesupport (>= 5.0, < 7)
cocoapods-core (1.12.1)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
Expand Down Expand Up @@ -113,7 +115,7 @@ GEM
dotenv (2.8.1)
emoji_regex (3.2.3)
escape (0.0.4)
ethon (0.15.0)
ethon (0.16.0)
ffi (>= 1.15.0)
excon (0.99.0)
faraday (1.10.3)
Expand Down Expand Up @@ -203,7 +205,7 @@ GEM
progress_bar (~> 1.3)
rake (>= 12.3, < 14.0)
rake-compiler (~> 1.0)
ffi (1.15.4)
ffi (1.15.5)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
Expand Down Expand Up @@ -248,6 +250,7 @@ GEM
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
hashie (5.0.0)
highline (2.0.3)
http-cookie (1.0.5)
domain_name (~> 0.5)
Expand All @@ -265,6 +268,10 @@ GEM
mini_magick (4.12.0)
mini_mime (1.1.2)
mini_portile2 (2.8.2)
minitar (0.8)
minitar-cli (0.8)
minitar (~> 0.8.0)
powerbar (~> 1.0)
minitest (5.18.0)
molinillo (0.8.0)
multi_json (1.15.0)
Expand All @@ -288,6 +295,8 @@ GEM
parser (3.2.2.1)
ast (~> 2.4.1)
plist (3.7.0)
powerbar (1.0.18)
hashie (>= 1.1.0)
progress_bar (1.3.3)
highline (>= 1.6, < 3)
options (~> 2.3.0)
Expand Down Expand Up @@ -366,13 +375,13 @@ GEM
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
zeitwerk (2.6.8)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.11)
archive-tar-minitar
cocoapods (~> 1.12, >= 1.12.1)
commonmarker
danger (~> 9.3)
danger-rubocop (~> 0.10)
Expand Down
35 changes: 35 additions & 0 deletions Gutenberg.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

# A spec for a pod whose only job is delegating the XCFrameworks integration to CocoaPods.
#
# This is used to fetch Gutenberg builds that come from commits instead of tags.
# Builds from tags are "official" and stable, so we distribute them via GitHub we'll eventually publish them on CocoaPods.
# The artifacts for builds from commits are instead only stored on an Automattic's server.
Pod::Spec.new do |s|
s.name = 'Gutenberg'
s.version = '1.0.0' # The value here is irrelevant, but required
s.summary = 'A spec to help integrating the Gutenberg XCFramework'
s.homepage = 'https://apps.wordpress.com'
s.license = { type: 'GPL', file: '../LICENSE' }
s.authors = 'Automattic'

s.ios.deployment_target = '13.0' # TODO: Read from common source
s.swift_version = '5.0' # TODO: read from common source

s.requires_arc = true # TODO: Can this be omitted?

# Tell CocoaPods where to download the XCFramework(s) archive with `source` and what to use from its decompressed contents with `vendored_frameworks`.
#
# See https://github.com/CocoaPods/CocoaPods/issues/10288
xcframework_archive_url = 'https://d2twmm2nzpx3bg.cloudfront.net/Gutenberg-8c5e0248b8c109eee664ac6b4ed7dd3ee7f3d380.tar.gz'
s.source = { http: xcframework_archive_url }
s.vendored_frameworks = [
'Aztec.xcframework',
'Gutenberg.xcframework',
'React.xcframework',
'RNTAztecView.xcframework',
'yoga.xcframework'
].map do |f|
"Frameworks/#{f}"
end
end
3 changes: 3 additions & 0 deletions Gutenberg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The folder where our bespoke automatation downloads and unpacks the XCFrameworks archives.
# Ideally, CocoaPods should do this, but for some reason I haven't yet been able to make it work.
.build/
73 changes: 73 additions & 0 deletions Gutenberg/Gutenberg.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# frozen_string_literal: true

require 'pathname'
require_relative './version'

# A spec for a pod whose only job is delegating the XCFrameworks integration to CocoaPods.
#
# This is used to fetch Gutenberg builds that come from commits instead of tags.
# Builds from tags are "official" and stable, so we distribute them via GitHub we'll eventually publish them on CocoaPods.
# The artifacts for builds from commits are instead only stored on an Automattic's server.
Pod::Spec.new do |s|
raise 'Could not find Gutenberg version configuration' if GUTENBERG_CONFIG.nil?

gutenberg_version = GUTENBERG_CONFIG[:commit]

raise "Trying to fetch Gutenberg XCFramework from Automattic's distribution server with invalid version '#{GUTENBERG_CONFIG}'" if gutenberg_version.nil?

xcframework_storage_url = 'https://d2twmm2nzpx3bg.cloudfront.net'

xcframework_archive_url = "#{xcframework_storage_url}/Gutenberg-#{gutenberg_version}.tar.gz"

require 'net/http'

raise "Could not find file at URL #{xcframework_archive_url}" unless Net::HTTP.get_response(URI(xcframework_archive_url)).code == '200'

s.name = 'Gutenberg'
s.version = '1.0.0' # The value here is irrelevant, but required
s.summary = 'A spec to help integrating the Gutenberg XCFramework'
s.homepage = 'https://apps.wordpress.com'
s.license = { type: 'GPL', file: '../LICENSE' }
s.authors = 'Automattic'

s.ios.deployment_target = '13.0' # TODO: Read from common source
s.swift_version = '5.0' # TODO: read from common source

s.requires_arc = true # TODO: Can this be omitted?

# Tell CocoaPods where to download the XCFramework(s) archive with `source` and what to use from its decompressed contents with `vendored_frameworks`.
#
# Unfortunately, CocoaPods currently does work when it comes to local specs with http sources.
#
# See https://github.com/CocoaPods/CocoaPods/issues/10288#issuecomment-1517711223
# s.source = { http: xcframework_archive_url }
archive_name = "Gutenberg-#{gutenberg_version}.tar.gz"
# Always use relative paths, otherwise the checksums in the lockfile will change from machine to machine
relative_extracted_archive_directory = Pathname.new("#{GUTENBERG_ARCHIVE_DIRECTORY}").relative_path_from(__dir__).to_s
relative_download_directory = Pathname.new(GUTENBERG_DOWNLOADS_DIRECTORY).relative_path_from(__dir__).to_s
relative_download_path = File.join(relative_download_directory, archive_name)

s.source = { http: "file://#{relative_download_path}" }

s.vendored_frameworks = [
'Aztec.xcframework',
'Gutenberg.xcframework',
'React.xcframework',
'RNTAztecView.xcframework',
'yoga.xcframework'
].map do |f|
# This needs to be a relative path to the local extraction location and account for the archive folder structure.
File.join(relative_extracted_archive_directory, 'Frameworks', f)
end

# Print the message here because the prepare_command output is not forwarded by CocoaPods
puts "Will skip downloading Gutenberg archive because it already exists at #{relative_download_path}" if File.exist? relative_download_path
s.prepare_command = <<-CMD
mkdir -p #{relative_download_directory}
if [[ ! -f "#{relative_download_path}" ]]; then
curl --progress-bar #{xcframework_archive_url} -o #{relative_download_path}
fi
mkdir -p #{relative_extracted_archive_directory}
tar -xzf #{relative_download_path} --directory=#{relative_extracted_archive_directory}
CMD
end
44 changes: 37 additions & 7 deletions Gutenberg/cocoapods_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# Helpers and configurations for integrating Gutenberg in Jetpack and WordPress via CocoaPods.

require 'archive/tar/minitar'
require 'net/http'
require 'pathname'
require 'ruby-progressbar'
require 'uri'
require 'zlib'
require_relative './version'

DEFAULT_GUTENBERG_LOCATION = File.join(__dir__, '..', '..', 'gutenberg-mobile')
Expand Down Expand Up @@ -59,6 +65,7 @@
React-bridging
].freeze

# rubocop:disable Metrics/AbcSize
def gutenberg_pod(config: GUTENBERG_CONFIG)
options = config

Expand All @@ -68,23 +75,41 @@ def gutenberg_pod(config: GUTENBERG_CONFIG)
options = { path: File.exist?(local_gutenberg) ? local_gutenberg : DEFAULT_GUTENBERG_LOCATION }

raise "Could not find Gutenberg pod at #{options[:path]}. You can configure the path using the #{local_gutenberg_key} environment variable." unless File.exist?(options[:path])
else

pod 'Gutenberg', options
pod 'RNTAztecView', options

gutenberg_dependencies(options: options)
elsif options[:tag]
options[:git] = "https://github.com/#{GITHUB_ORG}/#{REPO_NAME}.git"
options[:submodules] = true
end

pod 'Gutenberg', options
pod 'RNTAztecView', options
# This duplication with the branch above will disappear once tags will use pre-built binaries.
pod 'Gutenberg', options
pod 'RNTAztecView', options

gutenberg_dependencies(options: options)
gutenberg_dependencies(options: options)
elsif options[:commit]
# Notice the use of relative path, otherwise we'd get the full path of the user that run the `pod install` command tracked in Podfile.lock.
# Also notice the path is relative from Dir.pwd, that is, the location where the script running this code is invoked.
#
# Using a remote spec for a test
#
pod 'Gutenberg', path: Pathname.new(File.join(__dir__, 'Gutenberg.podspec')).relative_path_from(Dir.pwd).to_s
end
end
# rubocop:enable Metrics/AbcSize

def gutenberg_dependencies(options:)
if options[:path]
podspec_prefix = options[:path]
elsif options[:tag]
tag = options[:tag]
podspec_prefix = "https://raw.githubusercontent.com/#{GITHUB_ORG}/#{REPO_NAME}/#{tag}"
elsif options[:commit]
return # when referencing via a commit, we donwload pre-built frameworks
else
tag_or_commit = options[:tag] || options[:commit]
podspec_prefix = "https://raw.githubusercontent.com/#{GITHUB_ORG}/#{REPO_NAME}/#{tag_or_commit}"
raise "Unexpected Gutenberg dependencies configuration '#{options}'"
end

podspec_prefix += '/third-party-podspecs'
Expand All @@ -97,3 +122,8 @@ def gutenberg_dependencies(options:)
pod pod_name, podspec: "#{podspec_prefix}/#{pod_name}.#{podspec_extension}"
end
end

def archive_url(commit:)
xcframework_storage_url = 'https://d2twmm2nzpx3bg.cloudfront.net'
"#{xcframework_storage_url}/Gutenberg-#{commit}.tar.gz"
end
Loading