Class: Fastlane::Actions::CleanBuildCacheWorkspaceAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::CleanBuildCacheWorkspaceAction
- Defined in:
- lib/fastlane/plugin/build_cache/actions/clean_build_cache_workspace_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
23 24 25 |
# File 'lib/fastlane/plugin/build_cache/actions/clean_build_cache_workspace_action.rb', line 23 def self. ["Fernando Saragoca"] end |
.available_options ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fastlane/plugin/build_cache/actions/clean_build_cache_workspace_action.rb', line 27 def self. [ FastlaneCore::ConfigItem.new(key: :workspace_path, env_name: "BUILD_CACHE_WORKSPACE_PATH", description: "Build cache workspace", type: String), FastlaneCore::ConfigItem.new(key: :max_build_count, env_name: "BUILD_CACHE_MAX_BUILD_COUNT", description: "Number of archives to keep in workspace", default_value: 10, type: Integer) ] end |
.description ⇒ Object
19 20 21 |
# File 'lib/fastlane/plugin/build_cache/actions/clean_build_cache_workspace_action.rb', line 19 def self.description "Cleans workspace by removing old builds, using last access time for comparison" end |
.is_supported?(platform) ⇒ Boolean
41 42 43 |
# File 'lib/fastlane/plugin/build_cache/actions/clean_build_cache_workspace_action.rb', line 41 def self.is_supported?(platform) true end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fastlane/plugin/build_cache/actions/clean_build_cache_workspace_action.rb', line 4 def self.run(params) workspace_path = params[:workspace_path] max_build_count = params[:max_build_count] files = Dir[workspace_path + '/*.zip'] number_of_files_to_delete = files.count - max_build_count if number_of_files_to_delete > 0 # `File.atime` returns the last access time for the named file as a Time object. sorted_files = files.sort_by { |filename| File.atime(filename) } sorted_files.take(number_of_files_to_delete).each do |file| Actions.sh("rm -rf #{file}", log: $verbose) end end end |