Class: Fastlane::Actions::UploadSnapshotAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb

Class Method Summary collapse

Class Method Details

.authorsObject



54
55
56
# File 'lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb', line 54

def self.authors
  ["MoyuruAizawa"]
end

.available_optionsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb', line 29

def self.available_options
  [
      FastlaneCore::ConfigItem.new(key: :gcloud_service_key_file,
                                   env_name: "GCLOUD_SERVICE_KEY_FILE",
                                   description: "File path containing the gcloud auth key. Default: Created from GCLOUD_SERVICE_KEY environment variable",
                                   type: String,
                                   optional: false),
      FastlaneCore::ConfigItem.new(key: :snapshot_bucket,
                                   env_name: "SNAPSHOT_BUCKET",
                                   description: "GCS Bucket that stores expected images",
                                   type: String,
                                   optional: false),
      FastlaneCore::ConfigItem.new(key: :working_dir,
                                   env_name: "WORKING_DIR",
                                   description: "Working directory",
                                   type: String,
                                   optional: false),
      FastlaneCore::ConfigItem.new(key: :screenshot_dir,
                                   env_name: "SCREENSHOT_DIR",
                                   description: "Working directory",
                                   type: String,
                                   optional: false)
  ]
end

.descriptionObject



21
22
23
# File 'lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb', line 21

def self.description
  "Upload Snapshot"
end

.detailsObject



25
26
27
# File 'lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb', line 25

def self.details
  "Upload Snapshot"
end

.example_codeObject



62
63
64
65
66
67
68
69
# File 'lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb', line 62

def self.example_code
  ['upload_snapshot(
      gcloud_service_key_file: "fastlane/client-secret.json",
      snapshot_bucket: "cats-android-snapshot",
      working_dir: ".snapshot_test",
      screenshot_dir: ".screenshot/shamu-22-ja_JP-portrait"
  )']
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb', line 58

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb', line 8

def self.run(params)
  Helper.authenticate(params[:gcloud_service_key_file])

  UI.message "Copy screenshots to working directory"
  working_dir = params[:working_dir]
  screenshot_dir = params[:screenshot_dir]
  `mkdir #{working_dir}`
  `rm -rf #{working_dir}/actual`
  `mkdir #{working_dir}/actual`
  Action.sh "cp -pR #{screenshot_dir}/* #{working_dir}/actual"
  Action.sh "gsutil -m rsync -d -r #{working_dir} gs://#{params[:snapshot_bucket]}/#{Helper.get_current_commit_hash}"
end