Class: Fastlane::Actions::ConfigureValidateAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::ConfigureValidateAction
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb
Class Method Summary collapse
- .absolute_project_path(relative_path) ⇒ Object
- .absolute_secret_store_path(relative_path) ⇒ Object
- .authors ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .file_hash(absolute_path) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .run(params = {}) ⇒ Object
- .validate_that_all_copied_files_match ⇒ Object
-
.validate_that_branches_match ⇒ Object
Validate that the branch specified in .configure matches the branch checked out in ~/.mobile-secrets.
- .validate_that_configure_file_exists ⇒ Object
-
.validate_that_hashes_match ⇒ Object
Validate that the pinned hash specified in .configure matches the current hash of ~/.mobile-secrets.
-
.validate_that_no_dependent_files_have_changed ⇒ Object
Validate that based on the commit hash in the .configure file, no files have changed that affect this project.
-
.validate_that_secrets_repo_is_clean ⇒ Object
Validate that the secrets repo doesn’t have any local changes.
Class Method Details
.absolute_project_path(relative_path) ⇒ Object
105 106 107 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 105 def self.absolute_project_path(relative_path) Fastlane::Helper::FilesystemHelper.absolute_project_path(relative_path) end |
.absolute_secret_store_path(relative_path) ⇒ Object
109 110 111 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 109 def self.absolute_secret_store_path(relative_path) Fastlane::Helper::FilesystemHelper.absolute_secret_store_path(relative_path) end |
.authors ⇒ Object
121 122 123 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 121 def self. ['Automattic'] end |
.description ⇒ Object
117 118 119 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 117 def self.description 'Ensure that the configuration is valid' end |
.details ⇒ Object
125 126 127 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 125 def self.details 'Ensure that the configuration is valid' end |
.file_hash(absolute_path) ⇒ Object
113 114 115 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 113 def self.file_hash(absolute_path) Fastlane::Helper::FilesystemHelper.file_hash(absolute_path) end |
.is_supported?(platform) ⇒ Boolean
129 130 131 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 129 def self.is_supported?(platform) true end |
.run(params = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 10 def self.run(params = {}) # Start by ensuring that we've set up the project for configuration validate_that_configure_file_exists # Check that the secrets repo is locally clean _before_ downloading the latest version, # otherwise, the error messaging isn't as helpful. validate_that_secrets_repo_is_clean # Update the repository to get the latest version of the configuration secrets # – that's how we'll know if we're behind in subsequent validations ConfigureDownloadAction.run validate_that_branches_match validate_that_hashes_match validate_that_no_dependent_files_have_changed validate_that_all_copied_files_match UI.success 'Configuration is valid' end |
.validate_that_all_copied_files_match ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 89 def self.validate_that_all_copied_files_match Fastlane::Helper::ConfigureHelper.files_to_copy.each do |x| source = absolute_secret_store_path(x.file) destination = absolute_project_path(x.destination) source_hash = file_hash(source) destination_hash = file_hash(destination) UI.user_error!("`#{x.destination} doesn't match the file in the secrets repository (#{x.file}) – unable to continue") unless source_hash == destination_hash end end |
.validate_that_branches_match ⇒ Object
Validate that the branch specified in .configure matches the branch checked out in ~/.mobile-secrets.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 39 def self.validate_that_branches_match repo_branch_name = Fastlane::Helper::ConfigureHelper.repo_branch_name file_branch_name = Fastlane::Helper::ConfigureHelper.configure_file_branch_name unless repo_branch_name == file_branch_name UI.user_error!([ 'The branch specified in `.configure` is not the currently checked out branch in the secrets repository.', "To fix this issue, switch back to the `#{file_branch_name}` branch in the mobile secrets repository.", ].join("\n")) end end |
.validate_that_configure_file_exists ⇒ Object
101 102 103 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 101 def self.validate_that_configure_file_exists UI.user_error!("Couldn't find `.configure` file. Please set up this project for `configure` by running `bundle exec fastlane run configure_setup`") unless Fastlane::Helper::ConfigureHelper.configuration_path_exists end |
.validate_that_hashes_match ⇒ Object
Validate that the pinned hash specified in .configure matches the current hash of ~/.mobile-secrets
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 54 def self.validate_that_hashes_match repo_hash = Fastlane::Helper::ConfigureHelper.repo_commit_hash file_hash = Fastlane::Helper::ConfigureHelper.configure_file_commit_hash unless repo_hash == file_hash UI.user_error!([ 'The pinned_hash specified in `.configure` is not the currently checked out hash in the secrets repository.', "To fix this issue, check out the `#{file_hash}` hash in the mobile secrets repository.", ].join("\n")) end end |
.validate_that_no_dependent_files_have_changed ⇒ Object
Validate that based on the commit hash in the .configure file, no files have changed that affect this project.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 69 def self.validate_that_no_dependent_files_have_changed repo_hash = Fastlane::Helper::ConfigureHelper.repo_commit_hash file_hash = Fastlane::Helper::ConfigureHelper.configure_file_commit_hash changed_files = Fastlane::Helper::ConfigureHelper.files_changed_between(file_hash, repo_hash) dependencies = Fastlane::Helper::ConfigureHelper.file_dependencies new_files = Fastlane::Helper::ConfigureHelper.new_files_in(changed_files) changed_dependencies = changed_files & dependencies # calculate array intersection UI.user_error!("The following files are out of date. Please run `bundle exec fastlane run configure_update` before continuing:\n\n#{changed_dependencies}") unless changed_dependencies.empty? UI.user_error!("The following files are in the secrets repository, but aren't available for your project. Please run `bundle exec fastlane run configure_update` before continuing:\n\n#{new_files}") unless new_files.empty? end |
.validate_that_secrets_repo_is_clean ⇒ Object
Validate that the secrets repo doesn’t have any local changes
85 86 87 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb', line 85 def self.validate_that_secrets_repo_is_clean UI.user_error!('The secrets repository has uncommitted changes. Please commit or discard them before continuing.') unless Fastlane::Helper::ConfigureHelper.repo_has_changes end |