From 551941c6cb6f8ef323e584adacf6a6babf781e5c Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 11:58:51 -0500 Subject: [PATCH 01/20] Add script that publishes our podspecs --- .buildkite/publish-pod.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 .buildkite/publish-pod.sh diff --git a/.buildkite/publish-pod.sh b/.buildkite/publish-pod.sh new file mode 100755 index 00000000..dc4073dc --- /dev/null +++ b/.buildkite/publish-pod.sh @@ -0,0 +1,18 @@ +#!/bin/bash -eu + +if [ $# -ne 1 ]; then + echo "Error: CocoaPods publishing failed. One (and only one) podspec must be specified." + exit 1 +fi + +PODSPEC_PATH="$1" +SLACK_WEBHOOK=$PODS_SLACK_WEBHOOK + +echo "--- :rubygems: Setting up Gems" +install_gems + +echo "--- :cocoapods: Publishing Pod to CocoaPods CDN" +publish_pod $PODSPEC_PATH + +echo "--- :slack: Notifying Slack" +slack_notify_pod_published $PODSPEC_PATH "$SLACK_WEBHOOK" \ No newline at end of file From 97760bc50ee336e541c38d08c9c4dba094ef8ed0 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 11:59:44 -0500 Subject: [PATCH 02/20] Update pipeline to support publishing Podspecs when a new git tag is added --- .buildkite/pipeline.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 53f57183..49d89e33 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -13,6 +13,7 @@ steps: # Lint Source files ################# - label: "๐Ÿงช Lint" + key: "lint" command: | echo "--- ๐Ÿ›  Linting" make lint @@ -21,6 +22,7 @@ steps: # Build and Test ################# - label: "๐Ÿงช Build and Test" + key: "test" command: | echo "--- ๐Ÿ›  Building + Testing" make test @@ -29,6 +31,25 @@ steps: # Validate Podspec ################### - label: "๐Ÿงช Validate Podspec" + key: "validate" command: | echo "--- :microscope: Validate Podspec" make validate-pod-ci + + ################# + # Publish the Podspec (if we're building a tag) + ################# + - label: "โฌ†๏ธ Publish Podspec" + key: "publish" + command: | + .buildkite/publish-pod.sh "Gravatar.podspec" + .buildkite/publish-pod.sh "GravatarUI.podspec" + env: *common_env + plugins: [$CI_TOOLKIT] + depends_on: + - "test" + - "validate" + - "lint" + if: build.tag != null + agents: + queue: "mac" From bd5c44e25c91f529b6b168206278ba3c147755e6 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 13:59:41 -0500 Subject: [PATCH 03/20] Consolidate `validate-pod-ci` and `validate-pod` in Makefile --- .buildkite/pipeline.yml | 2 +- Makefile | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 49d89e33..f52189e7 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -34,7 +34,7 @@ steps: key: "validate" command: | echo "--- :microscope: Validate Podspec" - make validate-pod-ci + make validate-pod ################# # Publish the Podspec (if we're building a tag) diff --git a/Makefile b/Makefile index dd7d036c..7dc9ce04 100644 --- a/Makefile +++ b/Makefile @@ -31,12 +31,6 @@ lint: --lint validate-pod: - bundle install - bundle exec pod lib lint \ - --include-podspecs="*.podspec" \ - --verbose --fail-fast - -validate-pod-ci: # For some reason this fixes a failure in `lib lint` # https://github.com/Automattic/buildkite-ci/issues/7 xcrun simctl list >> /dev/null From cdb5ccfae5cad8c0f775b4ceae6779360be73b17 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 14:00:51 -0500 Subject: [PATCH 04/20] Add fastlane --- Gemfile | 1 + Gemfile.lock | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) diff --git a/Gemfile b/Gemfile index fd108b83..340cb795 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,4 @@ source 'https://rubygems.org' gem 'cocoapods', '~> 1.14.3' +gem "fastlane", "~> 2.219" diff --git a/Gemfile.lock b/Gemfile.lock index db788e72..07908ad9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,7 +18,25 @@ GEM algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) + artifactory (3.0.17) atomos (0.1.3) + aws-eventstream (1.3.0) + aws-partitions (1.899.0) + aws-sdk-core (3.191.4) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.8) + jmespath (~> 1, >= 1.6.1) + aws-sdk-kms (1.78.0) + aws-sdk-core (~> 3, >= 3.191.0) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.146.0) + aws-sdk-core (~> 3, >= 3.191.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.8) + aws-sigv4 (1.8.0) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.4) base64 (0.2.0) bigdecimal (3.1.5) claide (1.1.0) @@ -59,36 +77,194 @@ GEM nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.2.0) + colored (1.2) colored2 (3.1.2) + commander (4.6.0) + highline (~> 2.0.0) concurrent-ruby (1.2.2) connection_pool (2.4.1) + declarative (0.0.20) + digest-crc (0.6.5) + rake (>= 12.0.0, < 14.0.0) + domain_name (0.6.20240107) + dotenv (2.8.1) drb (2.2.0) ruby2_keywords + emoji_regex (3.2.3) escape (0.0.4) ethon (0.16.0) ffi (>= 1.15.0) + excon (0.110.0) + faraday (1.10.3) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) + http-cookie (~> 1.0.0) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + faraday_middleware (1.2.0) + faraday (~> 1.0) + fastimage (2.3.0) + fastlane (2.219.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.8, < 3.0.0) + artifactory (~> 3.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.3, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander (~> 4.6) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 4.0) + excon (>= 0.71.0, < 1.0.0) + faraday (~> 1.0) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 1.0) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-apis-androidpublisher_v3 (~> 0.3) + google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-env (>= 1.6.0, < 2.0.0) + google-cloud-storage (~> 1.31) + highline (~> 2.0) + http-cookie (~> 1.0.5) + json (< 3.0.0) + jwt (>= 2.1.0, < 3) + mini_magick (>= 4.9.4, < 5.0.0) + multipart-post (>= 2.0.0, < 3.0.0) + naturally (~> 2.2) + optparse (>= 0.1.1) + plist (>= 3.1.0, < 4.0.0) + rubyzip (>= 2.0.0, < 3.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (~> 3) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.13.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) ffi (1.16.3) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) + google-apis-androidpublisher_v3 (0.54.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-core (0.11.3) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.16.2, < 2.a) + httpclient (>= 2.8.1, < 3.a) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.a) + rexml + google-apis-iamcredentials_v1 (0.17.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-playcustomapp_v1 (0.13.0) + google-apis-core (>= 0.11.0, < 2.a) + google-apis-storage_v1 (0.31.0) + google-apis-core (>= 0.11.0, < 2.a) + google-cloud-core (1.7.0) + google-cloud-env (>= 1.0, < 3.a) + google-cloud-errors (~> 1.0) + google-cloud-env (1.6.0) + faraday (>= 0.17.3, < 3.0) + google-cloud-errors (1.4.0) + google-cloud-storage (1.47.0) + addressable (~> 2.8) + digest-crc (~> 0.4) + google-apis-iamcredentials_v1 (~> 0.1) + google-apis-storage_v1 (~> 0.31.0) + google-cloud-core (~> 1.6) + googleauth (>= 0.16.2, < 2.a) + mini_mime (~> 1.0) + googleauth (1.8.1) + faraday (>= 0.17.3, < 3.a) + jwt (>= 1.4, < 3.0) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (>= 0.16, < 2.a) + highline (2.0.3) + http-cookie (1.0.5) + domain_name (~> 0.5) httpclient (2.8.3) i18n (1.14.1) concurrent-ruby (~> 1.0) + jmespath (1.6.2) json (2.7.1) + jwt (2.8.1) + base64 + mini_magick (4.12.0) + mini_mime (1.1.5) minitest (5.21.1) molinillo (0.8.0) + multi_json (1.15.0) + multipart-post (2.4.0) mutex_m (0.2.0) nanaimo (0.3.0) nap (1.1.0) + naturally (2.2.1) netrc (0.11.0) + optparse (0.4.0) + os (1.1.4) + plist (3.7.1) public_suffix (4.0.7) + rake (13.1.0) + representable (3.2.0) + declarative (< 0.1.0) + trailblazer-option (>= 0.1.1, < 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) rexml (3.2.6) + rouge (2.0.7) ruby-macho (2.5.1) ruby2_keywords (0.0.5) + rubyzip (2.3.2) + security (0.1.3) + signet (0.19.0) + addressable (~> 2.8) + faraday (>= 0.17.5, < 3.a) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.10) + CFPropertyList + naturally + terminal-notifier (2.0.0) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + trailblazer-option (0.1.2) + tty-cursor (0.7.1) + tty-screen (0.8.2) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) typhoeus (1.4.1) ethon (>= 0.9.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + uber (0.1.0) + unicode-display_width (2.5.0) + word_wrap (1.0.0) xcodeproj (1.23.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) @@ -96,6 +272,10 @@ GEM colored2 (~> 3.1) nanaimo (~> 0.3.0) rexml (~> 3.2.4) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.1) + xcpretty (~> 0.2, >= 0.0.7) PLATFORMS arm64-darwin-23 @@ -103,6 +283,7 @@ PLATFORMS DEPENDENCIES cocoapods (~> 1.14.3) + fastlane (~> 2.219) BUNDLED WITH 2.5.4 From fd3bad5cb2ef172b4002772cb4e5fc5c429d5b9c Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 14:07:42 -0500 Subject: [PATCH 05/20] Configure `test` lane in Fastlane, convert Makefile and Buildkite to use it --- .buildkite/pipeline.yml | 4 ++-- .gitignore | 5 +++++ Makefile | 4 +--- fastlane/Fastfile | 22 ++++++++++++++++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 fastlane/Fastfile diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f52189e7..8caf0abc 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -24,8 +24,8 @@ steps: - label: "๐Ÿงช Build and Test" key: "test" command: | - echo "--- ๐Ÿ›  Building + Testing" - make test + validate_swift_package + plugins: [$CI_TOOLKIT] ################### # Validate Podspec diff --git a/.gitignore b/.gitignore index 9df7c566..530735c7 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,8 @@ Carthage/Build # `pod install` in .travis.yml # # Pods/ + +# Fastlane +fastlane/README.md +fastlane/report.xml +fastlane/test_output diff --git a/Makefile b/Makefile index 7dc9ce04..b4a1fde8 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,7 @@ dev-demo: xed Demo/ test: - xcodebuild test \ - -scheme Gravatar-Package \ - -destination 'platform=$(PLATFORM),OS=$(OS),name=$(DEVICE)' + bundle exec fastlane test swiftformat: swift package plugin \ diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 00000000..1ad5e95a --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +default_platform(:ios) + +SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS = '' +IPHONE_DEVICE = 'iPhone SE (3rd generation)' + +platform :ios do + desc 'Builds the project and runs tests' + lane :test do + run_tests( + package_path: '.', + scheme: 'Gravatar-Package', + device: IPHONE_DEVICE, + prelaunch_simulator: true, + clean: true, + buildlog_path: File.join(__dir__, '.build', 'logs'), + derived_data_path: File.join(__dir__, '.build', 'derived-data'), + xcargs: SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS + ) + end +end \ No newline at end of file From a23d0a6b97bb815292ad47659ca41cc6f167b231 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 15:27:31 -0500 Subject: [PATCH 06/20] Add ability to build Demo's from the command line, update `Makefile`, and configure Buildkite to build demos --- .buildkite/pipeline.yml | 13 +++++++++++++ Makefile | 8 ++++---- fastlane/Fastfile | 21 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 8caf0abc..085feabc 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -25,7 +25,19 @@ steps: key: "test" command: | validate_swift_package + env: *common_env plugins: [$CI_TOOLKIT] + + ################# + # Build Demo + ################# + - label: "๐Ÿงช Build Demo Project" + key: "test_demo" + command: | + echo "--- ๐Ÿ›  Building Demo (Swift)" + bundle exec fastlane build_demo scheme:Gravatar-Demo + echo "--- ๐Ÿ›  Building Demo (SwiftUI)" + bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo ################### # Validate Podspec @@ -48,6 +60,7 @@ steps: plugins: [$CI_TOOLKIT] depends_on: - "test" + - "test_demo" - "validate" - "lint" if: build.tag != null diff --git a/Makefile b/Makefile index b4a1fde8..28ea75c2 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,5 @@ .PHONY: all clean run -PLATFORM = iOS Simulator -OS = 17.2 -DEVICE = iPhone SE (3rd generation) - SWIFTFORMAT_CACHE = ~/Library/Caches/com.charcoaldesign.swiftformat dev: @@ -15,6 +11,10 @@ dev-demo: test: bundle exec fastlane test +build-demo: + bundle exec fastlane build_demo scheme:Gravatar-Demo + bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo + swiftformat: swift package plugin \ --allow-writing-to-package-directory \ diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 1ad5e95a..2e2482a7 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -3,6 +3,7 @@ default_platform(:ios) SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS = '' +OS = '17.2' IPHONE_DEVICE = 'iPhone SE (3rd generation)' platform :ios do @@ -19,4 +20,24 @@ platform :ios do xcargs: SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS ) end + + lane :build_demo do |options| + scheme = options.fetch(:scheme, 'Gravatar-Demo') + + build_ios_app( + project: 'Demo/Gravatar-Demo.xcodeproj', + scheme: scheme, + configuration: 'Debug', + destination: "platform=iOS Simulator,OS=#{OS},name=#{IPHONE_DEVICE}", + disable_package_automatic_updates: true, + export_method: 'development', + export_options: { + provisioningProfiles: { + "com.automattic.gravatar-sdk-demo" => "Gravatar Demo App Development", + "com.automattic.gravatar-sdk-demo-swiftui" => "Gravatar Demo App Development" + } + }, + output_directory: 'build' + ) + end end \ No newline at end of file From e8f528dee890de25e65a3ee7b5757b7011214bf5 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 15:30:33 -0500 Subject: [PATCH 07/20] Remove `env` parameters that shouldn't be there --- .buildkite/pipeline.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 085feabc..4277a61e 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -25,7 +25,6 @@ steps: key: "test" command: | validate_swift_package - env: *common_env plugins: [$CI_TOOLKIT] ################# @@ -56,7 +55,6 @@ steps: command: | .buildkite/publish-pod.sh "Gravatar.podspec" .buildkite/publish-pod.sh "GravatarUI.podspec" - env: *common_env plugins: [$CI_TOOLKIT] depends_on: - "test" From b87909dba35c7acd6d96e78e9ae2020781a0fe6c Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 15:36:48 -0500 Subject: [PATCH 08/20] Move demo building logic into helper commands, move helpers into `commands` folder, call helpers --- .buildkite/commands/build-demos.sh | 10 ++++++++++ .buildkite/{ => commands}/publish-pod.sh | 0 .buildkite/pipeline.yml | 10 +++------- 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 .buildkite/commands/build-demos.sh rename .buildkite/{ => commands}/publish-pod.sh (100%) diff --git a/.buildkite/commands/build-demos.sh b/.buildkite/commands/build-demos.sh new file mode 100644 index 00000000..854534d9 --- /dev/null +++ b/.buildkite/commands/build-demos.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eu + +echo "--- :rubygems: Setting up Gems" +install_gems + +echo "--- ๐Ÿ›  Building Demo (Swift)" +bundle exec fastlane build_demo scheme:Gravatar-Demo + +echo "--- ๐Ÿ›  Building Demo (SwiftUI)" +bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo \ No newline at end of file diff --git a/.buildkite/publish-pod.sh b/.buildkite/commands/publish-pod.sh similarity index 100% rename from .buildkite/publish-pod.sh rename to .buildkite/commands/publish-pod.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 4277a61e..95aa31a1 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -32,11 +32,7 @@ steps: ################# - label: "๐Ÿงช Build Demo Project" key: "test_demo" - command: | - echo "--- ๐Ÿ›  Building Demo (Swift)" - bundle exec fastlane build_demo scheme:Gravatar-Demo - echo "--- ๐Ÿ›  Building Demo (SwiftUI)" - bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo + command: .buildkite/commands/build-demos.sh ################### # Validate Podspec @@ -53,8 +49,8 @@ steps: - label: "โฌ†๏ธ Publish Podspec" key: "publish" command: | - .buildkite/publish-pod.sh "Gravatar.podspec" - .buildkite/publish-pod.sh "GravatarUI.podspec" + .buildkite/commands/publish-pod.sh "Gravatar.podspec" + .buildkite/commands/publish-pod.sh "GravatarUI.podspec" plugins: [$CI_TOOLKIT] depends_on: - "test" From 11da73e38b9d9fb73976937fc32e21528ba35a96 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 15:50:56 -0500 Subject: [PATCH 09/20] Make CI use make commands to build demos --- .buildkite/commands/build-demos.sh | 10 ---------- .buildkite/pipeline.yml | 14 +++++++++++--- Makefile | 14 ++++++++++---- 3 files changed, 21 insertions(+), 17 deletions(-) delete mode 100644 .buildkite/commands/build-demos.sh diff --git a/.buildkite/commands/build-demos.sh b/.buildkite/commands/build-demos.sh deleted file mode 100644 index 854534d9..00000000 --- a/.buildkite/commands/build-demos.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -eu - -echo "--- :rubygems: Setting up Gems" -install_gems - -echo "--- ๐Ÿ›  Building Demo (Swift)" -bundle exec fastlane build_demo scheme:Gravatar-Demo - -echo "--- ๐Ÿ›  Building Demo (SwiftUI)" -bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo \ No newline at end of file diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 95aa31a1..6d58073b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -24,15 +24,23 @@ steps: - label: "๐Ÿงช Build and Test" key: "test" command: | - validate_swift_package - plugins: [$CI_TOOLKIT] + echo "--- ๐Ÿ›  Building + Testing" + make test ################# # Build Demo ################# - label: "๐Ÿงช Build Demo Project" key: "test_demo" - command: .buildkite/commands/build-demos.sh + command: | + echo "--- :rubygems: Setting up Gems" + make bundle-install + + echo "--- ๐Ÿ›  Building Demo (Swift)" + make build-demo-swift + + echo "--- ๐Ÿ›  Building Demo (SwiftUI)" + make build-demo-swiftui ################### # Validate Podspec diff --git a/Makefile b/Makefile index 28ea75c2..8f8708f4 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,20 @@ dev: dev-demo: xed Demo/ -test: +test: bundle-install bundle exec fastlane test -build-demo: +build-demo: build-demo-swift build-demo-swiftui + +build-demo-swift: bundle-install bundle exec fastlane build_demo scheme:Gravatar-Demo + +build-demo-swiftui: bundle-install bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo +bundle-install: + bundle install + swiftformat: swift package plugin \ --allow-writing-to-package-directory \ @@ -28,11 +35,10 @@ lint: swiftformat \ --lint -validate-pod: +validate-pod: bundle-install # For some reason this fixes a failure in `lib lint` # https://github.com/Automattic/buildkite-ci/issues/7 xcrun simctl list >> /dev/null - bundle install bundle exec pod lib lint \ --include-podspecs="*.podspec" \ --verbose --fail-fast \ No newline at end of file From 7e8fd1cdda7ac88cfc48df3bb5780cc27127bd70 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 16:45:18 -0500 Subject: [PATCH 10/20] Configure Demo app builds in CI to "build_for_testing" instead of trying to build the app --- fastlane/Fastfile | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 2e2482a7..62d8050c 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -4,7 +4,7 @@ default_platform(:ios) SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS = '' OS = '17.2' -IPHONE_DEVICE = 'iPhone SE (3rd generation)' +IPHONE_DEVICE = "iPhone SE (3rd generation) (#{OS})" platform :ios do desc 'Builds the project and runs tests' @@ -24,20 +24,16 @@ platform :ios do lane :build_demo do |options| scheme = options.fetch(:scheme, 'Gravatar-Demo') - build_ios_app( + scan( project: 'Demo/Gravatar-Demo.xcodeproj', scheme: scheme, configuration: 'Debug', - destination: "platform=iOS Simulator,OS=#{OS},name=#{IPHONE_DEVICE}", + device: IPHONE_DEVICE, + clean: true, + build_for_testing: true, + buildlog_path: File.join(__dir__, 'build', 'logs'), + derived_data_path: File.join(__dir__, 'build', 'derived-data'), disable_package_automatic_updates: true, - export_method: 'development', - export_options: { - provisioningProfiles: { - "com.automattic.gravatar-sdk-demo" => "Gravatar Demo App Development", - "com.automattic.gravatar-sdk-demo-swiftui" => "Gravatar Demo App Development" - } - }, - output_directory: 'build' ) end end \ No newline at end of file From fd58bbd3c87d6ef52e9e466ad6a8227fa4bd447d Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 17:21:18 -0500 Subject: [PATCH 11/20] Refactor how we build the demos so that we take advantage of the caching that `install-gems` tool provides --- .buildkite/commands/build-demos.sh | 10 ++++++++++ .buildkite/commands/validate-pods.sh | 12 ++++++++++++ .buildkite/pipeline.yml | 18 ++++++------------ 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 .buildkite/commands/build-demos.sh create mode 100644 .buildkite/commands/validate-pods.sh diff --git a/.buildkite/commands/build-demos.sh b/.buildkite/commands/build-demos.sh new file mode 100644 index 00000000..854534d9 --- /dev/null +++ b/.buildkite/commands/build-demos.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eu + +echo "--- :rubygems: Setting up Gems" +install_gems + +echo "--- ๐Ÿ›  Building Demo (Swift)" +bundle exec fastlane build_demo scheme:Gravatar-Demo + +echo "--- ๐Ÿ›  Building Demo (SwiftUI)" +bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo \ No newline at end of file diff --git a/.buildkite/commands/validate-pods.sh b/.buildkite/commands/validate-pods.sh new file mode 100644 index 00000000..5425cff3 --- /dev/null +++ b/.buildkite/commands/validate-pods.sh @@ -0,0 +1,12 @@ +#!/bin/bash -eu + +echo "--- :rubygems: Setting up Gems" +install_gems + +echo "--- :microscope: Validate Podspec" +# For some reason this fixes a failure in `lib lint` +# https://github.com/Automattic/buildkite-ci/issues/7 +xcrun simctl list >> /dev/null +bundle exec pod lib lint \ + --include-podspecs="*.podspec" \ + --verbose --fail-fast \ No newline at end of file diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 6d58073b..f2eef682 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -24,8 +24,8 @@ steps: - label: "๐Ÿงช Build and Test" key: "test" command: | - echo "--- ๐Ÿ›  Building + Testing" - make test + validate_swift_package + plugins: [$CI_TOOLKIT] ################# # Build Demo @@ -33,14 +33,8 @@ steps: - label: "๐Ÿงช Build Demo Project" key: "test_demo" command: | - echo "--- :rubygems: Setting up Gems" - make bundle-install - - echo "--- ๐Ÿ›  Building Demo (Swift)" - make build-demo-swift - - echo "--- ๐Ÿ›  Building Demo (SwiftUI)" - make build-demo-swiftui + .buildkite/commands/build-demos.sh + plugins: [$CI_TOOLKIT] ################### # Validate Podspec @@ -48,8 +42,8 @@ steps: - label: "๐Ÿงช Validate Podspec" key: "validate" command: | - echo "--- :microscope: Validate Podspec" - make validate-pod + .buildkite/commands/validate-pods.sh + plugins: [$CI_TOOLKIT] ################# # Publish the Podspec (if we're building a tag) From 06fd0218c3c2d4026b478475745b7bac97c0fadf Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 18:16:58 -0500 Subject: [PATCH 12/20] Refactor `publish-pods.sh` so that we first verify that all version numbers are correct before publishing any --- .buildkite/commands/publish-pod.sh | 18 --------------- .buildkite/commands/publish-pods.sh | 35 +++++++++++++++++++++++++++++ .buildkite/pipeline.yml | 3 +-- 3 files changed, 36 insertions(+), 20 deletions(-) delete mode 100755 .buildkite/commands/publish-pod.sh create mode 100755 .buildkite/commands/publish-pods.sh diff --git a/.buildkite/commands/publish-pod.sh b/.buildkite/commands/publish-pod.sh deleted file mode 100755 index dc4073dc..00000000 --- a/.buildkite/commands/publish-pod.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -eu - -if [ $# -ne 1 ]; then - echo "Error: CocoaPods publishing failed. One (and only one) podspec must be specified." - exit 1 -fi - -PODSPEC_PATH="$1" -SLACK_WEBHOOK=$PODS_SLACK_WEBHOOK - -echo "--- :rubygems: Setting up Gems" -install_gems - -echo "--- :cocoapods: Publishing Pod to CocoaPods CDN" -publish_pod $PODSPEC_PATH - -echo "--- :slack: Notifying Slack" -slack_notify_pod_published $PODSPEC_PATH "$SLACK_WEBHOOK" \ No newline at end of file diff --git a/.buildkite/commands/publish-pods.sh b/.buildkite/commands/publish-pods.sh new file mode 100755 index 00000000..3f308a9f --- /dev/null +++ b/.buildkite/commands/publish-pods.sh @@ -0,0 +1,35 @@ +#!/bin/bash -eu + +if [ $# -eq 0 ]; then + echo "Error: CocoaPods publishing failed. All podspecs must be specified, separated by spaces." + exit 1 +fi + +SLACK_WEBHOOK=$PODS_SLACK_WEBHOOK +PODSPEC_PATHS=("$@") + +# Verify that all versions are current before publishing any podspecs +echo "--- :cocoapods: Verify version of all podspecs" +invalid_pod=false +for podspec_path in "${PODSPEC_PATHS[@]}"; do + pod_version=$(bundle exec pod ipc spec "$podspec_path" | jq -r '.version') + if [ -n "$BUILDKITE_TAG" ] && [ "$BUILDKITE_TAG" != "$pod_version" ]; then + echo "Tag $BUILDKITE_TAG does not match version $pod_version from $podspec_path." + invalid_pod=true + fi +done + +if ( $invalid_pod ); then + exit 1 +fi + +echo "--- :rubygems: Setting up Gems" +install_gems + +for podspec_path in "${PODSPEC_PATHS[@]}"; do + echo "--- :cocoapods: Publishing Pod to CocoaPods CDN" + publish_pod $podspec_path + + echo "--- :slack: Notifying Slack" + slack_notify_pod_published $podspec_path "$SLACK_WEBHOOK" +done \ No newline at end of file diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f2eef682..09ea6073 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,8 +51,7 @@ steps: - label: "โฌ†๏ธ Publish Podspec" key: "publish" command: | - .buildkite/commands/publish-pod.sh "Gravatar.podspec" - .buildkite/commands/publish-pod.sh "GravatarUI.podspec" + .buildkite/commands/publish-pods.sh "Gravatar.podspec" "GravatarUI.podspec" plugins: [$CI_TOOLKIT] depends_on: - "test" From 7ad540e7fd2a39b41ae09f76250f25e6bcbf9560 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 19:37:49 -0500 Subject: [PATCH 13/20] Remove unused `SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS` from Fastlfile --- fastlane/Fastfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 62d8050c..20d30c8b 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -2,7 +2,6 @@ default_platform(:ios) -SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS = '' OS = '17.2' IPHONE_DEVICE = "iPhone SE (3rd generation) (#{OS})" @@ -16,8 +15,7 @@ platform :ios do prelaunch_simulator: true, clean: true, buildlog_path: File.join(__dir__, '.build', 'logs'), - derived_data_path: File.join(__dir__, '.build', 'derived-data'), - xcargs: SWIFTLINT_PLUGIN_VALIDATION_BYPASS_XCARGS + derived_data_path: File.join(__dir__, '.build', 'derived-data') ) end From 06a111c7140fbb4c97d7112bf68ddf89074badcc Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Thu, 21 Mar 2024 19:40:58 -0500 Subject: [PATCH 14/20] Add helpful comments --- fastlane/Fastfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 20d30c8b..f0ee7ce8 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -19,9 +19,12 @@ platform :ios do ) end + desc 'Builds the Gravatar-Demo project with a specific scheme' lane :build_demo do |options| scheme = options.fetch(:scheme, 'Gravatar-Demo') + # We only need to build for testing to ensure that the project builds. + # There are no tests in the the Demo apps scan( project: 'Demo/Gravatar-Demo.xcodeproj', scheme: scheme, From 1a48f4d8147a15b4d917f0114d136a3cc1045b4e Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Fri, 22 Mar 2024 14:12:54 -0500 Subject: [PATCH 15/20] Ensure that all files end with a blank new line --- .buildkite/commands/build-demos.sh | 2 +- .buildkite/commands/publish-pods.sh | 2 +- .buildkite/commands/validate-pods.sh | 2 +- Gravatar.podspec | 1 - GravatarUI.podspec | 2 -- fastlane/Fastfile | 2 +- 6 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.buildkite/commands/build-demos.sh b/.buildkite/commands/build-demos.sh index 854534d9..fa538921 100644 --- a/.buildkite/commands/build-demos.sh +++ b/.buildkite/commands/build-demos.sh @@ -7,4 +7,4 @@ echo "--- ๐Ÿ›  Building Demo (Swift)" bundle exec fastlane build_demo scheme:Gravatar-Demo echo "--- ๐Ÿ›  Building Demo (SwiftUI)" -bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo \ No newline at end of file +bundle exec fastlane build_demo scheme:Gravatar-SwiftUI-Demo diff --git a/.buildkite/commands/publish-pods.sh b/.buildkite/commands/publish-pods.sh index 3f308a9f..d9fa2fc1 100755 --- a/.buildkite/commands/publish-pods.sh +++ b/.buildkite/commands/publish-pods.sh @@ -32,4 +32,4 @@ for podspec_path in "${PODSPEC_PATHS[@]}"; do echo "--- :slack: Notifying Slack" slack_notify_pod_published $podspec_path "$SLACK_WEBHOOK" -done \ No newline at end of file +done diff --git a/.buildkite/commands/validate-pods.sh b/.buildkite/commands/validate-pods.sh index 5425cff3..11c8c7a9 100644 --- a/.buildkite/commands/validate-pods.sh +++ b/.buildkite/commands/validate-pods.sh @@ -9,4 +9,4 @@ echo "--- :microscope: Validate Podspec" xcrun simctl list >> /dev/null bundle exec pod lib lint \ --include-podspecs="*.podspec" \ - --verbose --fail-fast \ No newline at end of file + --verbose --fail-fast diff --git a/Gravatar.podspec b/Gravatar.podspec index 0c4e7431..aeb46b18 100644 --- a/Gravatar.podspec +++ b/Gravatar.podspec @@ -35,4 +35,3 @@ Pod::Spec.new do |s| swift_unit_tests.requires_app_host = false end end - diff --git a/GravatarUI.podspec b/GravatarUI.podspec index d599aad9..d484d0ae 100644 --- a/GravatarUI.podspec +++ b/GravatarUI.podspec @@ -36,5 +36,3 @@ Pod::Spec.new do |s| swift_unit_tests.requires_app_host = false end end - - \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index f0ee7ce8..6e8399d1 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -37,4 +37,4 @@ platform :ios do disable_package_automatic_updates: true, ) end -end \ No newline at end of file +end From 3f42ca169c4f5b87af346a91332505b391ba8f5a Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Mon, 25 Mar 2024 12:07:58 -0500 Subject: [PATCH 16/20] Consolidate podspec version strings into `version.rb` --- Gravatar.podspec | 4 +++- GravatarUI.podspec | 4 +++- version.rb | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 version.rb diff --git a/Gravatar.podspec b/Gravatar.podspec index aeb46b18..d54e6ad9 100644 --- a/Gravatar.podspec +++ b/Gravatar.podspec @@ -1,6 +1,8 @@ +require_relative 'version' + Pod::Spec.new do |s| s.name = 'Gravatar' - s.version = '0.1.1' + s.version = Gravatar::VERSION s.summary = 'A convient library for accessing the Gravatar API' s.homepage = 'https://gravatar.com' diff --git a/GravatarUI.podspec b/GravatarUI.podspec index d484d0ae..bd2e10d9 100644 --- a/GravatarUI.podspec +++ b/GravatarUI.podspec @@ -1,6 +1,8 @@ +require_relative 'version' + Pod::Spec.new do |s| s.name = 'GravatarUI' - s.version = '0.1.1' + s.version = Gravatar::VERSION s.summary = 'A convient library of Gravatar UI components' s.homepage = 'https://gravatar.com' diff --git a/version.rb b/version.rb new file mode 100644 index 00000000..ee9eb8de --- /dev/null +++ b/version.rb @@ -0,0 +1,3 @@ +module Gravatar + VERSION = '0.1.1'.freeze +end From 4986fa3019ae466d72df63019598aa581643a753 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Mon, 25 Mar 2024 12:44:22 -0500 Subject: [PATCH 17/20] Now that all podspecs import the same version, simplify the `publish-pods.sh` script --- .buildkite/commands/publish-pods.sh | 32 ++++++++--------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/.buildkite/commands/publish-pods.sh b/.buildkite/commands/publish-pods.sh index d9fa2fc1..3bf9351a 100755 --- a/.buildkite/commands/publish-pods.sh +++ b/.buildkite/commands/publish-pods.sh @@ -1,35 +1,19 @@ #!/bin/bash -eu -if [ $# -eq 0 ]; then - echo "Error: CocoaPods publishing failed. All podspecs must be specified, separated by spaces." +if [ $# -ne 1 ]; then + echo "Error: CocoaPods publishing failed. Specify a path to a podspec." exit 1 fi SLACK_WEBHOOK=$PODS_SLACK_WEBHOOK -PODSPEC_PATHS=("$@") - -# Verify that all versions are current before publishing any podspecs -echo "--- :cocoapods: Verify version of all podspecs" -invalid_pod=false -for podspec_path in "${PODSPEC_PATHS[@]}"; do - pod_version=$(bundle exec pod ipc spec "$podspec_path" | jq -r '.version') - if [ -n "$BUILDKITE_TAG" ] && [ "$BUILDKITE_TAG" != "$pod_version" ]; then - echo "Tag $BUILDKITE_TAG does not match version $pod_version from $podspec_path." - invalid_pod=true - fi -done - -if ( $invalid_pod ); then - exit 1 -fi +PODSPEC_PATH="$1" echo "--- :rubygems: Setting up Gems" install_gems -for podspec_path in "${PODSPEC_PATHS[@]}"; do - echo "--- :cocoapods: Publishing Pod to CocoaPods CDN" - publish_pod $podspec_path +echo "--- :cocoapods: Publishing Pod to CocoaPods CDN" +publish_pod $PODSPEC_PATH + +echo "--- :slack: Notifying Slack" +slack_notify_pod_published $PODSPEC_PATH "$SLACK_WEBHOOK" - echo "--- :slack: Notifying Slack" - slack_notify_pod_published $podspec_path "$SLACK_WEBHOOK" -done From a2e1be85ce8a8ac27d961f3483c008848e7d0e2e Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Mon, 25 Mar 2024 12:45:21 -0500 Subject: [PATCH 18/20] Rename `publish-pods.sh` to `publish-pod.sh`, since it now handles each pod individually --- .buildkite/commands/{publish-pods.sh => publish-pod.sh} | 0 .buildkite/pipeline.yml | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename .buildkite/commands/{publish-pods.sh => publish-pod.sh} (100%) diff --git a/.buildkite/commands/publish-pods.sh b/.buildkite/commands/publish-pod.sh similarity index 100% rename from .buildkite/commands/publish-pods.sh rename to .buildkite/commands/publish-pod.sh diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 09ea6073..f2eef682 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,7 +51,8 @@ steps: - label: "โฌ†๏ธ Publish Podspec" key: "publish" command: | - .buildkite/commands/publish-pods.sh "Gravatar.podspec" "GravatarUI.podspec" + .buildkite/commands/publish-pod.sh "Gravatar.podspec" + .buildkite/commands/publish-pod.sh "GravatarUI.podspec" plugins: [$CI_TOOLKIT] depends_on: - "test" From 1c9986a3ffb2f129fcee9727a47e07bb44994357 Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Mon, 25 Mar 2024 12:48:20 -0500 Subject: [PATCH 19/20] Escape the `$PODSPEC_PATH` variables, defensively --- .buildkite/commands/publish-pod.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/commands/publish-pod.sh b/.buildkite/commands/publish-pod.sh index 3bf9351a..04ff4f44 100755 --- a/.buildkite/commands/publish-pod.sh +++ b/.buildkite/commands/publish-pod.sh @@ -12,8 +12,8 @@ echo "--- :rubygems: Setting up Gems" install_gems echo "--- :cocoapods: Publishing Pod to CocoaPods CDN" -publish_pod $PODSPEC_PATH +publish_pod "$PODSPEC_PATH" echo "--- :slack: Notifying Slack" -slack_notify_pod_published $PODSPEC_PATH "$SLACK_WEBHOOK" +slack_notify_pod_published "$PODSPEC_PATH" "$SLACK_WEBHOOK" From 878f43cf7e50ad76fe40b6530c0669cbfa0af5ef Mon Sep 17 00:00:00 2001 From: Andrew Montgomery Date: Mon, 25 Mar 2024 12:49:39 -0500 Subject: [PATCH 20/20] Change `Publish Podspec` to be plural: `Publish Podspecs` --- .buildkite/pipeline.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f2eef682..f107bf27 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -45,10 +45,10 @@ steps: .buildkite/commands/validate-pods.sh plugins: [$CI_TOOLKIT] - ################# - # Publish the Podspec (if we're building a tag) - ################# - - label: "โฌ†๏ธ Publish Podspec" + ####################### + # Publish the Podspecs (if we're building a tag) + ####################### + - label: "โฌ†๏ธ Publish Podspecs" key: "publish" command: | .buildkite/commands/publish-pod.sh "Gravatar.podspec"