e2e: remove upload to sauce from fastlane and fix in e2e
This commit is contained in:
parent
0202af8070
commit
89039cd79a
|
@ -50,25 +50,6 @@ def retry_curl_upload(url, file, auth, conn_timeout = 5, timeout = 60, retries =
|
|||
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.
|
||||
class Keychain
|
||||
attr_accessor :name, :pass
|
||||
|
@ -365,15 +346,4 @@ platform :android do
|
|||
uniApk = APK_PATHS.detect { |a| a.include? 'universal' }
|
||||
upload_to_diawi(uniApk)
|
||||
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
|
||||
|
|
|
@ -4,11 +4,11 @@ from datetime import datetime
|
|||
from http.client import RemoteDisconnected
|
||||
from os import environ
|
||||
from time import sleep
|
||||
from io import BytesIO
|
||||
import os
|
||||
import urllib.request
|
||||
|
||||
import pytest
|
||||
from _pytest.runner import runtestprotocol
|
||||
import requests
|
||||
|
||||
import tests
|
||||
from support.device_stats_db import DeviceStatsDB
|
||||
|
@ -203,18 +203,14 @@ def pytest_configure(config):
|
|||
if config.getoption('env') == 'sauce':
|
||||
if not is_uploaded():
|
||||
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]
|
||||
file = BytesIO(response.content)
|
||||
del response
|
||||
# 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)
|
||||
file_path = os.path.join(os.path.dirname(__file__), apk_name)
|
||||
for _ in range(3):
|
||||
try:
|
||||
requests.post('https://' + apibase + '/rest/v1/storage/'
|
||||
+ sauce_username + '/' + apk_name + '?overwrite=true',
|
||||
auth=(sauce_username, sauce_access_key),
|
||||
data=file,
|
||||
headers={'Content-Type': 'application/octet-stream'})
|
||||
urllib.request.urlretrieve(config.getoption('apk'), filename=file_path) # if url is not valid it raises an error
|
||||
sauce.storage.upload(file_path)
|
||||
os.remove(file_path)
|
||||
break
|
||||
except ConnectionError:
|
||||
sleep(10)
|
||||
|
|
Loading…
Reference in New Issue