Skip to content

Commit

Permalink
Merge pull request #60 from AliSoftware/feature/circleci2
Browse files Browse the repository at this point in the history
Upgrade to CircleCI 2
  • Loading branch information
AliSoftware authored Jul 14, 2018
2 parents 9917c30 + df4fdda commit 406165f
Show file tree
Hide file tree
Showing 7 changed files with 336 additions and 43 deletions.
166 changes: 166 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
defaults:
- &default-config
parallelism: 1
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
BUNDLE_PATH: vendor/bundle
macos:
xcode: "9.3.0"
shell: /bin/bash --login -eo pipefail
- &prepare-storage
run:
name: Create directories for artifacts and reports
command: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
- &restore-gems
restore_cache:
keys:
- gems-{{ checksum "Gemfile.lock" }}
- gems-
- &install-gems
run:
name: Bundle install
command: bundle check || bundle install
environment:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
- &store-gems
save_cache:
key: gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- &fetch-xcode-logs
run:
name: Getting Xcode activity logs
command: find $HOME/Library/Developer/Xcode/DerivedData -name '*.xcactivitylog' -exec cp {} $CIRCLE_ARTIFACTS/xcactivitylog \; || true
- &store-artifacts
store_artifacts:
path: /tmp/circleci-artifacts


version: 2
jobs:
carthage-build:
<<: *default-config
steps:
- *prepare-storage
- checkout
- *restore-gems
- *install-gems
- *store-gems
- run:
name: Install Carthage
command: bundle exec rake carthage:install
- run:
name: Build
command: bundle exec rake carthage:build
- store_test_results:
path: /tmp/circleci-test-results
- *fetch-xcode-logs
- *store-artifacts

check-deploy:
<<: *default-config
steps:
- *prepare-storage
- checkout
- *restore-gems
- *install-gems
- *store-gems
- run:
name: Download podspec repo
command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
- run:
name: Lint podspec
command: bundle exec rake pod:lint
- *store-artifacts

lint:
<<: *default-config
steps:
- *prepare-storage
- checkout
- *restore-gems
- *install-gems
- *store-gems
- run:
name: Install SwiftLint
command: bundle exec rake swiftlint:install
- run:
name: Lint source code
command: bundle exec rake swiftlint:run
- *store-artifacts

spm-build-and-test:
<<: *default-config
steps:
- *prepare-storage
- checkout
- *restore-gems
- *install-gems
- *store-gems
- run:
name: Run all tests
command: bundle exec rake spm:test
- *store-artifacts

xcode-ios-build-and-test:
<<: *default-config
steps:
- *prepare-storage
- checkout
- *restore-gems
- *install-gems
- *store-gems
- run:
name: Build Framework
command: bundle exec rake fmk:ios
- run:
name: Run Tests
command: bundle exec rake demo:ios
- store_test_results:
path: /tmp/circleci-test-results
- *fetch-xcode-logs
- *store-artifacts

xcode-tvos-build-and-test:
<<: *default-config
steps:
- *prepare-storage
- checkout
- *restore-gems
- *install-gems
- *store-gems
- run:
name: Build Framework
command: bundle exec rake fmk:tvos
- run:
name: Run Tests
command: bundle exec rake demo:tvos
- store_test_results:
path: /tmp/circleci-test-results
- *fetch-xcode-logs
- *store-artifacts


workflows:
version: 2
lint-buildandtest-checkdeploy:
jobs:
- lint
- xcode-ios-build-and-test:
requires:
- lint
- xcode-tvos-build-and-test:
requires:
- lint
- carthage-build:
requires:
- lint
- xcode-ios-build-and-test
- xcode-tvos-build-and-test
- check-deploy:
requires:
- lint
- xcode-ios-build-and-test
- xcode-tvos-build-and-test
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Master

