Skip to content

Commit 406165f

Browse files
authored
Merge pull request #60 from AliSoftware/feature/circleci2
Upgrade to CircleCI 2
2 parents 9917c30 + df4fdda commit 406165f

7 files changed

Lines changed: 336 additions & 43 deletions

File tree

.circleci/config.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
defaults:
2+
- &default-config
3+
parallelism: 1
4+
environment:
5+
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
6+
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
7+
BUNDLE_PATH: vendor/bundle
8+
macos:
9+
xcode: "9.3.0"
10+
shell: /bin/bash --login -eo pipefail
11+
- &prepare-storage
12+
run:
13+
name: Create directories for artifacts and reports
14+
command: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
15+
- &restore-gems
16+
restore_cache:
17+
keys:
18+
- gems-{{ checksum "Gemfile.lock" }}
19+
- gems-
20+
- &install-gems
21+
run:
22+
name: Bundle install
23+
command: bundle check || bundle install
24+
environment:
25+
BUNDLE_JOBS: 4
26+
BUNDLE_RETRY: 3
27+
- &store-gems
28+
save_cache:
29+
key: gems-{{ checksum "Gemfile.lock" }}
30+
paths:
31+
- vendor/bundle
32+
- &fetch-xcode-logs
33+
run:
34+
name: Getting Xcode activity logs
35+
command: find $HOME/Library/Developer/Xcode/DerivedData -name '*.xcactivitylog' -exec cp {} $CIRCLE_ARTIFACTS/xcactivitylog \; || true
36+
- &store-artifacts
37+
store_artifacts:
38+
path: /tmp/circleci-artifacts
39+
40+
41+
version: 2
42+
jobs:
43+
carthage-build:
44+
<<: *default-config
45+
steps:
46+
- *prepare-storage
47+
- checkout
48+
- *restore-gems
49+
- *install-gems
50+
- *store-gems
51+
- run:
52+
name: Install Carthage
53+
command: bundle exec rake carthage:install
54+
- run:
55+
name: Build
56+
command: bundle exec rake carthage:build
57+
- store_test_results:
58+
path: /tmp/circleci-test-results
59+
- *fetch-xcode-logs
60+
- *store-artifacts
61+
62+
check-deploy:
63+
<<: *default-config
64+
steps:
65+
- *prepare-storage
66+
- checkout
67+
- *restore-gems
68+
- *install-gems
69+
- *store-gems
70+
- run:
71+
name: Download podspec repo
72+
command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
73+
- run:
74+
name: Lint podspec
75+
command: bundle exec rake pod:lint
76+
- *store-artifacts
77+
78+
lint:
79+
<<: *default-config
80+
steps:
81+
- *prepare-storage
82+
- checkout
83+
- *restore-gems
84+
- *install-gems
85+
- *store-gems
86+
- run:
87+
name: Install SwiftLint
88+
command: bundle exec rake swiftlint:install
89+
- run:
90+
name: Lint source code
91+
command: bundle exec rake swiftlint:run
92+
- *store-artifacts
93+
94+
spm-build-and-test:
95+
<<: *default-config
96+
steps:
97+
- *prepare-storage
98+
- checkout
99+
- *restore-gems
100+
- *install-gems
101+
- *store-gems
102+
- run:
103+
name: Run all tests
104+
command: bundle exec rake spm:test
105+
- *store-artifacts
106+
107+
xcode-ios-build-and-test:
108+
<<: *default-config
109+
steps:
110+
- *prepare-storage
111+
- checkout
112+
- *restore-gems
113+
- *install-gems
114+
- *store-gems
115+
- run:
116+
name: Build Framework
117+
command: bundle exec rake fmk:ios
118+
- run:
119+
name: Run Tests
120+
command: bundle exec rake demo:ios
121+
- store_test_results:
122+
path: /tmp/circleci-test-results
123+
- *fetch-xcode-logs
124+
- *store-artifacts
125+
126+
xcode-tvos-build-and-test:
127+
<<: *default-config
128+
steps:
129+
- *prepare-storage
130+
- checkout
131+
- *restore-gems
132+
- *install-gems
133+
- *store-gems
134+
- run:
135+
name: Build Framework
136+
command: bundle exec rake fmk:tvos
137+
- run:
138+
name: Run Tests
139+
command: bundle exec rake demo:tvos
140+
- store_test_results:
141+
path: /tmp/circleci-test-results
142+
- *fetch-xcode-logs
143+
- *store-artifacts
144+
145+
146+
workflows:
147+
version: 2
148+
lint-buildandtest-checkdeploy:
149+
jobs:
150+
- lint
151+
- xcode-ios-build-and-test:
152+
requires:
153+
- lint
154+
- xcode-tvos-build-and-test:
155+
requires:
156+
- lint
157+
- carthage-build:
158+
requires:
159+
- lint
160+
- xcode-ios-build-and-test
161+
- xcode-tvos-build-and-test
162+
- check-deploy:
163+
requires:
164+
- lint
165+
- xcode-ios-build-and-test
166+
- xcode-tvos-build-and-test

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Master
44

