Skip to content

Commit

Permalink
Merge pull request #8 from HDE/browserstack
Browse files Browse the repository at this point in the history
Add tests via browserstack
  • Loading branch information
ojii committed Jul 15, 2017
2 parents 6dc7831 + 94e7185 commit 26da655
Show file tree
Hide file tree
Showing 41 changed files with 13,526 additions and 140 deletions.
Binary file added .circleci/browserstack-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12,954 changes: 12,954 additions & 0 deletions .circleci/browserstack-logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 131 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,145 @@
version: 2
defaults: &defaults
working_directory: /home/
docker:
- image: docker/compose:1.9.0
jobs:
build:
docker:
- image: docker/compose:1.9.0
working_directory: /home/
<<: *defaults
steps:
- setup_remote_docker
- setup_remote_docker:
reusable: true
exclusive: true
- checkout
- run: docker-compose pull
- run: docker-compose build
- run:
name: Run tests
name: Run unit tests
command: |
docker-compose \
run \
-e WEB_APP_BASE_URL=http://webapp:5000 \
-e REMOTE_WEBDRIVERS=http://firefox:4444/wd/hub?browser=firefox \
-e DOCS_DIR=/code/docs/ \
-e SPHINXBUILD=/code/test-env/bin/sphinx-build \
--rm \
test
test-unit
- run:
name: Run phantomjs tests
command: |
docker-compose \
run \
-e ARSENIC_SERVICE=PhantomJS \
-e ARSENIC_BROWSER=PhantomJS \
--rm \
test-phantomjs
- run:
name: Run geckodriver tests
command: |
docker-compose \
run \
-e ARSENIC_SERVICE=Geckodriver \
-e ARSENIC_BROWSER=Firefox \
--rm \
test-geckodriver
- run:
name: Run browserstack-ie tests
command: |
docker-compose \
run \
-e ARSENIC_SERVICE="Remote?url=http://${BROWSERSTACK_USERNAME}:${BROWSERSTACK_API_KEY}@hub.browserstack.com:80/wd/hub" \
-e ARSENIC_BROWSER="InternetExplorer?version=11.0&resolution=1024x768&os_version=7&browser_version=11.0&browserstack.local=&browserstack.localIdentifier=${CIRCLE_SHA1}&os=Windows&browser=IE&project=arsenic&build=${CIRCLE_SHA1}-${CIRCLE_BUILD_NUM}-IE" \
-e BROWSERSTACK_LOCAL_IDENTIFIER="${CIRCLE_SHA1}" \
-e BROWSERSTACK_API_KEY="${BROWSERSTACK_API_KEY}" \
--rm \
test-browserstack
setup:
<<: *defaults
steps:
- setup_remote_docker:
reusable: true
exclusive: true
- checkout
- run: docker-compose pull
- run: docker-compose build
unit:
<<: *defaults
steps:
- setup_remote_docker:
reusable: true
exclusive: true
- checkout
- run:
name: Run unit tests
command: |
docker-compose \
run \
-e DOCS_DIR=/code/docs/ \
-e SPHINXBUILD=/code/test-env/bin/sphinx-build \
--rm \
test-unit
phantomjs:
<<: *defaults
steps:
- setup_remote_docker:
reusable: true
exclusive: true
- checkout
- run:
name: Run phantomjs tests
command: |
docker-compose \
run \
-e ARSENIC_SERVICE=PhantomJS \
-e ARSENIC_BROWSER=PhantomJS \
--rm \
test-phantomjs
geckodriver:
<<: *defaults
steps:
- setup_remote_docker:
reusable: true
exclusive: true
- checkout
- run:
name: Run geckodriver tests
command: |
docker-compose \
run \
-e ARSENIC_SERVICE=Geckodriver \
-e ARSENIC_BROWSER=Firefox \
--rm \
test-geckodriver
browserstack-ie:
<<: *defaults
steps:
- setup_remote_docker:
reusable: true
exclusive: true
- checkout
- run:
name: Run browserstack-ie tests
command: |
docker-compose \
run \
-e ARSENIC_SERVICE="Remote?url=http://${BROWSERSTACK_USERNAME}:${BROWSERSTACK_API_KEY}@hub.browserstack.com:80/wd/hub" \
-e ARSENIC_BROWSER="InternetExplorer?version=11.0&resolution=1024x768&os_version=7&browser_version=11.0&browserstack.local=&browserstack.localIdentifier=${CIRCLE_SHA1}&os=Windows&browser=IE&project=arsenic&build=${CIRCLE_SHA1}-${CIRCLE_BUILD_NUM}-IE" \
-e BROWSERSTACK_LOCAL_IDENTIFIER="${CIRCLE_SHA1}" \
-e BROWSERSTACK_API_KEY="${BROWSERSTACK_API_KEY}" \
--rm \
test-browserstack
workflows:
version: 2
build-and-deploy:
jobs:
- setup
- unit:
requires:
- setup
- phantomjs:
requires:
- setup
- geckodriver:
requires:
- setup
- browserstack-ie:
requires:
- setup
150 changes: 150 additions & 0 deletions .circleci/gencfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/usr/bin/env python3


