diff --git a/.buildkite/commands/release-build-jetpack.sh b/.buildkite/commands/release-build-jetpack.sh old mode 100644 new mode 100755 diff --git a/.buildkite/commands/release-build-wordpress-internal.sh b/.buildkite/commands/release-build-wordpress-internal.sh old mode 100644 new mode 100755 diff --git a/.buildkite/commands/release-build-wordpress.sh b/.buildkite/commands/release-build-wordpress.sh old mode 100644 new mode 100755 index f82acbe8b2e5..f05f86f65253 --- a/.buildkite/commands/release-build-wordpress.sh +++ b/.buildkite/commands/release-build-wordpress.sh @@ -19,4 +19,7 @@ echo "--- :closed_lock_with_key: Installing Secrets" bundle exec fastlane run configure_apply echo "--- :hammer_and_wrench: Building" -bundle exec fastlane build_and_upload_app_store_connect skip_confirm:true create_gh_release:true +bundle exec fastlane build_and_upload_app_store_connect \ + skip_confirm:true \ + create_gh_release:true \ + beta_release:${1:-true} # use first call param, default to true for safety diff --git a/.buildkite/release-builds.yml b/.buildkite/release-builds.yml index 0fa25a6f7742..4638aebe612c 100644 --- a/.buildkite/release-builds.yml +++ b/.buildkite/release-builds.yml @@ -15,7 +15,7 @@ common_params: steps: - label: "🛠 WordPress Release Build (App Store Connect)" - command: ".buildkite/commands/release-build-wordpress.sh" + command: ".buildkite/commands/release-build-wordpress.sh $BETA_RELEASE" env: *common_env plugins: *common_plugins notify: diff --git a/.circleci/cache-version b/.circleci/cache-version deleted file mode 100644 index 76dd971a84de..000000000000 --- a/.circleci/cache-version +++ /dev/null @@ -1,2 +0,0 @@ -# To invalidate the cache, generate a new UUID using `uuidgen` on the command line then paste it here -D557401C-64E1-4BE6-B525-3E0CAF51B452 diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1cc7a70542e3..000000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,298 +0,0 @@ -version: 2.1 - -orbs: - # Using 1.0 of the Orbs means it will use the latest 1.0.x version from https://github.com/wordpress-mobile/circleci-orbs - ios: wordpress-mobile/ios@1.0 - git: wordpress-mobile/git@1.0 - slack: circleci/slack@3.4.2 - -parameters: - beta_build: - type: boolean - default: false - release_build: - type: boolean - default: false - -xcode_version: &xcode_version - xcode-version: "13.0.0" - -iphone_test_device: &iphone_test_device - device: iPhone 12 - ios-version: "15.0" - -ipad_test_device: &ipad_test_device - device: iPad Air (4th generation) - ios-version: "15.0" - -commands: - fix-image: - steps: - - run: - name: Fix CI Image - command: | - # Add `/usr/local/bin` to the Xcode 11.2 image's $PATH in order to be able to use dependencies - - if [ $(echo $PATH | ruby -e "puts Kernel.gets.include?('/usr/local/bin')") != "true" ]; then - echo 'export PATH=/usr/local/bin:$PATH' >> $BASH_ENV - echo "Manually added `/usr/local/bin` to the $PATH:" - echo $PATH - fi - - chruby ruby-$(cat .ruby-version) - gem install bundler - - # Prevent fastlane from checking for updates, also removing the verbose fastlane changelog at the end of each invocation. - echo "export FASTLANE_SKIP_UPDATE_CHECK=1" >> $BASH_ENV - - run: - name: Fix SSH setup to fetch Swift packages from GitHub - command: | - for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts || true - -jobs: - Build Tests: - parameters: - device: - type: string - description: The device (e.g. "iPhone 11") to use when compiling the build. - ios-version: - description: The iOS deployment target (e.g. "13.0") used to compile the build that will be used for testing. - type: string - executor: - name: ios/default - <<: *xcode_version - steps: - - fix-image - - git/shallow-checkout - - ios/install-dependencies: - bundle-install: true - pod-install: true - cache-prefix: cache-prefix-{{ checksum ".circleci/cache-version" }} - - run: - name: Install Dependencies - command: rake dependencies - - run: - name: Build for Testing - command: bundle exec fastlane build_for_testing device:'<< parameters.device >>' ios-version:'<< parameters.ios-version >>' - - persist_to_workspace: - root: ./ - paths: - - DerivedData/Build/Products - - Pods/WordPressMocks - - vendor/bundle - Unit Tests: - parameters: - device: - type: string - description: The device (e.g. "iPhone 11") to use when running unit tests. - ios-version: - description: The iOS version (e.g. "14.0") of the device used to run tests. - type: string - executor: - name: ios/default - <<: *xcode_version - steps: - - fix-image - - git/shallow-checkout - - attach_workspace: - at: ./ - - run: - name: Prepare Bundle - command: bundle --path vendor/bundle - - run: - name: Run Unit Tests - command: bundle exec fastlane test_without_building name:WordPressUnitTests device:'<< parameters.device >>' ios-version:'<< parameters.ios-version >>' - - ios/save-xcodebuild-artifacts: - result-bundle-path: build/results - UI Tests: - parameters: - device: - type: string - description: The device (e.g. "iPhone 11") to use when running tests. - ios-version: - description: The iOS version (e.g. "14.0") of the device used to run tests. - type: string - post-to-slack: - description: Post to Slack when tests fail. SLACK_WEBHOOK ENV variable must be set. - type: boolean - default: false - executor: - name: ios/default - <<: *xcode_version - steps: - - fix-image - - git/shallow-checkout - - attach_workspace: - at: ./ - - run: - name: Prepare Bundle - command: bundle --path vendor/bundle - - run: - name: Run mocks - command: ./Pods/WordPressMocks/scripts/start.sh 8282 - background: true - - run: - name: Run UI Tests - command: bundle exec fastlane test_without_building name:WordPressUITests device:'<< parameters.device >>' ios-version:'<< parameters.ios-version >>' - - ios/save-xcodebuild-artifacts: - result-bundle-path: build/results - - when: - condition: << parameters.post-to-slack >> - steps: - - run: - name: Prepare Slack message - when: always - command: | - # Get the name of the device that is running. - echo "export SLACK_FAILURE_MESSAGE=':red_circle: WordPress iOS UI tests failed on << parameters.device >> in \`${CIRCLE_BRANCH}\` branch by ${CIRCLE_USERNAME}.\n\nPlease reach out in #platform9 if you think this failure is not caused by your changes, so we can investigate.'" >> $BASH_ENV - - slack/status: - fail_only: true - include_job_number_field: false - include_project_field: false - failure_message: '${SLACK_FAILURE_MESSAGE}' - Release Build: - executor: - name: ios/default - <<: *xcode_version - environment: - HOMEBREW_NO_AUTO_UPDATE: 1 - steps: - - fix-image - - run: - name: Setup Notifications - command: | - echo "export SLACK_FAILURE_MESSAGE=':red_circle: Build for WordPress iOS failed!'" >> $BASH_ENV - - git/shallow-checkout - - ios/install-dependencies: - bundle-install: true - pod-install: true - cache-prefix: cache-prefix-{{ checksum ".circleci/cache-version" }} - - run: - name: Copy Secrets - command: bundle exec fastlane run configure_apply - - run: - name: Install other tools - command: | - brew update # Update homebrew to temporarily fix a bintray issue - brew install imagemagick - brew install ghostscript - curl -sL https://sentry.io/get-cli/ | bash - - run: - name: Setup notifications - command: | - APP_VERSION=$(cat config/Version.Public.xcconfig | grep "^VERSION_LONG" | cut -d "=" -f2) - echo "export SLACK_FAILURE_MESSAGE=':red_circle: Build for WordPress iOS $APP_VERSION failed!'" >> $BASH_ENV - echo "export SLACK_SUCCESS_MESSAGE=':tada: WordPress iOS $APP_VERSION has been deployed!'" >> $BASH_ENV - - when: - condition: << pipeline.parameters.beta_build >> - steps: - - run: - name: Build - command: | - bundle exec fastlane build_and_upload_beta_release skip_confirm:true create_gh_release:true - bundle exec fastlane build_and_upload_jetpack_for_app_store - no_output_timeout: 60m - - when: - condition: << pipeline.parameters.release_build >> - steps: - - run: - name: Build - command: | - bundle exec fastlane build_and_upload_stable_release skip_confirm:true create_gh_release:true - bundle exec fastlane build_and_upload_jetpack_for_app_store - no_output_timeout: 60m - - slack/status: - include_job_number_field: false - include_project_field: false - include_visit_job_action: false - webhook: '${SLACK_BUILD_WEBHOOK}' - failure_message: '${SLACK_FAILURE_MESSAGE}' - success_message: '${SLACK_SUCCESS_MESSAGE}' - Build Jetpack: - executor: - name: ios/default - <<: *xcode_version - environment: - HOMEBREW_NO_AUTO_UPDATE: 1 - steps: - - fix-image - - git/shallow-checkout - - ios/install-dependencies: - bundle-install: true - pod-install: true - cache-prefix: cache-prefix-{{ checksum ".circleci/cache-version" }} - - run: - name: Copy Secrets - command: bundle exec fastlane run configure_apply - - run: - name: Install other tools - command: | - brew update # Update homebrew to temporarily fix a bintray issue - brew install imagemagick - brew install ghostscript - curl -sL https://sentry.io/get-cli/ | bash - - run: - name: Build - command: bundle exec fastlane build_jetpack_for_testing - no_output_timeout: 60m -workflows: - wordpress_ios: - when: - and: - - not: << pipeline.parameters.beta_build >> - - not: << pipeline.parameters.release_build >> - jobs: - - Build Tests: - <<: *iphone_test_device - - Unit Tests: - <<: *iphone_test_device - requires: [ "Build Tests" ] - # Always run UI tests on trunk and release branches - - UI Tests: - name: UI Tests (iPhone) - <<: *iphone_test_device - post-to-slack: true - requires: [ "Build Tests" ] - filters: - branches: - only: - - trunk - - /^release.*/ - - /^gutenberg\/integrate_release_.*/ - - UI Tests: - name: UI Tests (iPad) - <<: *ipad_test_device - post-to-slack: true - requires: [ "Build Tests" ] - filters: - branches: - only: - - trunk - - /^release.*/ - - /^gutenberg\/integrate_release_.*/ - - Build Jetpack: - name: Build Jetpack (without testing) - #Optionally run UI tests on PRs - - Optional Tests: - type: approval - requires: [ "Build Tests" ] - filters: - branches: - ignore: - - trunk - - /^release.*/ - - /^gutenberg\/integrate_release_.*/ - - UI Tests: - name: UI Tests (iPhone) - <<: *iphone_test_device - requires: [ "Optional Tests" ] - - UI Tests: - name: UI Tests (iPad) - <<: *ipad_test_device - requires: [ "Optional Tests" ] - - Release Build: - when: - or: [ << pipeline.parameters.beta_build >>, << pipeline.parameters.release_build >> ] - jobs: - - Release Build diff --git a/Gemfile.lock b/Gemfile.lock index 77d7a8e6df01..6e3a13bbb012 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -33,6 +33,8 @@ GEM aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) bigdecimal (1.4.4) + buildkit (1.4.5) + sawyer (>= 0.6) chroma (0.2.0) claide (1.1.0) cocoapods (1.11.2) @@ -161,9 +163,10 @@ GEM xcpretty-travis-formatter (>= 0.0.3) fastlane-plugin-appcenter (1.11.1) fastlane-plugin-sentry (1.11.0) - fastlane-plugin-wpmreleasetoolkit (2.3.0) + fastlane-plugin-wpmreleasetoolkit (3.0.0) activesupport (~> 5) bigdecimal (~> 1.4) + buildkit (~> 1.4) chroma (= 0.2.0) diffy (~> 3.3) git (~> 1.3) @@ -245,7 +248,7 @@ GEM nokogiri (1.12.5) mini_portile2 (~> 2.6.1) racc (~> 1.4) - octokit (4.21.0) + octokit (4.22.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) oj (3.13.10) @@ -331,7 +334,7 @@ DEPENDENCIES fastlane (~> 2.174) fastlane-plugin-appcenter (~> 1.8) fastlane-plugin-sentry - fastlane-plugin-wpmreleasetoolkit (~> 2.3) + fastlane-plugin-wpmreleasetoolkit (~> 3.0) octokit (~> 4.0) rake rmagick (~> 3.2.0) diff --git a/README.md b/README.md index 33a44b5a1fc8..e47b44f63846 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # WordPress for iOS # -[![CircleCI](https://circleci.com/gh/wordpress-mobile/WordPress-iOS.svg?style=svg)](https://circleci.com/gh/wordpress-mobile/WordPress-iOS) +[![Build status](https://badge.buildkite.com/2f3fbb17bfbb5bba508efd80f1ea8d640db5ca2465a516a457.svg)](https://buildkite.com/automattic/wordpress-ios) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) ## Build Instructions diff --git a/Rakefile b/Rakefile index 1a35ee5c7707..18e83000ae30 100644 --- a/Rakefile +++ b/Rakefile @@ -345,10 +345,7 @@ namespace :install do end def get_ci_xcode_version - ci_config = File.read(".circleci/config.yml") - specs = YAML.load(ci_config) - - ci_version = specs["jobs"]["Build Tests"]["executor"]["xcode-version"] + ci_version = File.read(".xcversion") end end diff --git a/fastlane/Fastfile b/fastlane/Fastfile index dfddef8c4648..a6b20892027e 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -57,6 +57,9 @@ before_all do |lane| # Ensure we use the latest version of the toolkit check_for_toolkit_updates unless is_ci || ENV['FASTLANE_SKIP_TOOLKIT_UPDATE_CHECK'] + # Fixes weird Keychain bugs + setup_ci + # Check that the env files exist unless is_ci || File.file?(USER_ENV_FILE_PATH) example_path = 'fastlane/env/user.env-example ' @@ -65,11 +68,6 @@ before_all do |lane| unless File.file?(PROJECT_ENV_FILE_PATH) UI.user_error!("project.env not found at #{PROJECT_ENV_FILE_PATH}: Make sure your configuration is up to date with `rake dependencies`") end - - # This allows code signing to work on CircleCI - # It is skipped if this isn't running on CI - # See https://circleci.com/docs/2.0/ios-codesigning/ - setup_circle_ci end platform :ios do @@ -469,75 +467,6 @@ platform :ios do download_jetpack_localized_app_store_metadata end - ##################################################################################### - # build_and_upload_beta_release - # ----------------------------------------------------------------------------------- - # This lane builds a beta release of the app and optionally uploads - # it for both internal and external distribution - # ----------------------------------------------------------------------------------- - # Usage: - # bundle exec fastlane build_and_upload_beta_release [skip_confirm:] - # [create_gh_release:] - # - # Example: - # bundle exec fastlane build_and_upload_beta_release - # bundle exec fastlane build_and_upload_beta_release skip_confirm:true - # bundle exec fastlane build_and_upload_beta_release create_gh_release:true - ##################################################################################### - desc 'Builds and uploads a beta release for distribution' - lane :build_and_upload_beta_release do |options| - build_and_upload_release( - skip_confirm: options[:skip_confirm], - create_gh_release: options[:create_gh_release], - beta_release: true - ) - end - - ##################################################################################### - # build_and_upload_stable_release - # ----------------------------------------------------------------------------------- - # This lane builds a stable release of the app and optionally uploads - # it for distribution - # ----------------------------------------------------------------------------------- - # Usage: - # bundle exec fastlane build_and_upload_stable_release [skip_confirm:] - # [create_gh_release:] - # - # Example: - # bundle exec fastlane build_and_upload_stable_release - # bundle exec fastlane build_and_upload_stable_release skip_confirm:true - # bundle exec fastlane build_and_upload_stable_release create_gh_release:true - ##################################################################################### - desc 'Builds and uploads a stable release for distribution' - lane :build_and_upload_stable_release do |options| - build_and_upload_release( - skip_confirm: options[:skip_confirm], - create_gh_release: options[:create_gh_release], - beta_release: false - ) - end - - ##################################################################################### - # build_and_upload_release [Deprecated - Can be removed once CircleCI is no longer in use] - # ----------------------------------------------------------------------------------- - # This lane builds the app and uploads it for both internal and external distribution - # ----------------------------------------------------------------------------------- - # Usage: - # bundle exec fastlane build_and_upload_release [skip_confirm:] - # [create_gh_release:] [beta_release:] - # - # Example: - # bundle exec fastlane build_and_upload_release - # bundle exec fastlane build_and_upload_release skip_confirm:true - # bundle exec fastlane build_and_upload_release create_gh_release:true - # bundle exec fastlane build_and_upload_release beta_release:true - ##################################################################################### - desc 'Builds and uploads for distribution' - lane :build_and_upload_release do |options| - build_and_upload_app_center(options) if options[:beta_release] - build_and_upload_app_store_connect(options) - end - ##################################################################################### # build_and_upload_app_store_connect # ----------------------------------------------------------------------------------- @@ -847,12 +776,7 @@ platform :ios do # ##################################################################################### lane :trigger_beta_build do |options| - circleci_trigger_job( - circle_ci_token: ENV['CIRCLE_CI_AUTH_TOKEN'], - repository: REPOSITORY_NAME, - branch: options[:branch_to_build], - job_params: { 'beta_build' => true } - ) + trigger_buildkite_release_build(branch: options[:branch_to_build], beta: true) end ##################################################################################### @@ -865,12 +789,7 @@ platform :ios do # ##################################################################################### lane :trigger_release_build do |options| - circleci_trigger_job( - circle_ci_token: ENV['CIRCLE_CI_AUTH_TOKEN'], - repository: REPOSITORY_NAME, - branch: options[:branch_to_build], - job_params: { 'release_build' => true } - ) + trigger_buildkite_release_build(branch: options[:branch_to_build], beta: false) end ######################################################################## @@ -1052,6 +971,16 @@ def generate_installable_build_number end end +def trigger_buildkite_release_build(branch:, beta:) + buildkite_trigger_build( + buildkite_organization: 'automattic', + buildkite_pipeline: 'wordpress-ios', + branch: branch, + environment: { BETA_RELEASE: beta }, + pipeline_file: 'release-builds.yml' + ) +end + # Application-agnostic settings for the `upload_to_app_store` action, also # known as `deliver`. UPLOAD_TO_APP_STORE_COMMON_PARAMS = { diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index bb5c3d1e3d20..098c8f2fd31a 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -7,8 +7,8 @@ group :screenshots, optional: true do end # This comment avoids typing to switch to a development version for testing. -# gem 'fastlane-plugin-wpmreleasetoolkit', git: 'git@github.com:wordpress-mobile/release-toolkit', branch: 'trunk' -gem 'fastlane-plugin-wpmreleasetoolkit', '~> 2.3' +# gem 'fastlane-plugin-wpmreleasetoolkit', git: 'git@github.com:wordpress-mobile/release-toolkit', branch: '' +gem 'fastlane-plugin-wpmreleasetoolkit', '~> 3.0' gem 'fastlane-plugin-sentry' gem 'fastlane-plugin-appcenter', '~> 1.8' diff --git a/fastlane/env/user.env-example b/fastlane/env/user.env-example index 763c920ccaf1..f75ebe246bc8 100644 --- a/fastlane/env/user.env-example +++ b/fastlane/env/user.env-example @@ -5,4 +5,4 @@ GHHELPER_ACCESS= APPCENTER_API_TOKEN= SENTRY_AUTH_TOKEN= -CIRCLE_CI_AUTH_TOKEN= +BUILDKITE_TOKEN=