fastlane-plugin-build_cache 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b340bae99f72196dfefb748a59afcc6428f13b0b
4
+ data.tar.gz: 22bcc41493691de2b611ab8b2c16c6c27d311821
5
+ SHA512:
6
+ metadata.gz: 61acecde35e545d6a5daba795721b35e826eeb15c4ecac2a78574fca90273d237a31e5f07ebc92dda65095bccb3e52827c37accb8fccdd4752397f93195ed3c0
7
+ data.tar.gz: c9fef9d851367775aa54d23f8c0ffea0c2a9439e7cf73910dbce73252f94ec4120100b64e2e816ee8e9e24da7e3f2ca4d73ca43726e73ea0b7911fe3c9152a1d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Fernando Saragoca <fsaragoca@me.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # build_cache plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-build_cache)
4
+ [![Twitter: @fsaragoca](https://img.shields.io/badge/contact-@fsaragoca-blue.svg?style=flat)](https://twitter.com/fsaragoca)
5
+
6
+ [![CircleCI](https://circleci.com/gh/fsaragoca/fastlane-plugin-build_cache.svg?style=svg)](https://circleci.com/gh/fsaragoca/fastlane-plugin-build_cache)
7
+
8
+ ## Getting Started
9
+
10
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-build_cache`, add it to your project by running:
11
+
12
+ ```bash
13
+ fastlane add_plugin build_cache
14
+ ```
15
+
16
+ ## About build_cache
17
+
18
+ Helper for caching builds when using Xcode 8 features 'build for testing' & 'test without building'
19
+
20
+ ## Example
21
+
22
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
23
+
24
+ ## Run tests for this plugin
25
+
26
+ To run both the tests, and code style validation, run
27
+
28
+ ```
29
+ rake
30
+ ```
31
+
32
+ To automatically fix many of the styling issues, use
33
+ ```
34
+ rubocop -a
35
+ ```
36
+
37
+ ## Issues and Feedback
38
+
39
+ For any other issues and feedback about this plugin, please submit it to this repository.
40
+
41
+ ## Troubleshooting
42
+
43
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
44
+
45
+ ## Using `fastlane` Plugins
46
+
47
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
48
+
49
+ ## About `fastlane`
50
+
51
+ `fastlane` is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/build_cache/version'
2
+
3
+ module Fastlane
4
+ module BuildCache
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::BuildCache.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,66 @@
1
+ module Fastlane
2
+ module Actions
3
+ class ArchiveDerivedDataAction < Action
4
+ def self.run(params)
5
+ build_identifier = params[:build_identifier]
6
+ workspace_path = params[:workspace_path]
7
+ Helper::BuildCacheHelper.ensure_workspace_folder_exists(workspace_path)
8
+
9
+ derived_data_path = params[:derived_data_path]
10
+ derived_data_path_components = derived_data_path.split('/')
11
+ derived_data_folder_name = derived_data_path_components.pop
12
+
13
+ zip_tmp_path = File.join(derived_data_path_components.join('/'), build_identifier)
14
+ zip_final_path = File.join(workspace_path, build_identifier)
15
+
16
+ files_to_delete = [File.join(derived_data_path, 'ModuleCache'),
17
+ File.join(derived_data_path, 'Logs')]
18
+ files_to_delete << zip_tmp_path
19
+ files_to_delete << zip_final_path
20
+
21
+ files_to_delete.each do |file|
22
+ Actions.sh("rm -rf #{file}", log: $verbose)
23
+ end
24
+
25
+ Actions.sh("cd #{derived_data_path} && cd ../ && zip -r #{build_identifier} #{derived_data_folder_name}", log: $verbose)
26
+ Actions.sh("mv #{zip_tmp_path} #{zip_final_path}", log: $verbose)
27
+
28
+ zip_final_path
29
+ end
30
+
31
+ def self.description
32
+ "Archives derived data folder in a zip file for later use"
33
+ end
34
+
35
+ def self.authors
36
+ ["Fernando Saragoca"]
37
+ end
38
+
39
+ def self.return_value
40
+ "Returns path for archived zip file"
41
+ end
42
+
43
+ def self.available_options
44
+ [
45
+ FastlaneCore::ConfigItem.new(key: :derived_data_path,
46
+ env_name: "BUILD_CACHE_DERIVED_DATA_PATH",
47
+ description: "Path to derived data folder",
48
+ type: String),
49
+ FastlaneCore::ConfigItem.new(key: :workspace_path,
50
+ env_name: "BUILD_CACHE_WORKSPACE_PATH",
51
+ description: "Build cache workspace",
52
+ type: String),
53
+ FastlaneCore::ConfigItem.new(key: :build_identifier,
54
+ env_name: "BUILD_CACHE_BUILD_IDENTIFIER",
55
+ description: "Identifier for current build",
56
+ default_value: Helper::BuildCacheHelper.build_identifier,
57
+ type: String)
58
+ ]
59
+ end
60
+
61
+ def self.is_supported?(platform)
62
+ true
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,42 @@
1
+ module Fastlane
2
+ module Actions
3
+ class CheckBuildCacheWorkspaceAction < Action
4
+ def self.run(params)
5
+ workspace_path = params[:workspace_path]
6
+ build_identifier = params[:build_identifier]
7
+ full_path = File.join(workspace_path, build_identifier)
8
+ File.file?(full_path)
9
+ end
10
+
11
+ def self.description
12
+ "Check if cache for current build is avaiable"
13
+ end
14
+
15
+ def self.authors
16
+ ["Fernando Saragoca"]
17
+ end
18
+
19
+ def self.return_value
20
+ "Boolean indicating if cache for current build is available"
21
+ end
22
+
23
+ def self.available_options
24
+ [
25
+ FastlaneCore::ConfigItem.new(key: :workspace_path,
26
+ env_name: "BUILD_CACHE_WORKSPACE_PATH",
27
+ description: "Build cache workspace",
28
+ type: String),
29
+ FastlaneCore::ConfigItem.new(key: :build_identifier,
30
+ env_name: "BUILD_CACHE_BUILD_IDENTIFIER",
31
+ description: "Identifier for current build",
32
+ default_value: Helper::BuildCacheHelper.build_identifier,
33
+ type: String)
34
+ ]
35
+ end
36
+
37
+ def self.is_supported?(platform)
38
+ true
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ module Fastlane
2
+ module Actions
3
+ class CleanBuildCacheWorkspaceAction < Action
4
+ def self.run(params)
5
+ workspace_path = params[:workspace_path]
6
+ max_build_count = params[:max_build_count]
7
+
8
+ files = Dir[workspace_path + '/*.zip']
9
+ number_of_files_to_delete = files.count - max_build_count
10
+ if number_of_files_to_delete > 0
11
+ # `File.atime` returns the last access time for the named file as a Time object.
12
+ sorted_files = files.sort_by { |filename| File.atime(filename) }
13
+ sorted_files.take(number_of_files_to_delete).each do |file|
14
+ Actions.sh("rm -rf #{file}", log: $verbose)
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.description
20
+ "Cleans workspace by removing old builds, using last access time for comparison"
21
+ end
22
+
23
+ def self.authors
24
+ ["Fernando Saragoca"]
25
+ end
26
+
27
+ def self.available_options
28
+ [
29
+ FastlaneCore::ConfigItem.new(key: :workspace_path,
30
+ env_name: "BUILD_CACHE_WORKSPACE_PATH",
31
+ description: "Build cache workspace",
32
+ type: String),
33
+ FastlaneCore::ConfigItem.new(key: :max_build_count,
34
+ env_name: "BUILD_CACHE_MAX_BUILD_COUNT",
35
+ description: "Number of archives to keep in workspace",
36
+ default_value: 10,
37
+ type: Integer)
38
+ ]
39
+ end
40
+
41
+ def self.is_supported?(platform)
42
+ true
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,55 @@
1
+ module Fastlane
2
+ module Actions
3
+ class UnarchiveDerivedDataAction < Action
4
+ def self.run(params)
5
+ build_identifier = params[:build_identifier]
6
+ workspace_path = params[:workspace_path]
7
+ Helper::BuildCacheHelper.ensure_workspace_folder_exists(workspace_path)
8
+
9
+ derived_data_path = params[:derived_data_path]
10
+ derived_data_path_components = derived_data_path.split('/')
11
+ derived_data_path_components.pop
12
+
13
+ derived_data_root_folder_path = derived_data_path_components.join('/')
14
+ zip_path = File.join(workspace_path, build_identifier)
15
+
16
+ if File.exist?(zip_path)
17
+ Actions.sh("unzip #{zip_path} -d #{derived_data_root_folder_path}", log: $verbose)
18
+ else
19
+ UI.user_error! "Unable to find cache for build '#{build_identifier}' 🚫"
20
+ end
21
+ end
22
+
23
+ def self.description
24
+ "Unarchives derived data folder from a zip file"
25
+ end
26
+
27
+ def self.authors
28
+ ["Fernando Saragoca"]
29
+ end
30
+
31
+ def self.available_options
32
+ [
33
+ FastlaneCore::ConfigItem.new(key: :derived_data_path,
34
+ env_name: "BUILD_CACHE_DERIVED_DATA_PATH",
35
+ description: "Path to derived data folder",
36
+ default_value: ENV['DERIVED_DATA_PATH'],
37
+ type: String),
38
+ FastlaneCore::ConfigItem.new(key: :workspace_path,
39
+ env_name: "BUILD_CACHE_WORKSPACE_PATH",
40
+ description: "Build cache workspace",
41
+ type: String),
42
+ FastlaneCore::ConfigItem.new(key: :build_identifier,
43
+ env_name: "BUILD_CACHE_BUILD_IDENTIFIER",
44
+ description: "Identifier for current build",
45
+ default_value: Helper::BuildCacheHelper.build_identifier,
46
+ type: String)
47
+ ]
48
+ end
49
+
50
+ def self.is_supported?(platform)
51
+ true
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,18 @@
1
+ module Fastlane
2
+ module Helper
3
+ class BuildCacheHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::BuildCacheHelper.your_method`
6
+ #
7
+ def self.build_identifier
8
+ commits = Actions.sh('git rev-list HEAD', log: $verbose).chomp
9
+ identifier = Digest::SHA256.hexdigest(commits)
10
+ identifier + '.zip'
11
+ end
12
+
13
+ def self.ensure_workspace_folder_exists(workspace_path)
14
+ `mkdir #{workspace_path}` unless File.exist?(workspace_path)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module BuildCache
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-build_cache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fernando Saragoca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: s3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fastlane
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.5
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.5
111
+ description:
112
+ email: fsaragoca@me.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - LICENSE
118
+ - README.md
119
+ - lib/fastlane/plugin/build_cache.rb
120
+ - lib/fastlane/plugin/build_cache/actions/archive_derived_data_action.rb
121
+ - lib/fastlane/plugin/build_cache/actions/check_build_cache_workspace_action.rb
122
+ - lib/fastlane/plugin/build_cache/actions/clean_build_cache_workspace_action.rb
123
+ - lib/fastlane/plugin/build_cache/actions/unarchive_derived_data_action.rb
124
+ - lib/fastlane/plugin/build_cache/helper/build_cache_helper.rb
125
+ - lib/fastlane/plugin/build_cache/version.rb
126
+ homepage: https://github.com/fsaragoca/fastlane-plugin-build_cache
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.5.1
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: Helper for caching builds when using 'build for testing' & 'test without
150
+ building'
151
+ test_files: []