def define_steps():
yield step(
'unit',
DOCS_DIR='/code/docs/',
SPHINXBUILD='/code/test-env/bin/sphinx-build',
)
yield step(
'phantomjs',
ARSENIC_SERVICE='PhantomJS',
ARSENIC_BROWSER='PhantomJS',
)
yield step(
'geckodriver',
ARSENIC_SERVICE='Geckodriver',
ARSENIC_BROWSER='Firefox',
)
yield step(
'browserstack-ie',
service='test-browserstack',
ARSENIC_SERVICE='"Remote?url=http://${BROWSERSTACK_USERNAME}:${BROWSERSTACK_API_KEY}@hub.browserstack.com:80/wd/hub"',
ARSENIC_BROWSER=browser(
'InternetExplorer',
version='11.0',
resolution='1024x768',
os_version='7',
browser_version='11.0',
browserstack={
'local': True,
'localIdentifier': '${CIRCLE_SHA1}',
},
os='Windows',
browser='IE',
project='arsenic',
build='${CIRCLE_SHA1}-${CIRCLE_BUILD_NUM}-IE',

),
BROWSERSTACK_LOCAL_IDENTIFIER='"${CIRCLE_SHA1}"',
BROWSERSTACK_API_KEY='"${BROWSERSTACK_API_KEY}"',
)


# HERE BE DRAGONS
from urllib.parse import urlencode


def browser(name, **options):
if options:
params = {}
for key, value in options.items():
for query_key, query_value in _encode_browser_param(key, value):
params[query_key] = query_value
qs = urlencode(params, safe='{}$')
return f'"{name}?{qs}"'
else:
return name


def _encode_browser_param(key, value):
if value is True:
yield key, ''
elif isinstance(value, dict):
for sub_key, sub_value in value.items():
yield from _encode_browser_param(f'{key}.{sub_key}', sub_value)
else:
yield key, value


def step(name, *, service=None, **env):
return (
name,
'\n'.join(_build_command(name, service, env))
)


def _build_command(name, service, env):
# use f-strings everywhere for nice indent
service = service or f'test-{name}'
yield f' - run:'
yield f' name: Run {name} tests'
yield f' command: |'
yield f' docker-compose \\'
yield f' run \\'
yield from _build_env(env)
yield f' --rm \\'
yield f' {service}'


def _build_env(env):
for key, value in env.items():
yield f' -e {key}={value} \\'


STEPS = list(define_steps())

PREAMBLE = '''version: 2
defaults: &defaults
working_directory: /home/
docker:
- image: docker/compose:1.9.0
jobs:
build:
<<: *defaults
steps:
- setup_remote_docker:
reusable: true
exclusive: true
- checkout
- run: docker-compose pull
- run: docker-compose build'''

