class Fastlane::Actions::UploadSnapshotAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb, line 54
def self.authors
  ["MoyuruAizawa"]
end
available_options() click to toggle source
# 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
description() click to toggle source
# File lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb, line 21
def self.description
  "Upload Snapshot"
end
details() click to toggle source
# File lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb, line 25
def self.details
  "Upload Snapshot"
end
example_code() click to toggle source
# 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) click to toggle source
# File lib/fastlane/plugin/snapshot_test/actions/regression/upload_snapshot.rb, line 58
def self.is_supported?(platform)
  true
end
run(params) click to toggle source
# 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