class Publisher::Uploaders::GCS
Google cloud storage uploader implementation
Private Instance Methods
bucket()
click to toggle source
GCS
bucket
@return [Google::Cloud::Storage::Bucket]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 20 def bucket @bucket ||= client.bucket(bucket_name, skip_lookup: true) end
client()
click to toggle source
GCS
client
@return [Google::Cloud::Storage::Project]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 13 def client @client ||= Google::Cloud::Storage.new end
download_history()
click to toggle source
Download allure history
@return [void]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 41 def download_history HISTORY.each do |file_name| file = bucket.file(key(prefix, "history", file_name)) raise(HistoryNotFoundError, "Allure history from previous runs not found!") unless file file.download(path(results_path, "history", file_name)) end end
key(*args)
click to toggle source
Fabricate key for s3 object
@param [String] *args @return [String]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 91 def key(*args) args.compact.join("/") end
latest_report_url()
click to toggle source
Latest report url
@return [String]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 34 def latest_report_url @latest_report_url ||= url(prefix) end
report_url()
click to toggle source
Report url
@return [String]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 27 def report_url @report_url ||= url(full_prefix) end
upload_history()
click to toggle source
Upload allure history
@return [void]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 53 def upload_history upload_to_gcs(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix) end
upload_latest_copy()
click to toggle source
Upload copy of latest run
@return [void]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 67 def upload_latest_copy upload_to_gcs(report_files, prefix) end
upload_report()
click to toggle source
Upload allure report
@return [void]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 60 def upload_report upload_to_gcs(report_files, full_prefix) end
upload_to_gcs(files, key_prefix)
click to toggle source
Upload files to s3
@param [Array<Pathname>] files @param [String] key_prefix @return [Array<Hash>]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 76 def upload_to_gcs(files, key_prefix) args = files.map do |file| { file: file.to_s, path: key(key_prefix, file.relative_path_from(report_path)) } end Parallel.each(args, in_threads: 8) { |obj| bucket.create_file(obj[:file], obj[:path]) } end
url(path_prefix)
click to toggle source
Report url
@param [String] path_prefix @return [String]
# File lib/allure_report_publisher/lib/uploaders/gcs.rb, line 99 def url(path_prefix) ["https://storage.googleapis.com", bucket_name, path_prefix, "index.html"].compact.join("/") end