Skip to content

Commit

Permalink
[MBL-773] CircleCI Workspaces Integration (#1821)
Browse files Browse the repository at this point in the history
* updating circle-ci to use workspaces

* trying spm ssh workaround to add permissions for restoring spm cache

* syntax corrections

* update ruby version to 3.0.5

* move restore bundler before restore spm cache see if permissions issue persists

* update config.yml

* removing restoring and saving cache steps

* updated ios sim version in makefile - might cause the hang on the xcodebuild cmd

* maybe make bootstrap needs to run first before make test

* removed unneeded step from test_job

* added make bootstrap to build and cache step.

* bootstrap spm added back to test job

* trying to see if other make cmds run

* no need for make steps, confirmed no PWD is set in env.

* using executor

* explicitly setting the work directory for each test job and removing executor

* adding a recommended orb for running shell cmds, which is what the make file does.

* trying to override default login shell before make test

* oops forgot to remove the login option

* git clone was preventing the native-secrets rep from being cloned.

* replaced preload_simulator with orb run step

* update config.yml with create step on test job

* updated device name - might fix issue

* xcode cannot identify name of simulator if it contains the version

* update ios-certificate urls in fastfile to match format that doesn't require login, cleaned up comments in the config.yml

* testing just alpha dist

* commented out other jobs just to validate config

* making build and cache req for deploy alpha

* updated xcode version from 13.3.1 to 14.2 in fastfile

* fix cleanup step login issue, comment back in tests

* re-triggering to get code coverage checked again
  • Loading branch information
msadoon committed May 18, 2023
1 parent aee3831 commit c50512a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 103 deletions.
124 changes: 28 additions & 96 deletions .circleci/config.yml
Expand Up @@ -10,7 +10,6 @@ aws_cli_setup: &aws_cli_setup

xcode_version: &xcode_version 14.2
iphone_name: &iphone_name iPhone 8
preload_simulator: &preload_simulator xcrun instruments -w "iPhone 8 (15.5) [" || true

# Works around an issue in xcodebuild where it requires GitHub to have been added to the known_hosts in order for it to clone dependencies.
spm_ssh_workaround: &spm_ssh_workaround for ip in $(dig @1.1.1.1 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts
Expand All @@ -34,46 +33,19 @@ base_job: &base_job

test_job: &test_job
steps:
- checkout
- run:
name: SPM SSH Workaround
command: *spm_ssh_workaround
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Bootstrap
command: make bootstrap
- run:
name: Download GraphQL Schema
command: bin/apollo-schema-download.sh
- attach_workspace:
at: .
- run:
name: Pre-install simulator
command: xcrun simctl create "iPhone 8 (15.5)" com.apple.CoreSimulator.SimDeviceType.iPhone-8 com.apple.CoreSimulator.SimRuntime.iOS-15-5
- run:
name: Pre-load simulator
command: *preload_simulator
name: Create iPhone 8 iOS 15.5 Simulator
command: xcrun simctl create "iPhone 8" com.apple.CoreSimulator.SimDeviceType.iPhone-8 com.apple.CoreSimulator.SimRuntime.iOS-15-5
- macos/preboot-simulator:
version: "15.5"
platform: "iOS"
device: "iPhone 8"
- run:
name: Run tests
command: make test
no_output_timeout: "20m" # 20 minutes
- restore_cache:
name: Restore Bundler
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Install Bundler
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- run:
name: Generate Slather coverage report
command: bundle exec slather coverage -x --scheme $SCHEME ./Kickstarter.xcodeproj
Expand All @@ -82,38 +54,10 @@ test_job: &test_job

distribute_job: &distribute_job
steps:
- checkout
- attach_workspace:
at: .
- aws-cli/setup:
<<: *aws_cli_setup
- run:
name: SPM SSH Workaround
command: *spm_ssh_workaround
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Bootstrap
command: make bootstrap
- restore_cache:
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle install
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- save_cache:
key: v1-gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Increment build number
command: agvtool new-version -all $(($(date +%s)/1000))
Expand All @@ -136,8 +80,7 @@ distribute_job: &distribute_job
path: output

all_jobs: &all_jobs
- build-and-cache
- kickstarter-tests
- kickstarter-tests
- library-tests
- ksapi-tests

Expand All @@ -156,39 +99,28 @@ jobs:
- run:
name: Store Xcode Version
command: xcodebuild -version > xcode_version.txt
- restore_cache:
name: Restore SPM Cache
keys:
- spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
- run:
name: Bootstrap SPM
command: xcodebuild -resolvePackageDependencies -clonedSourcePackagesDirPath SourcePackages
- run:
name: Bootstrap
command: make bootstrap
- save_cache:
name: Cache SPM
key: spm-cache-v1-{{ checksum "./Kickstarter.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved" }}-{{ checksum "xcode_version.txt" }}
paths:
- SourcePackages
- restore_cache:
name: Restore Bundler
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Install Bundler
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- save_cache:
name: Cache Bundler
key: v1-gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Download GraphQL Schema
command: bin/apollo-schema-download.sh
- run:
name: Danger
command: bin/danger.sh
- persist_to_workspace:
root: .
paths:
- .

# Kickstarter tests
kickstarter-tests:
Expand Down Expand Up @@ -268,19 +200,12 @@ jobs:
- run:
name: Secrets
command: make secrets
- restore_cache:
keys:
- v1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle install
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- save_cache:
key: v1-gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- run:
name: Download dSYMs and upload to Crashlytics
command: bundle exec fastlane refresh_dsyms
Expand All @@ -302,9 +227,16 @@ workflows:
# Matches all_jobs
jobs:
- build-and-cache
- kickstarter-tests
- library-tests
- ksapi-tests
- kickstarter-tests:
requires:
- build-and-cache
- library-tests:
requires:
- build-and-cache
- ksapi-tests:
requires:
- build-and-cache

# ** Refreshing dSYMs disabled until a suitable workaround is found for App Store Connect 2FA authentication
# or Fastlane implements API key support in this Fastlane action. Uncomment below to re-enable.
# See: https://docs.fastlane.tools/app-store-connect-api/
Expand Down
8 changes: 4 additions & 4 deletions .fastlane/Fastfile
Expand Up @@ -26,7 +26,7 @@ platform :ios do
match(
app_identifier: ["com.kickstarter.kickstarter"],
type: "appstore",
git_url: "https://github.com/kickstarter/ios-certificates",
git_url: "git@github.com:kickstarter/ios-certificates",
team_id: "48YBP49Y5N",
git_branch: "ksr",
username: ENV["ITUNES_CONNECT_ACCOUNT"]
Expand All @@ -40,7 +40,7 @@ platform :ios do
"com.kickstarter.kickstarter.debug"
],
type: "development",
git_url: "https://github.com/kickstarter/ios-certificates",
git_url: "git@github.com:kickstarter/ios-certificates",
team_id: "48YBP49Y5N",
git_branch: "ksr",
username: ENV["ITUNES_CONNECT_ACCOUNT"],
Expand All @@ -56,7 +56,7 @@ platform :ios do
"com.kickstarter.kickstarter.kickalpha"
],
type: "enterprise",
git_url: "https://github.com/kickstarter/ios-certificates",
git_url: "git@github.com:kickstarter/ios-certificates",
team_id: "5DAN4UM3NC",
git_branch: "ksr-enterprise",
username: ENV["ITUNES_CONNECT_ACCOUNT"],
Expand Down Expand Up @@ -226,7 +226,7 @@ platform :ios do
end

private_lane :xcode_check do
xcodes(version: "13.3.1", select_for_current_build_only: true)
xcodes(version: "14.2", select_for_current_build_only: true)
end

private_lane :build_the_app do |options|
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -119,8 +119,8 @@ sync:

cleanup:
@echo "Adding remotes..."
@git remote add oss https://github.com/kickstarter/ios-oss
@git remote add private https://github.com/kickstarter/ios-private
@git remote add oss git@github.com:kickstarter/ios-oss
@git remote add private git@github.com:kickstarter/ios-private

@echo "Deleting temporary branch: $(CIRCLE_BRANCH)"

Expand All @@ -132,7 +132,7 @@ strings:

secrets:
-@rm -rf Frameworks/native-secrets
-@git clone https://github.com/kickstarter/native-secrets Frameworks/native-secrets 2>/dev/null || echo '(Skipping secrets.)'
-@git clone git@github.com:kickstarter/native-secrets Frameworks/native-secrets 2>/dev/null || echo '(Skipping secrets.)'
if [ ! -d Frameworks/native-secrets ]; \
then \
mkdir -p Frameworks/native-secrets/ios \
Expand Down

0 comments on commit c50512a

Please sign in to comment.