SETUP = ''' - run: docker-compose pull
- run: docker-compose build'''

COMMON_SETUP = ''' <<: *defaults
steps:
- setup_remote_docker:
reusable: true
exclusive: true
- checkout'''

WORKFLOWS_PREAMBLE = '''workflows:
version: 2
build-and-deploy:
jobs:
- setup'''


def generate():
print(PREAMBLE)
for _, step in STEPS:
print(step)
print(' setup:')
print(COMMON_SETUP)
print(' - run: docker-compose pull')
print(' - run: docker-compose build')
for name, step in STEPS:
print(f' {name}:')
print(COMMON_SETUP)
print(step)
print(WORKFLOWS_PREAMBLE)
for name, step in STEPS:
print(f' - {name}:')
print(' requires:')
print(' - setup')

if __name__ == '__main__':
generate()
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*/__pycache__/*
/env/*
/build/*
/dist/*
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Async Webdriver

[![CircleCI](https://circleci.com/gh/HDE/arsenic/tree/master.svg?style=svg)](https://circleci.com/gh/HDE/arsenic/tree/master) [![Documentation Status](https://readthedocs.org/projects/arsenic/badge/?version=latest)](http://arsenic.readthedocs.io/en/latest/?badge=latest)
[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=MjJhTXF4TmFlMFc4b1NpMzVBODNpVXNXeE9yWHlqZFNVR1o4N0l5QVhmMD0tLU15R1VoYU1VbGJrM0FxZTFHSjhaWGc9PQ==--836b0ffba754cc76cb9671875a9bd7be134acb98)](https://www.browserstack.com/automate/public-build/MjJhTXF4TmFlMFc4b1NpMzVBODNpVXNXeE9yWHlqZFNVR1o4N0l5QVhmMD0tLU15R1VoYU1VbGJrM0FxZTFHSjhaWGc9PQ==--836b0ffba754cc76cb9671875a9bd7be134acb98)


Asynchronous webdriver client built on asyncio.
Expand Down Expand Up @@ -30,3 +31,9 @@ async def example():
```

For more information, check [the documentation](https://arsenic.readthedocs.io/)

## CI Supported by Browserstack

Continuous integration for certain browsers is generously provided by [Browserstack](http://browserstack.com).

[![Browserstack](./.circleci/browserstack-logo.png)](http://browserstack.com/)
29 changes: 16 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
version: '2'
services:
webapp:
build: tests/app
firefox:
image: selenium/standalone-firefox:latest
depends_on:
- "webapp"
test:
build:
context: .
dockerfile: tests/Dockerfile
depends_on:
- "webapp"
- "firefox"
test-unit:
build:
context: .
dockerfile: tests/dockerfiles/unit
test-phantomjs:
build:
context: .
dockerfile: tests/dockerfiles/phantomjs
test-geckodriver:
build:
context: .
dockerfile: tests/dockerfiles/geckodriver
test-browserstack:
build:
context: .
dockerfile: tests/dockerfiles/browserstack
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Welcome to arsenic's documentation!
:maxdepth: 2
:caption: Reference

reference/supported-browsers
reference/index


Expand Down
21 changes: 21 additions & 0 deletions docs/reference/supported-browsers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Supported Browsers
##################

.. note::

A Browser is considered supported if it is tested in continuous integration.
Other browsers and browser versions might also work, but are not tested.


.. list-table:: Browsers
:header-rows: 1

* - Browser Name
- Supported Versions
- Supported Service
* - Firefox
- 54.0
- Geckodriver 0.16.1
* - PhantomJS
- 1.9.8
- PhantomJS 1.9.8
2 changes: 2 additions & 0 deletions src/arsenic/browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ class InternetExplorer(Browser):
'version': '',
'platform': 'WINDOWS',
}

IE = InternetExplorer

0 comments on commit 26da655

Please sign in to comment.