e2e: remove upload to sauce from fastlane and fix in e2e

This commit is contained in:
Churikova Tetiana 2023-02-03 14:00:58 +01:00
parent 0202af8070
commit 89039cd79a
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
2 changed files with 7 additions and 41 deletions

View File

@ -50,25 +50,6 @@ def retry_curl_upload(url, file, auth, conn_timeout = 5, timeout = 60, retries =
end end
end end
# uploads `file` to sauce labs (overwrites if there is anoter file from the
# same commit)
def upload_to_saucelabs(file)
key = ENV['SAUCE_ACCESS_KEY']
username = ENV['SAUCE_USERNAME']
unique_name = ENV['SAUCE_LABS_NAME']
url = "https://eu-central-1.saucelabs.com/rest/v1/storage/#{username}/#{unique_name}?overwrite=true"
upload_result = retry_curl_upload(url, file, "#{username}:#{key}")
# fail the lane if upload fails
unless upload_result.include? 'filename'
UI.user_error!(
"failed to upload file to saucelabs despite retries: #{upload_result}"
)
end
end
# Creates and unlocks a keychain into which Fastlane match imports signing keys and certs. # Creates and unlocks a keychain into which Fastlane match imports signing keys and certs.
class Keychain class Keychain
attr_accessor :name, :pass attr_accessor :name, :pass
@ -365,15 +346,4 @@ platform :android do
uniApk = APK_PATHS.detect { |a| a.include? 'universal' } uniApk = APK_PATHS.detect { |a| a.include? 'universal' }
upload_to_diawi(uniApk) upload_to_diawi(uniApk)
end end
desc '`fastlane android saucelabs` - upload .apk to sauce labs'
desc 'expects to have an .apk prepared: `result/app.apk`'
desc 'expects to have a saucelabs access key as SAUCE_ACCESS_KEY env variable'
desc 'expects to have a saucelabs username token as SAUCE_USERNAME env variable'
desc 'expects to have a saucelabs destination name as SAUCE_LABS_NAME env variable'
desc "will fails if file isn't there"
lane :saucelabs do
e2eApk = APK_PATHS.detect { |a| a.include? 'x86' }
upload_to_saucelabs(e2eApk)
end
end end

View File

@ -4,11 +4,11 @@ from datetime import datetime
from http.client import RemoteDisconnected from http.client import RemoteDisconnected
from os import environ from os import environ
from time import sleep from time import sleep
from io import BytesIO import os
import urllib.request
import pytest import pytest
from _pytest.runner import runtestprotocol from _pytest.runner import runtestprotocol
import requests
import tests import tests
from support.device_stats_db import DeviceStatsDB from support.device_stats_db import DeviceStatsDB
@ -203,18 +203,14 @@ def pytest_configure(config):
if config.getoption('env') == 'sauce': if config.getoption('env') == 'sauce':
if not is_uploaded(): if not is_uploaded():
if 'http' in config.getoption('apk'): if 'http' in config.getoption('apk'):
response = requests.get(config.getoption('apk'), stream=True)
response.raise_for_status()
apk_name = config.getoption('apk').split("/")[-1] apk_name = config.getoption('apk').split("/")[-1]
file = BytesIO(response.content) # it works with just a file_name, but I've added full path because not sure how it'll behave on the remote run (Jenkins)
del response file_path = os.path.join(os.path.dirname(__file__), apk_name)
for _ in range(3): for _ in range(3):
try: try:
requests.post('https://' + apibase + '/rest/v1/storage/' urllib.request.urlretrieve(config.getoption('apk'), filename=file_path) # if url is not valid it raises an error
+ sauce_username + '/' + apk_name + '?overwrite=true', sauce.storage.upload(file_path)
auth=(sauce_username, sauce_access_key), os.remove(file_path)
data=file,
headers={'Content-Type': 'application/octet-stream'})
break break
except ConnectionError: except ConnectionError:
sleep(10) sleep(10)