carthage_cache 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -2
- data/README.md +38 -1
- data/carthage_cache.gemspec +1 -0
- data/exe/carthage_cache +1 -1
- data/lib/carthage_cache.rb +3 -47
- data/lib/carthage_cache/application.rb +51 -0
- data/lib/carthage_cache/archiver.rb +8 -2
- data/lib/carthage_cache/carthage_resolved_file.rb +7 -2
- data/lib/carthage_cache/configuration.rb +3 -1
- data/lib/carthage_cache/project.rb +5 -3
- data/lib/carthage_cache/shell_command_executor.rb +11 -0
- data/lib/carthage_cache/swift_version_resolver.rb +17 -0
- data/lib/carthage_cache/version.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c1088f79834754ab5253f660ae875d825eb7c4e
|
4
|
+
data.tar.gz: ac83ce8bce893e65bcc95113ae9a2da2e1562894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ed7c130a44dc91ac3dc85c31123e9cccc1a0ee104af3cc55a96253ea13140ad0a3bac2ef29b3401f7805057e743310c1df4472f7ed0a1cdf06ceccc71a45e36
|
7
|
+
data.tar.gz: f38f45564c0044d742307ae36dc18bd10703599d3c1202817ba1c1155931d48817eed3da047069276923a967f88216b484d25881d21a2400069db7da056eb213
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -3,7 +3,6 @@ os:
|
|
3
3
|
language: ruby
|
4
4
|
cache: bundler
|
5
5
|
rvm:
|
6
|
-
- head
|
7
6
|
- 2.2.2
|
8
7
|
# OS X 10.9.5-10.10.0 (2.0.0-p481)
|
9
8
|
- system
|
@@ -14,4 +13,8 @@ branches:
|
|
14
13
|
only:
|
15
14
|
- master
|
16
15
|
|
17
|
-
before_install: gem install bundler
|
16
|
+
before_install: sudo gem install bundler
|
17
|
+
|
18
|
+
addons:
|
19
|
+
code_climate:
|
20
|
+
repo_token: 6220ef8896c380cb590d4640621d1fc4c0d6d36ccc24d3d818cfba76bbd50014
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# CarthageCache
|
2
2
|
|
3
|
+
[](https://travis-ci.org/guidomb/carthage_cache)
|
3
4
|
[](https://codeclimate.com/github/guidomb/carthage_cache)
|
4
5
|
[](https://codeclimate.com/github/guidomb/carthage_cache/coverage)
|
5
6
|
[](https://badge.fury.io/rb/carthage_cache)
|
@@ -10,7 +11,8 @@ Most libraries don't provide pre-compiled binaries, `.framework` files, in their
|
|
10
11
|
|
11
12
|
When you add slow building environments like Travis CI to the mix, a project bootstrap could take around 25 minutes just to build all your dependencies. Which is a lot for every push or pull request. You want your build and test to run really fast.
|
12
13
|
|
13
|
-
CarthageCache generates a hash key based on the content of your `Cartfile.resolved` and
|
14
|
+
CarthageCache generates a hash key based on the content of your `Cartfile.resolved` and the current
|
15
|
+
installed version of Swift. Then it checks if there is a cache archive (a zip file of your `Carthage/Build` directory) associated to that hash. If there is one it will download it and install it in your project avoiding the need to run `carthage bootstrap`.
|
14
16
|
|
15
17
|
## Installation
|
16
18
|
|
@@ -50,6 +52,41 @@ You can also set your credentials using the following environmental variables
|
|
50
52
|
|
51
53
|
CarthageCache will assume there is a bucket named `carthage-cache`. You can change the bucket to be used by using the option `-b` or `--bucket-name`.
|
52
54
|
|
55
|
+
### IAM Policy
|
56
|
+
|
57
|
+
Once you create the bucket, you will need to create a user. Go to the IAM section and create a new user. Create a new group, and add the new user to that group.
|
58
|
+
Create a policy with the following permisions:
|
59
|
+
```
|
60
|
+
{
|
61
|
+
"Version": "2012-10-17",
|
62
|
+
"Statement": [
|
63
|
+
{
|
64
|
+
"Sid": "autogenerated-id",
|
65
|
+
"Effect": "Allow",
|
66
|
+
"Action": [
|
67
|
+
"s3:ListBucket"
|
68
|
+
],
|
69
|
+
"Resource": [
|
70
|
+
"arn:aws:s3:::carthage-cache"
|
71
|
+
]
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"Sid": "autogenerated-id",
|
75
|
+
"Effect": "Allow",
|
76
|
+
"Action": [
|
77
|
+
"s3:DeleteObject",
|
78
|
+
"s3:GetObject",
|
79
|
+
"s3:PutObject"
|
80
|
+
],
|
81
|
+
"Resource": [
|
82
|
+
"arn:aws:s3:::carthage-cache/*"
|
83
|
+
]
|
84
|
+
}
|
85
|
+
]
|
86
|
+
}
|
87
|
+
```
|
88
|
+
Don't forget to attach the policy to the group.
|
89
|
+
|
53
90
|
## Usage
|
54
91
|
|
55
92
|
If you want to bootstrap a project from cache and if there is none then fallback to Carthage.
|
data/carthage_cache.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec"
|
30
30
|
spec.add_development_dependency "pry"
|
31
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
31
32
|
|
32
33
|
spec.add_dependency "aws-sdk", "~> 2.2.3"
|
33
34
|
spec.add_dependency "commander", "~> 4.3.8"
|
data/exe/carthage_cache
CHANGED
@@ -45,7 +45,7 @@ command :install do |c|
|
|
45
45
|
c.description = 'Installs the cache archive for the current Cartfile.resolved.'
|
46
46
|
c.action do |args, options|
|
47
47
|
app = CarthageCache::Application.new(args.first || ".", verbose, config)
|
48
|
-
app.install_archive
|
48
|
+
exit 1 unless app.install_archive
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
data/lib/carthage_cache.rb
CHANGED
@@ -10,54 +10,10 @@ require "carthage_cache/terminal"
|
|
10
10
|
require "carthage_cache/configuration"
|
11
11
|
require "carthage_cache/configurator"
|
12
12
|
require "carthage_cache/configurator_wizard"
|
13
|
+
require "carthage_cache/shell_command_executor.rb"
|
14
|
+
require "carthage_cache/application.rb"
|
15
|
+
require "carthage_cache/swift_version_resolver.rb"
|
13
16
|
|
14
17
|
module CarthageCache
|
15
18
|
|
16
|
-
class Application
|
17
|
-
|
18
|
-
CACHE_DIR_NAME = "carthage_cache"
|
19
|
-
|
20
|
-
attr_reader :terminal
|
21
|
-
attr_reader :archiver
|
22
|
-
attr_reader :repository
|
23
|
-
attr_reader :project
|
24
|
-
attr_reader :config
|
25
|
-
|
26
|
-
def initialize(project_path, verbose, config)
|
27
|
-
@terminal = Terminal.new(verbose)
|
28
|
-
@archiver = Archiver.new
|
29
|
-
@config = Configurator.new(project_path, config).config
|
30
|
-
@repository = Repository.new(@config.bucket_name, @config.hash_object[:aws_s3_client_options])
|
31
|
-
@project = Project.new(project_path, CACHE_DIR_NAME, terminal)
|
32
|
-
end
|
33
|
-
|
34
|
-
def archive_exist?
|
35
|
-
repository.archive_exist?(project.archive_filename)
|
36
|
-
end
|
37
|
-
|
38
|
-
def install_archive
|
39
|
-
if archive_exist?
|
40
|
-
archive_installer.install
|
41
|
-
else
|
42
|
-
terminal.puts "There is no cached archive for the current Cartfile.resolved file."
|
43
|
-
exit 1
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def create_archive(force = false)
|
48
|
-
archive_builder.build if force || !archive_exist?
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def archive_installer
|
54
|
-
@archive_installer ||= ArchiveInstaller.new(terminal, repository, archiver, project)
|
55
|
-
end
|
56
|
-
|
57
|
-
def archive_builder
|
58
|
-
@archive_builder ||= ArchiveBuilder.new(terminal, repository, archiver, project)
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
19
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module CarthageCache
|
2
|
+
|
3
|
+
class Application
|
4
|
+
|
5
|
+
CACHE_DIR_NAME = "carthage_cache"
|
6
|
+
|
7
|
+
attr_reader :terminal
|
8
|
+
attr_reader :archiver
|
9
|
+
attr_reader :repository
|
10
|
+
attr_reader :project
|
11
|
+
attr_reader :config
|
12
|
+
|
13
|
+
def initialize(project_path, verbose, config, repository: Repository, terminal: Terminal, swift_version_resolver: SwiftVersionResolver)
|
14
|
+
@terminal = terminal.new(verbose)
|
15
|
+
@archiver = Archiver.new
|
16
|
+
@config = Configurator.new(project_path, config).config
|
17
|
+
@repository = repository.new(@config.bucket_name, @config.hash_object[:aws_s3_client_options])
|
18
|
+
@project = Project.new(project_path, CACHE_DIR_NAME, terminal, @config.tmpdir, swift_version_resolver.new)
|
19
|
+
end
|
20
|
+
|
21
|
+
def archive_exist?
|
22
|
+
repository.archive_exist?(project.archive_filename)
|
23
|
+
end
|
24
|
+
|
25
|
+
def install_archive
|
26
|
+
if archive_exist?
|
27
|
+
archive_installer.install
|
28
|
+
true
|
29
|
+
else
|
30
|
+
terminal.puts "There is no cached archive for the current Cartfile.resolved file."
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_archive(force = false)
|
36
|
+
archive_builder.build if force || !archive_exist?
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def archive_installer
|
42
|
+
@archive_installer ||= ArchiveInstaller.new(terminal, repository, archiver, project)
|
43
|
+
end
|
44
|
+
|
45
|
+
def archive_builder
|
46
|
+
@archive_builder ||= ArchiveBuilder.new(terminal, repository, archiver, project)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -2,13 +2,19 @@ module CarthageCache
|
|
2
2
|
|
3
3
|
class Archiver
|
4
4
|
|
5
|
+
attr_reader :executor
|
6
|
+
|
7
|
+
def initialize(executor = ShellCommandExecutor.new)
|
8
|
+
@executor = executor
|
9
|
+
end
|
10
|
+
|
5
11
|
def archive(archive_path, destination_path)
|
6
12
|
files = Dir.entries(archive_path).select { |x| !x.start_with?(".") }
|
7
|
-
|
13
|
+
executor.execute("cd #{archive_path} && zip -r -X #{File.expand_path(destination_path)} #{files.join(' ')} > /dev/null")
|
8
14
|
end
|
9
15
|
|
10
16
|
def unarchive(archive_path, destination_path)
|
11
|
-
|
17
|
+
executor.execute("unzip -o #{archive_path} -d #{destination_path} > /dev/null")
|
12
18
|
end
|
13
19
|
|
14
20
|
end
|
@@ -6,18 +6,23 @@ module CarthageCache
|
|
6
6
|
|
7
7
|
attr_reader :file_path
|
8
8
|
|
9
|
-
def initialize(file_path)
|
9
|
+
def initialize(file_path, swift_version_resolver = SwiftVersionResolver.new)
|
10
10
|
@file_path = file_path
|
11
|
+
@swift_version_resolver = swift_version_resolver
|
11
12
|
end
|
12
13
|
|
13
14
|
def digest
|
14
|
-
@digest ||= Digest::SHA256.hexdigest(content)
|
15
|
+
@digest ||= Digest::SHA256.hexdigest(content + "#{swift_version}")
|
15
16
|
end
|
16
17
|
|
17
18
|
def content
|
18
19
|
@content ||= File.read(file_path)
|
19
20
|
end
|
20
21
|
|
22
|
+
def swift_version
|
23
|
+
@swift_version ||= @swift_version_resolver.swift_version
|
24
|
+
end
|
25
|
+
|
21
26
|
end
|
22
27
|
|
23
28
|
end
|
@@ -32,7 +32,8 @@ module CarthageCache
|
|
32
32
|
region: ENV['AWS_REGION'],
|
33
33
|
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
34
34
|
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
35
|
-
}
|
35
|
+
},
|
36
|
+
tmpdir: Dir.tmpdir
|
36
37
|
})
|
37
38
|
end
|
38
39
|
|
@@ -40,6 +41,7 @@ module CarthageCache
|
|
40
41
|
config_key :aws_region
|
41
42
|
config_key :aws_access_key_id
|
42
43
|
config_key :aws_secret_access_key
|
44
|
+
config_key :tmpdir
|
43
45
|
|
44
46
|
attr_reader :hash_object
|
45
47
|
|
@@ -6,12 +6,14 @@ module CarthageCache
|
|
6
6
|
attr_reader :project_path
|
7
7
|
attr_reader :cache_dir_name
|
8
8
|
attr_reader :terminal
|
9
|
+
attr_reader :tmpdir_base_path
|
9
10
|
|
10
|
-
def initialize(project_path, cache_dir_name, terminal)
|
11
|
+
def initialize(project_path, cache_dir_name, terminal, tmpdir, swift_version_resolver = SwiftVersionResolver.new)
|
11
12
|
@project_path = project_path
|
12
13
|
@cache_dir_name = cache_dir_name
|
13
14
|
@terminal = terminal
|
14
|
-
@
|
15
|
+
@tmpdir_base_path = tmpdir
|
16
|
+
@cartfile = CartfileResolvedFile.new(cartfile_resolved_path, swift_version_resolver)
|
15
17
|
end
|
16
18
|
|
17
19
|
def archive_filename
|
@@ -37,7 +39,7 @@ module CarthageCache
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def create_tmpdir
|
40
|
-
dir = File.join(
|
42
|
+
dir = File.join(tmpdir_base_path, cache_dir_name)
|
41
43
|
unless File.exist?(dir)
|
42
44
|
terminal.vputs "Creating carthage cache directory at '#{dir}'."
|
43
45
|
FileUtils.mkdir_p(dir)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CarthageCache
|
2
|
+
|
3
|
+
class SwiftVersionResolver
|
4
|
+
|
5
|
+
def initialize(executor = ShellCommandExecutor.new)
|
6
|
+
@executor = executor
|
7
|
+
end
|
8
|
+
|
9
|
+
def swift_version
|
10
|
+
output = @executor.execute('xcrun swift -version').chomp
|
11
|
+
version_string = /(\d+\.)?(\d+\.)?(\d+)/.match(output).to_s
|
12
|
+
Gem::Version.new(version_string)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carthage_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guido Marucci Blas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: aws-sdk
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +133,7 @@ files:
|
|
119
133
|
- carthage_cache.gemspec
|
120
134
|
- exe/carthage_cache
|
121
135
|
- lib/carthage_cache.rb
|
136
|
+
- lib/carthage_cache/application.rb
|
122
137
|
- lib/carthage_cache/archive_builder.rb
|
123
138
|
- lib/carthage_cache/archive_installer.rb
|
124
139
|
- lib/carthage_cache/archiver.rb
|
@@ -129,6 +144,8 @@ files:
|
|
129
144
|
- lib/carthage_cache/description.rb
|
130
145
|
- lib/carthage_cache/project.rb
|
131
146
|
- lib/carthage_cache/repository.rb
|
147
|
+
- lib/carthage_cache/shell_command_executor.rb
|
148
|
+
- lib/carthage_cache/swift_version_resolver.rb
|
132
149
|
- lib/carthage_cache/terminal.rb
|
133
150
|
- lib/carthage_cache/version.rb
|
134
151
|
homepage: https://github.com/guidomb/carthage_cache
|