Skip to content

Commit

Permalink
migrate to workflows and 2.1 config (#48)
Browse files Browse the repository at this point in the history
* migrate to workflows and 2.1 config

* extract bundle install in a separate command

* Instal pods only before validating pod

* commit gem lock file

* do not run bundle install when it's not needed

* pass raw parameters to test job
  • Loading branch information
ilyapuchka authored Oct 7, 2019
1 parent 36599c6 commit ff84ba3
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 70 deletions.
198 changes: 130 additions & 68 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,148 @@
version: 2
version: 2.1

references:
- &cocoapods_cache_key
2-pods-{{ checksum "Podfile.lock" }}

- &restore_cocoapods_cache
restore_cache:
key: *cocoapods_cache_key
- &container_config
macos:
xcode: "10.3.0"
working_directory: /Users/distiller/project
shell: /bin/bash --login -eo pipefail

- &pod_install
run:
name: Pod Install
command: |
bundle exec pod --version
diff Podfile.lock Pods/Manifest.lock || curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
bundle exec pod install
commands:

- &save_cocoapods_cache
save_cache:
key: *cocoapods_cache_key
save_workspace:
parameters:
path:
type: string
default: .
steps:
- persist_to_workspace:
root: .
paths:
- Pods
- ~/.cocoapods/repos

- &carthage_cache_key
101-carthage-{{ checksum "Cartfile.resolved" }}
- << parameters.path >>

- &restore_carthage_cache
restore_cache:
key: *carthage_cache_key
restore_workspace:
steps:
- attach_workspace:
at: .

- &save_carthage_cache
save_cache:
key: *carthage_cache_key
gems:
steps:
- restore_cache:
key: &gems_cache_key 1-gems-{{ checksum "Gemfile.lock" }}
- run:
name: Bundle Install
command: bundle check --path=.vendor/bundle || bundle install --path=.vendor/bundle --jobs=4 --retry=3
- save_cache:
key: *gems_cache_key
paths:
- Carthage
- .vendor/bundle

- &swift_package_manager
run:
name: Swift Package Manager validation
command: |
swift --version
swift build
swift test
cocoapods:
steps:
- restore_cache:
key: &cocoapods_cache_key 3-pods-{{ checksum "Podfile.lock" }}
- run:
name: Pod Install
command: |
if ! diff -q Podfile.lock Pods/Manifest.lock &>/dev/null; then
curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
bundle exec pod install || bundle exec pod install --repo-update
fi
- save_cache:
key: *cocoapods_cache_key
paths:
- Pods

jobs:
build:
macos:
xcode: "10.3.0"
working_directory: /Users/distiller/project
shell: /bin/bash --login -eo pipefail
carthage:
steps:
- checkout
- *restore_carthage_cache
- restore_cache:
key: &carthage_cache_key 101-carthage-{{ checksum "Cartfile.resolved" }}
- run:
name: "Bootstrap Carthage"
command: |
carthage bootstrap --no-build
- *save_carthage_cache
- run:
name: "Test: iOS"
command: |
script/test iphonesimulator "platform=iOS Simulator,name=iPhone X" ReactiveFeedback-iOS
- run:
name: "Test: macOS"
command: |
script/test macosx "arch=x86_64" ReactiveFeedback-macOS
- run:
name: "Test: tvOS"
command: |
script/test appletvsimulator "platform=tvOS Simulator,name=Apple TV 4K" ReactiveFeedback-tvOS
- run:
name: "Example app"
command: |
script/test iphonesimulator "platform=iOS Simulator,name=iPhone X" Example build
- *restore_cocoapods_cache
- *pod_install
- *save_cocoapods_cache
- save_cache:
key: *carthage_cache_key
paths:
- Carthage

jobs:

checkout_code:
<<: *container_config
steps:
- checkout
- gems
- carthage
- save_workspace

test:
parameters:
parameters:
type: string
<<: *container_config
steps:
- restore_workspace
- gems
- run: script/test << parameters.parameters >>

cocoapods_validation:
<<: *container_config
steps:
- restore_workspace
- gems
- cocoapods
- run: pod lib lint --use-libraries

carthage_validation:
<<: *container_config
steps:
- restore_workspace
- run: carthage build --no-skip-current --cache-builds

spm_validation:
<<: *container_config
steps:
- restore_workspace
- run:
name: "Package manager validation"
command: |
pod lib lint --use-libraries
carthage build --no-skip-current --cache-builds
- *swift_package_manager
swift --version
swift build
swift test
workflows:
version: 2

build:
jobs:
- checkout_code
- test:
parameters: iphonesimulator "platform=iOS Simulator,name=iPhone X" ReactiveFeedback-iOS
name: Test-iOS
requires:
- checkout_code
- test:
parameters: macosx "arch=x86_64" ReactiveFeedback-macOS
name: Test-macOS
requires:
- checkout_code
- test:
parameters: appletvsimulator "platform=tvOS Simulator,name=Apple TV 4K" ReactiveFeedback-tvOS
name: Test-tvOS
requires:
- checkout_code
- test:
parameters: iphonesimulator "platform=iOS Simulator,name=iPhone X" Example build
name: ExampleApp
requires:
- checkout_code
- cocoapods_validation:
requires: &all_tests
- Test-iOS
- Test-macOS
- Test-tvOS
- ExampleApp
- carthage_validation:
requires: *all_tests
- spm_validation:
requires: *all_tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# from source-control, but YMMV

*.lock
!Gemfile.lock
.vendor

#
# profile - REMOVED temporarily (on double-checking, this seems incorrect; I can't find it in OS X docs?)
Expand Down
80 changes: 80 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.1)
activesupport (4.2.11.1)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
atomos (0.1.3)
claide (1.0.3)
cocoapods (1.6.2)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.6.2)
cocoapods-deintegrate (>= 1.0.2, < 2.0)
cocoapods-downloader (>= 1.2.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.3.1, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.2.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.6.6)
nap (~> 1.0)
ruby-macho (~> 1.4)
xcodeproj (>= 1.8.1, < 2.0)
cocoapods-core (1.6.2)
activesupport (>= 4.0.2, < 6)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.4)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.1.0)
cocoapods-trunk (1.4.1)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.1.5)
escape (0.0.4)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
minitest (5.12.2)
molinillo (0.6.6)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.11.0)
rouge (2.0.7)
ruby-macho (1.4.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
xcodeproj (1.12.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.6)
xcpretty (0.3.0)
rouge (~> 2.0.7)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.6.2)
xcpretty

BUNDLED WITH
2.0.2
2 changes: 0 additions & 2 deletions script/test
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

bundle install

if [[ "$1" == "macosx" ]]; then
XCODE_ACTION="build"
fi
Expand Down

0 comments on commit ff84ba3

Please sign in to comment.