Use a docker image to run the tests (#162)
* Use a docker image to run the tests * Run against both Python 2 and 3 on Jenkins in parallel * Use Docker in Travis CI * Use Alpine linux for smaller Docker images
This commit is contained in:
Родитель
718490401a
Коммит
971841dc94
|
@ -0,0 +1,8 @@
|
||||||
|
.cache
|
||||||
|
.tox
|
||||||
|
**/__pycache__
|
||||||
|
**/*.pyc
|
||||||
|
build
|
||||||
|
dist
|
||||||
|
fxapom.egg-info
|
||||||
|
results
|
|
@ -1,9 +1,10 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
.cache
|
.cache
|
||||||
|
.eggs
|
||||||
|
.idea/
|
||||||
.tox
|
.tox
|
||||||
|
*.pyc
|
||||||
build
|
build
|
||||||
dist
|
dist
|
||||||
.idea/
|
|
||||||
*.pyc
|
|
||||||
fxapom.egg-info
|
fxapom.egg-info
|
||||||
results/
|
results/
|
||||||
|
|
65
.travis.yml
65
.travis.yml
|
@ -1,47 +1,32 @@
|
||||||
|
sudo: required
|
||||||
language: python
|
language: python
|
||||||
python:
|
services:
|
||||||
- 2.7
|
- docker
|
||||||
- 3.6
|
jobs:
|
||||||
addons:
|
|
||||||
firefox: latest
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- DISPLAY=:99.0
|
|
||||||
matrix:
|
|
||||||
include:
|
include:
|
||||||
- python: 2.7
|
- stage:
|
||||||
env: TOXENV=flake8
|
env: TOXENV=flake8
|
||||||
- python: 2.7
|
- stage:
|
||||||
env: TOXENV=py27
|
env: TOXENV=py27
|
||||||
- python: 3.6
|
- stage:
|
||||||
env: TOXENV=flake8
|
|
||||||
- python: 3.6
|
|
||||||
env: TOXENV=py36
|
env: TOXENV=py36
|
||||||
exclude:
|
- stage: deploy
|
||||||
- python: 2.7
|
python: 3.6
|
||||||
- python: 3.6
|
before_install: skip
|
||||||
before_install:
|
script: skip
|
||||||
- wget -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz
|
deploy:
|
||||||
- gunzip -c geckodriver.tar.gz | tar xopf -
|
provider: pypi
|
||||||
- chmod +x geckodriver && sudo mv geckodriver /usr/local/bin
|
user: davehunt
|
||||||
- firefox --version
|
password:
|
||||||
- geckodriver --version
|
secure: GyTB/x+/F1DNmAWF4K8keaBgwUTq6AVgCfdMzArPSLiHxs4Fi98Y44U6YM4fy5qwZ8oJxYYwdlWoooStIYouV8PEg0GOl+x1m7eb02XXZEufVUqQ4p5sN3HHeUmj2Et0j0o0AkUvAZjY2zCS3hI9U8wH+rLrkyR/1g8a88HLeHo=
|
||||||
install:
|
distributions: sdist bdist_wheel
|
||||||
- pip install tox
|
on:
|
||||||
before_script:
|
tags: true
|
||||||
- sh -e /etc/init.d/xvfb start
|
repo: mozilla/fxapom
|
||||||
script:
|
cache:
|
||||||
- tox
|
pip: true
|
||||||
|
before_install: docker build -t mozilla/fxapom .
|
||||||
|
install: skip
|
||||||
|
script: docker run -e TOXENV=$TOXENV mozilla/fxapom tox
|
||||||
notifications:
|
notifications:
|
||||||
email: fte-ci@mozilla.com
|
email: fte-ci@mozilla.com
|
||||||
deploy:
|
|
||||||
provider: pypi
|
|
||||||
user: davehunt
|
|
||||||
password:
|
|
||||||
secure: GyTB/x+/F1DNmAWF4K8keaBgwUTq6AVgCfdMzArPSLiHxs4Fi98Y44U6YM4fy5qwZ8oJxYYwdlWoooStIYouV8PEg0GOl+x1m7eb02XXZEufVUqQ4p5sN3HHeUmj2Et0j0o0AkUvAZjY2zCS3hI9U8wH+rLrkyR/1g8a88HLeHo=
|
|
||||||
distributions: sdist bdist_wheel
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: mozilla/fxapom
|
|
||||||
python: 2.7
|
|
||||||
condition: "$TOXENV = py27"
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
ENV MOZ_HEADLESS=1
|
||||||
|
|
||||||
|
RUN mkdir /opt
|
||||||
|
RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
|
||||||
|
RUN apk --no-cache add \
|
||||||
|
curl \
|
||||||
|
firefox@testing \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
libffi-dev \
|
||||||
|
musl-dev \
|
||||||
|
openssl-dev \
|
||||||
|
py3-pip \
|
||||||
|
python2-dev \
|
||||||
|
python3-dev
|
||||||
|
|
||||||
|
ENV GECKODRIVER_VERSION=0.19.1
|
||||||
|
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
|
|
@ -22,52 +22,81 @@ pipeline {
|
||||||
"--tb=short " +
|
"--tb=short " +
|
||||||
"--color=yes " +
|
"--color=yes " +
|
||||||
"--driver=SauceLabs " +
|
"--driver=SauceLabs " +
|
||||||
"--variables=capabilities.json " +
|
"--variables=capabilities.json"
|
||||||
"--log-raw=results/py27_raw.txt " +
|
|
||||||
"--log-tbpl=results/py27_tbpl.txt"
|
|
||||||
PULSE = credentials('PULSE')
|
PULSE = credentials('PULSE')
|
||||||
SAUCELABS = credentials('SAUCELABS')
|
SAUCELABS = credentials('SAUCELABS')
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Lint') {
|
stage('Lint') {
|
||||||
|
agent {
|
||||||
|
dockerfile true
|
||||||
|
}
|
||||||
steps {
|
steps {
|
||||||
sh "tox -e flake8"
|
sh "tox -e flake8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Test') {
|
stage('Test') {
|
||||||
steps {
|
parallel {
|
||||||
writeCapabilities(capabilities, 'capabilities.json')
|
stage('py36') {
|
||||||
sh "tox -e py27"
|
agent {
|
||||||
}
|
dockerfile true
|
||||||
post {
|
}
|
||||||
always {
|
steps {
|
||||||
archiveArtifacts 'results/*'
|
writeCapabilities(capabilities, 'capabilities.json')
|
||||||
junit 'results/*.xml'
|
sh "tox -e py36"
|
||||||
submitToActiveData('results/py27_raw.txt')
|
}
|
||||||
submitToTreeherder('fxapom', 'T', 'Tests', 'results/*', 'results/py27_tbpl.txt')
|
post {
|
||||||
publishHTML(target: [
|
always {
|
||||||
allowMissing: false,
|
stash includes: 'results/py36.html', name: 'py36'
|
||||||
alwaysLinkToLastBuild: true,
|
archiveArtifacts 'results/*'
|
||||||
keepAll: true,
|
junit 'results/*.xml'
|
||||||
reportDir: 'results',
|
}
|
||||||
reportFiles: "py27.html",
|
}
|
||||||
reportName: 'HTML Report'])
|
}
|
||||||
|
stage('py27') {
|
||||||
|
agent {
|
||||||
|
dockerfile true
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
writeCapabilities(capabilities, 'capabilities.json')
|
||||||
|
sh "tox -e py27"
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
stash includes: 'results/py27.html', name: 'py27'
|
||||||
|
archiveArtifacts 'results/*'
|
||||||
|
junit 'results/*.xml'
|
||||||
|
submitToActiveData('results/py27_raw.txt')
|
||||||
|
submitToTreeherder('fxapom', 'T', 'Tests', 'results/*', 'results/py27_tbpl.txt')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
always {
|
||||||
|
unstash 'py36'
|
||||||
|
unstash 'py27'
|
||||||
|
publishHTML(target: [
|
||||||
|
allowMissing: false,
|
||||||
|
alwaysLinkToLastBuild: true,
|
||||||
|
keepAll: true,
|
||||||
|
reportDir: 'results',
|
||||||
|
reportFiles: "py36.html, py27.html",
|
||||||
|
reportName: 'HTML Report'])
|
||||||
|
}
|
||||||
|
changed {
|
||||||
|
ircNotification()
|
||||||
|
}
|
||||||
failure {
|
failure {
|
||||||
emailext(
|
emailext(
|
||||||
attachLog: true,
|
attachLog: true,
|
||||||
attachmentsPattern: 'results/py27.html',
|
attachmentsPattern: 'results/*.html',
|
||||||
body: '$BUILD_URL\n\n$FAILED_TESTS',
|
body: '$BUILD_URL\n\n$FAILED_TESTS',
|
||||||
replyTo: '$DEFAULT_REPLYTO',
|
replyTo: '$DEFAULT_REPLYTO',
|
||||||
subject: '$DEFAULT_SUBJECT',
|
subject: '$DEFAULT_SUBJECT',
|
||||||
to: '$DEFAULT_RECIPIENTS')
|
to: '$DEFAULT_RECIPIENTS')
|
||||||
}
|
}
|
||||||
changed {
|
|
||||||
ircNotification()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
11
README.rst
11
README.rst
|
@ -96,8 +96,15 @@ Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Fork the repository and submit PRs with bug fixes and enhancements,
|
Fork the repository and submit PRs with bug fixes and enhancements,
|
||||||
contributions are very welcome. Tests can be run locally with
|
contributions are very welcome. You can run the tests using
|
||||||
`tox <http://tox.readthedocs.io/en/latest/>`_.
|
`Docker <https://www.docker.com/>`_:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ docker build -t fxapom .
|
||||||
|
$ docker run -it fxapom tox
|
||||||
|
|
||||||
|
Using
|
||||||
|
|
||||||
Resources
|
Resources
|
||||||
---------
|
---------
|
||||||
|
|
13
tox.ini
13
tox.ini
|
@ -2,9 +2,8 @@
|
||||||
envlist = py{27,36}, flake8
|
envlist = py{27,36}, flake8
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
passenv = BUILD_NUMBER DISPLAY GIT_BRANCH GIT_COMMIT GIT_URL JENKINS_URL \
|
passenv = HOME DISPLAY MOZ_HEADLESS PYTEST_ADDOPTS PYTEST_BASE_URL \
|
||||||
JOB_NAME PYTEST_ADDOPTS PYTEST_BASE_URL SAUCELABS_USR \
|
SAUCELABS_USR SAUCELABS_PSW JENKINS_URL JOB_NAME BUILD_NUMBER
|
||||||
SAUCELABS_PSW
|
|
||||||
deps = -rrequirements/{envname}-tests.txt
|
deps = -rrequirements/{envname}-tests.txt
|
||||||
commands = pytest \
|
commands = pytest \
|
||||||
--junit-xml=results/{envname}.xml \
|
--junit-xml=results/{envname}.xml \
|
||||||
|
@ -16,6 +15,14 @@ skip_install = true
|
||||||
deps = -rrequirements/flake8.txt
|
deps = -rrequirements/flake8.txt
|
||||||
commands = flake8 {posargs:.}
|
commands = flake8 {posargs:.}
|
||||||
|
|
||||||
|
[testenv:py27]
|
||||||
|
commands = pytest \
|
||||||
|
--junit-xml=results/{envname}.xml \
|
||||||
|
--html=results/{envname}.html --self-contained-html \
|
||||||
|
--log-raw=results/{envname}_raw.txt \
|
||||||
|
--log-tbpl=results/{envname}_tbpl.txt \
|
||||||
|
{posargs:tests}
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E501
|
ignore = E501
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче