Skip to content

Commit

Permalink
Migrate from legacy sauce storage (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfehler authored Jun 29, 2021
1 parent c8800ba commit 9540e35
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,21 @@ jobs:
tunnelIdentifier: github-action-tunnel

- name: Install test dependencies
run: pip install tox coveralls
run: pip install tox coveralls requests

- name: Set env
run: echo "USE_SAUCE_LABS=True" >> $GITHUB_ENV

- name: "Show environment variables"
run: |
env
# Runs a single command using the runners shell
- name: Run tests on Sauce Labs
env:
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
run: |
python scripts/upload_ios_app.py;
tox -e flake8;
tox -e ${{matrix.PY_VER}}-stere;
tox -e ${{matrix.PY_VER}}-splinter -- --splinter-webdriver=remote --sauce-remote-url=http://${{secrets.SAUCE_USERNAME}}:${{secrets.SAUCE_ACCESS_KEY}}@ondemand.saucelabs.com/wd/hub;
tox -e ${{matrix.PY_VER}}-appium -- --sauce-remote-url=http://${{secrets.SAUCE_USERNAME}}:${{secrets.SAUCE_ACCESS_KEY}}@ondemand.saucelabs.com/wd/hub;
tox -e ${{matrix.PY_VER}}-splinter -- --splinter-webdriver=remote --sauce-remote-url=http://${{secrets.SAUCE_USERNAME}}:${{secrets.SAUCE_ACCESS_KEY}}@ondemand.us-west-1.saucelabs.com/wd/hub;
tox -e ${{matrix.PY_VER}}-appium -- --sauce-remote-url=http://${{secrets.SAUCE_USERNAME}}:${{secrets.SAUCE_ACCESS_KEY}}@ondemand.us-west-1.saucelabs.com/wd/hub;
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v1
Expand Down
41 changes: 41 additions & 0 deletions scripts/upload_ios_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os

import requests


SAUCE_USERNAME = os.getenv('SAUCE_USERNAME')
SAUCE_ACCESS_KEY = os.getenv('SAUCE_ACCESS_KEY')
SAUCE_UPLOAD_URL = 'https://api.us-west-1.saucelabs.com/v1/storage/upload'

APP_URL = (
'https://github.com/jsfehler/stere_ios_test_app/'
'raw/master/build/stere_ios_test_app.zip'
)
APP_FILENAME = 'stere_ios_test_app.zip'


def get_app():
"""Download the test app and save it to disk."""
response = requests.get(APP_URL)

with open(APP_FILENAME, 'wb') as f:
for block in response.iter_content():
f.write(block)


def upload_app_to_sauce():
"""Upload the test app to sauce labs."""
with open(APP_FILENAME, 'rb') as f:
response = requests.post(
SAUCE_UPLOAD_URL,
files={'payload': f, 'name': APP_FILENAME},
auth=(SAUCE_USERNAME, SAUCE_ACCESS_KEY),
)

return response


if __name__ == '__main__':
# Upload the IOS test app to sauce storage before running any tests.
get_app()
upload_app_to_sauce()
2 changes: 1 addition & 1 deletion tests/appium/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def appium_capabilities(request):
'browserName': '',
'appiumVersion': '1.9.1',
'deviceOrientation': 'portrait',
'app': 'sauce-storage:stere_ios_test_app.zip',
'app': 'storage:filename=stere_ios_test_app.zip',
}

if browser_name == 'ios':
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ commands =
skip_install = true
deps = -rrequirements/lint.txt
changedir = .
commands = flake8 stere tests
commands = flake8 stere tests scripts

0 comments on commit 9540e35

Please sign in to comment.