-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from HDE/browserstack
Add tests via browserstack
- Loading branch information
Showing
41 changed files
with
13,526 additions
and
140 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*/__pycache__/* | ||
/env/* | ||
/build/* | ||
/dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,5 @@ class InternetExplorer(Browser): | |
'version': '', | ||
'platform': 'WINDOWS', | ||
} | ||
|
||
IE = InternetExplorer |
Oops, something went wrong.