diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c18eabd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM ubuntu:xenial + +ENV DEBIAN_FRONTEND=noninteractive \ + MOZ_HEADLESS=1 \ + PIP_DISABLE_PIP_VERSION_CHECK=1 + +RUN apt-get update \ + && apt-get install -y software-properties-common \ + && add-apt-repository ppa:deadsnakes/ppa \ + && apt-get update \ + && apt-get install -y bzip2 curl firefox git python2.7 python3.6 python3-pip \ + && rm -rf /var/lib/apt/lists/* + +ENV FIREFOX_VERSION=59.0 + +RUN curl -fsSLo /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2 \ + && apt-get -y purge firefox \ + && rm -rf /opt/firefox \ + && tar -C /opt -xjf /tmp/firefox.tar.bz2 \ + && rm /tmp/firefox.tar.bz2 \ + && mv /opt/firefox /opt/firefox-$FIREFOX_VERSION \ + && ln -fs /opt/firefox-$FIREFOX_VERSION/firefox /usr/bin/firefox + +ENV GECKODRIVER_VERSION=0.20.0 +RUN curl -fsSLo /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v$GECKODRIVER_VERSION/geckodriver-v$GECKODRIVER_VERSION-linux64.tar.gz \ + && rm -rf /opt/geckodriver \ + && tar -C /opt -zxf /tmp/geckodriver.tar.gz \ + && rm /tmp/geckodriver.tar.gz \ + && mv /opt/geckodriver /opt/geckodriver-$GECKODRIVER_VERSION \ + && chmod 755 /opt/geckodriver-$GECKODRIVER_VERSION \ + && ln -fs /opt/geckodriver-$GECKODRIVER_VERSION /usr/bin/geckodriver + +ENV TOX_VERSION=2.9.1 +RUN pip3 install tox==$TOX_VERSION + +ADD . /src +WORKDIR /src diff --git a/Jenkinsfile b/Jenkinsfile index 0460512..4b317d9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,37 +9,51 @@ def capabilities = [ pipeline { agent any + libraries { + lib('fxtest@1.9') + } + options { + ansiColor('xterm') + timestamps() + timeout(time: 30, unit: 'MINUTES') + } + environment { + PYTEST_ADDOPTS = + "--tb=short " + + "--color=yes " + + "--driver=SauceLabs " + + "--variables=capabilities.json" + PULSE = credentials('PULSE') + SAUCELABS = credentials('SAUCELABS') + } stages { - stage('Checkout') { - steps { - deleteDir() - checkout scm - stash 'workspace' - } - } stage('Lint') { + agent { + dockerfile true + } steps { - deleteDir() - unstash 'workspace' - ansiColor('xterm') { - sh "tox -e flake8" - } + sh "tox -e flake8" } } stage('Test') { - environment { - SAUCELABS = credentials('SAUCELABS') - } - steps { - unstash 'workspace' - ansiColor('xterm') { - sh "tox" + parallel { + stage('py36') { + agent { + dockerfile true + } + steps { + writeCapabilities(capabilities, 'capabilities.json') + sh "tox -e py36" + } } - } - post { - always { - stash includes: 'results/*', name: 'results' - archiveArtifacts 'results/*' + stage('py27') { + agent { + dockerfile true + } + steps { + writeCapabilities(capabilities, 'capabilities.json') + sh "tox -e py27" + } } } } diff --git a/axe_selenium_python/axe.py b/axe_selenium_python/axe.py index 7db6130..d76f4cb 100644 --- a/axe_selenium_python/axe.py +++ b/axe_selenium_python/axe.py @@ -40,7 +40,7 @@ def execute(self, context=None, options=None): """ Run axe against the current page. - :param context: which part of the page to analyze and/or what to exclude. + :param context: which page part(s) to analyze and/or what to exclude. :param options: dictionary of aXe options. """ template = 'return axe.run(%s).then(function(result){return result;});' diff --git a/axe_selenium_python/tests/conftest.py b/axe_selenium_python/tests/conftest.py index 99f345d..567c454 100644 --- a/axe_selenium_python/tests/conftest.py +++ b/axe_selenium_python/tests/conftest.py @@ -42,7 +42,7 @@ def pytest_html_results_table_row(report, cells): @pytest.mark.hookwrapper def pytest_runtest_makereport(item, call): - """Make HTML report. Use test function docstrings as description in report.""" + """Make HTML report using test-function docstrings as description.""" outcome = yield report = outcome.get_result() # add docstring to 'description' column diff --git a/tox.ini b/tox.ini index 511db66..d4cd4eb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,15 @@ [tox] -envlist = py27, py3, flake8 +envlist = py27, py36, flake8 skipsdist = true [testenv] +passenv = HOME DISPLAY MOZ_HEADLESS PYTEST_ADDOPTS PYTEST_BASE_URL \ + SAUCELABS_USR SAUCELABS_PSW JENKINS_URL JOB_NAME BUILD_NUMBER deps = -raxe_selenium_python/tests/requirements/tests.txt commands = pytest \ --verbose \ --driver=SauceLabs \ - --base-url=https://mozillians.org \ - --capability browserName Firefox + --base-url=https://web-mozillians-staging.production.paas.mozilla.community [testenv:flake8] deps = -raxe_selenium_python/tests/requirements/flake8.txt