5+
* Upgrade to CircleCI 2.
6+
[djbe](https://github.com/djbe)
7+
[#60](https://github.com/AliSoftware/Reusable/pull/60)
8+
59
* Update project to support Swift 4.2.
610
[djbe](https://github.com/djbe)
711
[#58](https://github.com/AliSoftware/Reusable/pull/58)

Gemfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
# The bare minimum for building, e.g. in Homebrew
6+
group :build do
7+
gem 'rake', '~> 10.5'
8+
gem 'xcpretty'
9+
end
10+
11+
# In addition to :build, for contributing
12+
group :development do
13+
gem 'cocoapods', '~> 1.5'
14+
gem 'rubocop', '~> 0.58'
15+
end

Gemfile.lock

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (3.0.0)
5+
activesupport (4.2.10)
6+
i18n (~> 0.7)
7+
minitest (~> 5.1)
8+
thread_safe (~> 0.3, >= 0.3.4)
9+
tzinfo (~> 1.1)
10+
ast (2.4.0)
11+
atomos (0.1.2)
12+
claide (1.0.2)
13+
cocoapods (1.5.3)
14+
activesupport (>= 4.0.2, < 5)
15+
claide (>= 1.0.2, < 2.0)
16+
cocoapods-core (= 1.5.3)
17+
cocoapods-deintegrate (>= 1.0.2, < 2.0)
18+
cocoapods-downloader (>= 1.2.0, < 2.0)
19+
cocoapods-plugins (>= 1.0.0, < 2.0)
20+
cocoapods-search (>= 1.0.0, < 2.0)
21+
cocoapods-stats (>= 1.0.0, < 2.0)
22+
cocoapods-trunk (>= 1.3.0, < 2.0)
23+
cocoapods-try (>= 1.1.0, < 2.0)
24+
colored2 (~> 3.1)
25+
escape (~> 0.0.4)
26+
fourflusher (~> 2.0.1)
27+
gh_inspector (~> 1.0)
28+
molinillo (~> 0.6.5)
29+
nap (~> 1.0)
30+
ruby-macho (~> 1.1)
31+
xcodeproj (>= 1.5.7, < 2.0)
32+
cocoapods-core (1.5.3)
33+
activesupport (>= 4.0.2, < 6)
34+
fuzzy_match (~> 2.0.4)
35+
nap (~> 1.0)
36+
cocoapods-deintegrate (1.0.2)
37+
cocoapods-downloader (1.2.1)
38+
cocoapods-plugins (1.0.0)
39+
nap
40+
cocoapods-search (1.0.0)
41+
cocoapods-stats (1.0.0)
42+
cocoapods-trunk (1.3.0)
43+
nap (>= 0.8, < 2.0)
44+
netrc (~> 0.11)
45+
cocoapods-try (1.1.0)
46+
colored2 (3.1.2)
47+
concurrent-ruby (1.0.5)
48+
escape (0.0.4)
49+
fourflusher (2.0.1)
50+
fuzzy_match (2.0.4)
51+
gh_inspector (1.1.3)
52+
i18n (0.9.5)
53+
concurrent-ruby (~> 1.0)
54+
jaro_winkler (1.5.1)
55+
minitest (5.11.3)
56+
molinillo (0.6.5)
57+
nanaimo (0.2.6)
58+
nap (1.1.0)
59+
netrc (0.11.0)
60+
parallel (1.12.1)
61+
parser (2.5.1.2)
62+
ast (~> 2.4.0)
63+
powerpack (0.1.2)
64+
rainbow (3.0.0)
65+
rake (10.5.0)
66+
rouge (2.0.7)
67+
rubocop (0.58.1)
68+
jaro_winkler (~> 1.5.1)
69+
parallel (~> 1.10)
70+
parser (>= 2.5, != 2.5.1.1)
71+
powerpack (~> 0.1)
72+
rainbow (>= 2.2.2, < 4.0)
73+
ruby-progressbar (~> 1.7)
74+
unicode-display_width (~> 1.0, >= 1.0.1)
75+
ruby-macho (1.2.0)
76+
ruby-progressbar (1.9.0)
77+
thread_safe (0.3.6)
78+
tzinfo (1.2.5)
79+
thread_safe (~> 0.1)
80+
unicode-display_width (1.4.0)
81+
xcodeproj (1.5.9)
82+
CFPropertyList (>= 2.3.3, < 4.0)
83+
atomos (~> 0.1.2)
84+
claide (>= 1.0.2, < 2.0)
85+
colored2 (~> 3.1)
86+
nanaimo (~> 0.2.5)
87+
xcpretty (0.2.8)
88+
rouge (~> 2.0.7)
89+
90+
PLATFORMS
91+
ruby
92+
93+
DEPENDENCIES
94+
cocoapods (~> 1.5)
95+
rake (~> 10.5)
96+
rubocop (~> 0.58)
97+
xcpretty
98+
99+
BUNDLED WITH
100+
1.16.1

Package.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
// swift-tools-version:4.0
12
import PackageDescription
23

4+
// Note: SPM support is broken until we can add dependency on UIKit.
5+
36
let package = Package(
4-
name: "Reusable"
7+
name: "Reusable",
8+
products: [
9+
.library(name: "Reusable", targets: ["Reusable"])
10+
],
11+
targets: [
12+
.target(
13+
name: "Reusable",
14+
path: "",
15+
sources: ["Sources"]
16+
)
17+
],
18+
swiftLanguageVersions: [3, 4]
519
)

Rakefile

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/rake
2+
13
## UTILS ##
24

35
def run(command, xcpretty: true)
@@ -38,16 +40,15 @@ namespace :carthage do
3840
end
3941
end
4042

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

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

@@ -63,23 +64,38 @@ namespace :fmk do
6364
end
6465
end
6566

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

72-
desc "Builds the ReusableDemo app for tvOS using xcodebuild."
73-
task :tvos do |t, args|
74-
xcodebuild(scheme: 'ReusableDemo tvOS', sdk: 'appletvsimulator', destination: DESTINATIONS[:tvos_sim])
74+
namespace :spm do
75+
desc 'Build using SPM'
76+
task :build do |task|
77+
Utils.print_header 'Compile using SPM'
78+
Utils.run('swift build', task, xcrun: true)
79+
end
80+
81+
desc 'Run SPM Unit Tests'
82+
task :test => :build do |task|
83+
Utils.print_header 'Run the unit tests using SPM'
84+
Utils.run('swift test', task, xcrun: true)
7585
end
7686
end
7787

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

80-
namespace :pod do
81-
desc "Lints the Reusable.podspec"
82-
task :lint do |t|
83-
run("pod lib lint --allow-warnings --quick", xcpretty: false)
95+
desc "Run SwiftLint on the source code"
96+
task :run do
97+
run('swiftlint lint --strict', xcpretty: false)
8498
end
8599
end
100+
101+
# TODO: "namespace :test" once we have Unit Tests

0 commit comments

Comments
 (0)