Skip to content

Commit d6f77d9

Browse files
committed
Add SPM rake task and CI job
1 parent 73b4559 commit d6f77d9

2 files changed

Lines changed: 78 additions & 51 deletions

File tree

.circleci/config.yml

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defaults:
4040

4141
version: 2
4242
jobs:
43-
lint:
43+
carthage-build:
4444
<<: *default-config
4545
steps:
4646
- *prepare-storage
@@ -49,14 +49,17 @@ jobs:
4949
- *install-gems
5050
- *store-gems
5151
- run:
52-
name: Install SwiftLint
53-
command: bundle exec rake swiftlint:install
52+
name: Install Carthage
53+
command: bundle exec rake carthage:install
5454
- run:
55-
name: Lint source code
56-
command: bundle exec rake swiftlint: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
5760
- *store-artifacts
5861

59-
xcode-ios-build-and-test:
62+
check-deploy:
6063
<<: *default-config
6164
steps:
6265
- *prepare-storage
@@ -65,17 +68,14 @@ jobs:
6568
- *install-gems
6669
- *store-gems
6770
- run:
68-
name: Build Framework
69-
command: bundle exec rake fmk:ios
71+
name: Download podspec repo
72+
command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
7073
- run:
71-
name: Run Tests
72-
command: bundle exec rake demo:ios
73-
- store_test_results:
74-
path: /tmp/circleci-test-results
75-
- *fetch-xcode-logs
74+
name: Lint podspec
75+
command: bundle exec rake pod:lint
7676
- *store-artifacts
7777

78-
xcode-tvos-build-and-test:
78+
lint:
7979
<<: *default-config
8080
steps:
8181
- *prepare-storage
@@ -84,17 +84,14 @@ jobs:
8484
- *install-gems
8585
- *store-gems
8686
- run:
87-
name: Build Framework
88-
command: bundle exec rake fmk:tvos
87+
name: Install SwiftLint
88+
command: bundle exec rake swiftlint:install
8989
- run:
90-
name: Run Tests
91-
command: bundle exec rake demo:tvos
92-
- store_test_results:
93-
path: /tmp/circleci-test-results
94-
- *fetch-xcode-logs
90+
name: Lint source code
91+
command: bundle exec rake swiftlint:run
9592
- *store-artifacts
9693

97-
carthage-build:
94+
spm-build-and-test:
9895
<<: *default-config
9996
steps:
10097
- *prepare-storage
@@ -103,17 +100,30 @@ jobs:
103100
- *install-gems
104101
- *store-gems
105102
- run:
106-
name: Install Carthage
107-
command: bundle exec rake carthage:install
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
108115
- run:
109-
name: Build
110-
command: bundle exec rake carthage:build
116+
name: Build Framework
117+
command: bundle exec rake fmk:ios
118+
- run:
119+
name: Run Tests
120+
command: bundle exec rake demo:ios
111121
- store_test_results:
112122
path: /tmp/circleci-test-results
113123
- *fetch-xcode-logs
114124
- *store-artifacts
115125

116-
check-deploy:
126+
xcode-tvos-build-and-test:
117127
<<: *default-config
118128
steps:
119129
- *prepare-storage
@@ -122,11 +132,14 @@ jobs:
122132
- *install-gems
123133
- *store-gems
124134
- run:
125-
name: Download podspec repo
126-
command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
135+
name: Build Framework
136+
command: bundle exec rake fmk:tvos
127137
- run:
128-
name: Lint podspec
129-
command: bundle exec rake pod:lint
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
130143
- *store-artifacts
131144

132145

Rakefile

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ namespace :carthage do
4040
end
4141
end
4242

43-
namespace :swiftlint do
44-
desc "Install SwiftLint from pkg"
45-
task :install do
46-
next if system('which swiftlint >/dev/null')
47-
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])
4847
end
4948

50-
desc "Run SwiftLint on the source code"
51-
task :run do
52-
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])
5352
end
5453
end
5554

@@ -65,23 +64,38 @@ namespace :fmk do
6564
end
6665
end
6766

68-
namespace :demo do
69-
desc "Builds the ReusableDemo app for iOS using xcodebuild."
70-
task :ios do |t, args|
71-
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)
7271
end
72+
end
7373

74-
desc "Builds the ReusableDemo app for tvOS using xcodebuild."
75-
task :tvos do |t, args|
76-
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)
7785
end
7886
end
7987

80-
# 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
8194

82-
namespace :pod do
83-
desc "Lints the Reusable.podspec"
84-
task :lint do |t|
85-
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)
8698
end
8799
end
100+
101+
# TODO: "namespace :test" once we have Unit Tests

0 commit comments

Comments
 (0)