* Upgrade to CircleCI 2.
[djbe](https://github.com/djbe)
[#60](https://github.com/AliSoftware/Reusable/pull/60)

* Update project to support Swift 4.2.
[djbe](https://github.com/djbe)
[#58](https://github.com/AliSoftware/Reusable/pull/58)
Expand Down
15 changes: 15 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# The bare minimum for building, e.g. in Homebrew
group :build do
gem 'rake', '~> 10.5'
gem 'xcpretty'
end

# In addition to :build, for contributing
group :development do
gem 'cocoapods', '~> 1.5'
gem 'rubocop', '~> 0.58'
end
100 changes: 100 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.0)
activesupport (4.2.10)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
ast (2.4.0)
atomos (0.1.2)
claide (1.0.2)
cocoapods (1.5.3)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.5.3)
cocoapods-deintegrate (>= 1.0.2, < 2.0)
cocoapods-downloader (>= 1.2.0, < 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.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (~> 2.0.1)
gh_inspector (~> 1.0)
molinillo (~> 0.6.5)
nap (~> 1.0)
ruby-macho (~> 1.1)
xcodeproj (>= 1.5.7, < 2.0)
cocoapods-core (1.5.3)
activesupport (>= 4.0.2, < 6)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
escape (0.0.4)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.1)
minitest (5.11.3)
molinillo (0.6.5)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.11.0)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
powerpack (0.1.2)
rainbow (3.0.0)
rake (10.5.0)
rouge (2.0.7)
rubocop (0.58.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-macho (1.2.0)
ruby-progressbar (1.9.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.4.0)
xcodeproj (1.5.9)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.2)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.5)
xcpretty (0.2.8)
rouge (~> 2.0.7)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.5)
rake (~> 10.5)
rubocop (~> 0.58)
xcpretty

BUNDLED WITH
1.16.1
16 changes: 15 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
// swift-tools-version:4.0
import PackageDescription

// Note: SPM support is broken until we can add dependency on UIKit.

let package = Package(
name: "Reusable"
name: "Reusable",
products: [
.library(name: "Reusable", targets: ["Reusable"])
],
targets: [
.target(
name: "Reusable",
path: "",
sources: ["Sources"]
)
],
swiftLanguageVersions: [3, 4]
)
56 changes: 36 additions & 20 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/rake

## UTILS ##

def run(command, xcpretty: true)
Expand Down Expand Up @@ -38,16 +40,15 @@ namespace :carthage do
end
end

namespace :swiftlint do
desc "Install SwiftLint from pkg"
task :install do
next if system('which swiftlint >/dev/null')
install_pkg('https://github.com/realm/SwiftLint/releases/download/0.26.0/SwiftLint.pkg')
namespace :demo do
desc "Builds the ReusableDemo app for iOS using xcodebuild."
task :ios do |t, args|
xcodebuild(scheme: 'ReusableDemo iOS', sdk: 'iphonesimulator', destination: DESTINATIONS[:ios_sim])
end

desc "Run SwiftLint on the source code"
task :run do
run('swiftlint lint --strict', xcpretty: false)
desc "Builds the ReusableDemo app for tvOS using xcodebuild."
task :tvos do |t, args|
xcodebuild(scheme: 'ReusableDemo tvOS', sdk: 'appletvsimulator', destination: DESTINATIONS[:tvos_sim])
end
end

Expand All @@ -63,23 +64,38 @@ namespace :fmk do
end
end

namespace :demo do
desc "Builds the ReusableDemo app for iOS using xcodebuild."
task :ios do |t, args|
xcodebuild(scheme: 'ReusableDemo iOS', sdk: 'iphonesimulator', destination: DESTINATIONS[:ios_sim])
namespace :pod do
desc "Lints the Reusable.podspec"
task :lint do |t|
run("pod lib lint --allow-warnings --quick", xcpretty: false)
end
end

desc "Builds the ReusableDemo app for tvOS using xcodebuild."
task :tvos do |t, args|
xcodebuild(scheme: 'ReusableDemo tvOS', sdk: 'appletvsimulator', destination: DESTINATIONS[:tvos_sim])
namespace :spm do
desc 'Build using SPM'
task :build do |task|
Utils.print_header 'Compile using SPM'
Utils.run('swift build', task, xcrun: true)
end

desc 'Run SPM Unit Tests'
task :test => :build do |task|
Utils.print_header 'Run the unit tests using SPM'
Utils.run('swift test', task, xcrun: true)
end
end

# TODO: "namespace :test" once we have Unit Tests
namespace :swiftlint do
desc "Install SwiftLint from pkg"
task :install do
next if system('which swiftlint >/dev/null')
install_pkg('https://github.com/realm/SwiftLint/releases/download/0.26.0/SwiftLint.pkg')
end

namespace :pod do
desc "Lints the Reusable.podspec"
task :lint do |t|
run("pod lib lint --allow-warnings --quick", xcpretty: false)
desc "Run SwiftLint on the source code"
task :run do
run('swiftlint lint --strict', xcpretty: false)
end
end

# TODO: "namespace :test" once we have Unit Tests
Loading

0 comments on commit 406165f

Please sign in to comment.