Skip to content

Backport version tests to 7.x #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
84069ca
Remove `LABEL version` from Dockerfile and CONTRIBUTING guide
humitos Feb 19, 2020
56766f4
Downgrade conda
stsewd Feb 27, 2020
3af8caf
Pin Python core dependencies (virtualenv, pip, setuptools)
humitos Feb 28, 2020
a1a1c78
Merge pull request #122 from readthedocs/port-to-master
humitos Mar 3, 2020
c6d09a6
Merge branch 'master' of github.com:rtfd/readthedocs-docker-images in…
humitos Mar 3, 2020
87a7fa6
Pin system virtualenv version as well
humitos Mar 3, 2020
7ac4308
Remove test for miniconda sha
humitos Mar 3, 2020
41acc2f
Use different name for PIP_VERSION env var
humitos Mar 3, 2020
3c95d16
Merge pull request #125 from readthedocs/humitos/remove-test-miniconda
humitos Mar 3, 2020
0da9ff3
Pin Python2.7 packages manually
humitos Mar 3, 2020
0b62a43
Merge pull request #124 from readthedocs/humitos/pin-python-dependencies
humitos Mar 3, 2020
ba0360a
Move LABEL and ENV to bottom
humitos Mar 4, 2020
c0c81dd
Move conda installation closest to the bottom
humitos Mar 4, 2020
8df342f
Suppress no test ran exit code when running 0 tests
humitos Mar 4, 2020
ff38190
Prefix all of our variables with `RTD_` to avoid issues
humitos Mar 11, 2020
3dbd984
Suppress no test ran exit code when running 0 tests
humitos Mar 4, 2020
c9b08e1
Merge pull request #128 from readthedocs/humitos/prefix-our-variables
humitos Mar 11, 2020
1957993
Merge pull request #129 from readthedocs/humitos/ignore-exit-pytest
humitos Mar 11, 2020
a4d4eaf
Merge pull request #118 from readthedocs/humitos/remove-label
humitos Apr 30, 2020
58a2a61
Merge branch 'master' of github.com:rtfd/readthedocs-docker-images in…
humitos Apr 30, 2020
087cd75
Merge conflict fixed
humitos Apr 30, 2020
064ba8d
Merge pull request #126 from readthedocs/humitos/move-env-labels-to-b…
humitos Apr 30, 2020
d384102
Updating CONTRIBUTING.rst template managing
fbaldassarri May 5, 2020
f8db06c
Merge pull request #133 from fbaldassarri/patch-1
stsewd May 5, 2020
27cd33b
Added Rust to the build image
alex Aug 17, 2020
bec7fc3
Pin to latest rust stable
alex Aug 31, 2020
e07d337
Apply suggestions from code review
alex Sep 1, 2020
e122b49
Merge pull request #136 from alex/install-rust
ericholscher Sep 1, 2020
ce9bfde
Upgrade Ubuntu to 20.04 LTS
humitos Aug 27, 2020
3ea74e0
Add early support for Python 3.9.0rc1
humitos Aug 27, 2020
5d0847b
Update readme mentioning 8.0
humitos Aug 27, 2020
295ef2d
Do not install python-pip
humitos Aug 27, 2020
e1d071b
Revert "Do not install python-pip"
humitos Aug 31, 2020
7758def
Install python3-pip
humitos Aug 31, 2020
f4ec9d2
Do not install Python dependencies on Py 3.9
humitos Aug 31, 2020
c855249
Install virtualenv in Python 3.9rc1
humitos Sep 1, 2020
7239b0f
Update Dockerfile
humitos Sep 24, 2020
6e61b2a
Merge pull request #137 from readthedocs/humitos/new-version-8.0
humitos Sep 24, 2020
66447b5
Upgrade all Python patch versions
humitos Sep 28, 2020
5cf525e
Merge pull request #139 from readthedocs/humitos/upgrade-python-patch…
humitos Sep 28, 2020
68c7bc3
Update Python 3.9 to 3.9.0 that it's released now
humitos Oct 13, 2020
eb14558
Merge pull request #141 from readthedocs/humitos/py39-update
humitos Oct 13, 2020
859ffb5
Follow redirects when downloading Miniconda
humitos Oct 14, 2020
89bb0b6
Merge pull request #144 from readthedocs/humitos/follow-redirect-cond…
humitos Oct 15, 2020
bc02c15
Run some version tests after building the image
humitos Oct 14, 2020
1f27462
Install docker for tests
humitos Oct 14, 2020
5717135
Update Python version to match latest ones
humitos Oct 14, 2020
d00ba8f
Check setuptools version on all Python versions
humitos Oct 14, 2020
f2f3a87
Refactor to isolate 'run_commnd_in_container' and re-use it
humitos Oct 15, 2020
7bbd96f
Test more docker images (5.0, 6.0 and 7.0)
humitos Oct 15, 2020
0825a17
Add test for cargo/rust version on 7.0
humitos Oct 15, 2020
8d07107
Add tests for readthedocs/build:master tag
humitos Oct 15, 2020
fbedc03
Run tests in all the branches we care
humitos Oct 15, 2020
682c9df
Add check for git --version
humitos Oct 15, 2020
b7c3aaa
Make this directory a package
humitos Oct 15, 2020
fe49abd
Use `readthedocs/build:master` as image name
humitos Oct 15, 2020
d10d544
Use --cache-from for `docker build`
humitos Oct 15, 2020
c1eebe3
Pull the image before to use is as cache
humitos Oct 15, 2020
e3204e8
Fix virtualenv versions on master
humitos Oct 15, 2020
cf1a119
Fix pip version for python2 on master
humitos Oct 15, 2020
d5f2d62
Py2 pip version, again :(
humitos Oct 15, 2020
3db2351
More versions fixes
humitos Oct 15, 2020
1b8d99b
Merge remote-tracking branch 'origin/humitos/test-command-versions' i…
humitos Oct 19, 2020
bed5b5c
Run test for `image_70` on this branch
humitos Oct 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ env:
- PIPENV_IGNORE_VIRTUALENVS=1
before_install:
- pip install pipenv
- docker pull readthedocs/build:7.0 || true
install:
- pipenv install
script:
- pipenv run pytest
- docker build .
- docker build --cache-from readthedocs/build:7.0 -t readthedocs/build:7.0 .
- pipenv run pytest -m image_70

branches:
only:
- master
- releases/5.x
- releases/6.x
- releases/7.x
- releases/8.x
15 changes: 6 additions & 9 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Python/Sphinx/etc operations to see if your changes have worked. For example::

cd ~docs
git clone https://github.com/readthedocs/template
cd template
cd template/docs
make html

Releases
Expand All @@ -46,20 +46,17 @@ are defined in the :doc:`README`.

We follow `semantic versioning`_, but drop the bug fix level version number for
our images, as this level of granularity is not important for any application of
these images. Each release is tagged in Git, and the release version number is
included in the Dockerfile version label (``LABEL version="2.0"``).
these images.

Releases should be merged into one of the ``releases/`` branches, for instance
``releases/2.x``. The version label in the Dockerfile should be updated to the
next version in the series, following semver rules. This commit should then also
be tagged using the new version number.
``releases/2.x``. This commit should then also be tagged using the new version number.

If the version number in the Dockerfile was ``2.0.1`` before, and you implement
If the version number was ``2.0.1`` before, and you implement
a bug fix to the image, the new image will be ``2.0.2``. The output image from
Docker Hub will still be ``2.0`` however. If a new feature is introduced, the
new version tagged and in the Dockerfile will be ``2.1``.
new version tagged will be ``2.1``.

We don't care about bug fix version numbers here, as RTD will only ever have one
We don't care about bug fix version numbers here, as Read the Docs will only ever have one
main ``2.x`` image at a time. There is no need for us to run multiple bug fix
versions at the same time.

Expand Down
4 changes: 3 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ name = "pypi"

"dockerfile-parse" = "*"
requests = "*"
pytest = "*"
pytest = "*"
pytest-custom-exit-code = "*"
docker = "*"
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ repository:
**Deprecated**
Ubuntu 18.04 supporting Python 2.7, 3.5, 3.6, 3.7.

`readthedocs/build:5.0`
`readthedocs/build:6.0`
``stable``
Ubuntu 18.04 supporting Python 2.7, 3.6, 3.7 and pypy3.5-7.0.0.
Ubuntu 18.04 supporting Python 2.7, 3.5, 3.6, 3.7, 3.8 and PyPy3.5-7.0.0.
This is the **stable** image supported by Read the Docs.

`readthedocs/build:6.0`
`readthedocs/build:7.0`
``latest``
Ubuntu 18.04 supporting Python 2.7, 3.5, 3.6, 3.7, 3.8 and PyPy3.5-7.0.0.
This is the **latest** default image used for documentation builds and supported by Read the Docs.

`readthedocs/build:7.0`
`readthedocs/build:8.0`
``testing``
Ubuntu 18.04 supporting Python 2.7, 3.5, 3.6, 3.7, 3.8 and PyPy3.5-7.0.0.
Ubuntu 20.04 supporting Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9.0rc1 and PyPy3.5-7.0.0.
For internal development **testing** only, not available for public usage yet.

.. _readthedocs/build: https://hub.docker.com/r/readthedocs/build/
Expand Down
28 changes: 0 additions & 28 deletions tests/test_dependencies.py

This file was deleted.

162 changes: 162 additions & 0 deletions tests/test_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import pytest
from docker import APIClient

from .utils import run_command_in_container


@pytest.mark.image_master
@pytest.mark.parametrize(
'command,expected_output',
[
# python
('python2 --version', 'Python 2.7.18'),
('python3.5 --version', 'Python 3.5.10'),
('python3.6 --version', 'Python 3.6.12'),
('python3.7 --version', 'Python 3.7.9'),
('python3.8 --version', 'Python 3.8.6'),
('pypy3.5 --version', 'Python 3.5.3 (928a4f70d3de7d17449456946154c5da6e600162, Feb 09 2019, 11:50:43)\n[PyPy 7.0.0 with GCC 8.2.0]'),
# pip
('python2 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/2.7.18/lib/python2.7/site-packages/pip (python 2.7)"),
('python3.5 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.5.10/lib/python3.5/site-packages/pip (python 3.5)"),
('python3.6 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip (python 3.6)"),
('python3.7 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.7.9/lib/python3.7/site-packages/pip (python 3.7)"),
('python3.8 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.8.6/lib/python3.8/site-packages/pip (python 3.8)"),
# setuptools
('python2 -c "import setuptools; print(setuptools.__version__)"', "44.0.0"),
('python3.5 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
('python3.6 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
('python3.7 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
('python3.8 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
# virtualenv
('python2 -m virtualenv --version', '16.7.9'),
('python3.5 -m virtualenv --version', '16.7.9'),
('python3.6 -m virtualenv --version', '16.7.9'),
('python3.7 -m virtualenv --version', '16.7.9'),
('python3.8 -m virtualenv --version', '16.7.9'),
# others
('node --version', 'v10.19.0'),
('npm --version', '6.14.4'),
('conda --version', 'conda 4.6.14'),
('cargo --version', 'cargo 1.46.0 (149022b1d 2020-07-17)'),
('git --version', 'git version 2.25.1'),
]
)
def test_command_versions_image_master(command, expected_output):
cmd_output = run_command_in_container('readthedocs/build:master', command)
assert cmd_output == expected_output


@pytest.mark.image_70
@pytest.mark.parametrize(
'command,expected_output',
[
# python
('python2 --version', 'Python 2.7.18'),
('python3.5 --version', 'Python 3.5.10'),
('python3.6 --version', 'Python 3.6.12'),
('python3.7 --version', 'Python 3.7.9'),
('python3.8 --version', 'Python 3.8.6'),
('pypy3.5 --version', 'Python 3.5.3 (928a4f70d3de7d17449456946154c5da6e600162, Feb 09 2019, 11:50:43)\n[PyPy 7.0.0 with GCC 8.2.0]'),
# pip
('python2 -m pip --version', "pip 20.0.2 from /home/docs/.pyenv/versions/2.7.18/lib/python2.7/site-packages/pip (python 2.7)"),
('python3.5 -m pip --version', "pip 20.0.2 from /home/docs/.pyenv/versions/3.5.10/lib/python3.5/site-packages/pip (python 3.5)"),
('python3.6 -m pip --version', "pip 20.0.2 from /home/docs/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip (python 3.6)"),
('python3.7 -m pip --version', "pip 20.0.2 from /home/docs/.pyenv/versions/3.7.9/lib/python3.7/site-packages/pip (python 3.7)"),
('python3.8 -m pip --version', "pip 20.0.2 from /home/docs/.pyenv/versions/3.8.6/lib/python3.8/site-packages/pip (python 3.8)"),
# setuptools
('python2 -c "import setuptools; print(setuptools.__version__)"', "44.0.0"),
('python3.5 -c "import setuptools; print(setuptools.__version__)"', "45.2.0"),
('python3.6 -c "import setuptools; print(setuptools.__version__)"', "45.2.0"),
('python3.7 -c "import setuptools; print(setuptools.__version__)"', "45.2.0"),
('python3.8 -c "import setuptools; print(setuptools.__version__)"', "45.2.0"),
# virtualenv
('python2 -m virtualenv --version', 'virtualenv 20.0.7 from /home/docs/.pyenv/versions/2.7.18/lib/python2.7/site-packages/virtualenv/__init__.pyc'),
('python3.5 -m virtualenv --version', 'virtualenv 20.0.7 from /home/docs/.pyenv/versions/3.5.10/lib/python3.5/site-packages/virtualenv/__init__.pyc'),
('python3.6 -m virtualenv --version', 'virtualenv 20.0.7 from /home/docs/.pyenv/versions/3.6.12/lib/python3.6/site-packages/virtualenv/__init__.pyc'),
('python3.7 -m virtualenv --version', 'virtualenv 20.0.7 from /home/docs/.pyenv/versions/3.7.9/lib/python3.7/site-packages/virtualenv/__init__.pyc'),
('python3.8 -m virtualenv --version', 'virtualenv 20.0.7 from /home/docs/.pyenv/versions/3.8.6/lib/python3.8/site-packages/virtualenv/__init__.pyc'),
# others
('node --version', 'v8.10.0'),
('npm --version', '3.5.2'),
('conda --version', 'conda 4.6.14'),
('cargo --version', 'cargo 1.46.0 (149022b1d 2020-07-17)'),
('git --version', 'git version 2.17.1'),
]
)
def test_command_versions_image_70(command, expected_output):
cmd_output = run_command_in_container('readthedocs/build:7.0', command)
assert cmd_output == expected_output


@pytest.mark.image_60
@pytest.mark.parametrize(
'command,expected_output',
[
# python
('python2 --version', 'Python 2.7.18'),
('python3.5 --version', 'Python 3.5.10'),
('python3.6 --version', 'Python 3.6.12'),
('python3.7 --version', 'Python 3.7.9'),
('python3.8 --version', 'Python 3.8.6'),
('pypy3.5 --version', 'Python 3.5.3 (928a4f70d3de7d17449456946154c5da6e600162, Feb 09 2019, 11:50:43)\n[PyPy 7.0.0 with GCC 8.2.0]'),
# pip
('python2 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/2.7.18/lib/python2.7/site-packages/pip (python 2.7)"),
('python3.5 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.5.10/lib/python3.5/site-packages/pip (python 3.5)"),
('python3.6 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip (python 3.6)"),
('python3.7 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.7.9/lib/python3.7/site-packages/pip (python 3.7)"),
('python3.8 -m pip --version', "pip 20.0.1 from /home/docs/.pyenv/versions/3.8.6/lib/python3.8/site-packages/pip (python 3.8)"),
# setuptools
('python2 -c "import setuptools; print(setuptools.__version__)"', "44.0.0"),
('python3.5 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
('python3.6 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
('python3.7 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
('python3.8 -c "import setuptools; print(setuptools.__version__)"', "45.1.0"),
# virtualenv
('python2 -m virtualenv --version', '16.7.9'),
('python3.5 -m virtualenv --version', '16.7.9'),
('python3.6 -m virtualenv --version', '16.7.9'),
('python3.7 -m virtualenv --version', '16.7.9'),
('python3.8 -m virtualenv --version', '16.7.9'),
# others
('node --version', 'v8.10.0'),
('npm --version', '3.5.2'),
('conda --version', 'conda 4.6.14'),
('git --version', 'git version 2.17.1'),
]
)
def test_command_versions_image_60(command, expected_output):
cmd_output = run_command_in_container('readthedocs/build:6.0', command)
assert cmd_output == expected_output


@pytest.mark.image_50
@pytest.mark.parametrize(
'command,expected_output',
[
# python
('python2 --version', 'Python 2.7.18'),
('python3.6 --version', 'Python 3.6.12'),
('python3.7 --version', 'Python 3.7.9'),
('pypy3.5 --version', 'Python 3.5.3 (928a4f70d3de7d17449456946154c5da6e600162, Feb 09 2019, 11:50:43)\n[PyPy 7.0.0 with GCC 8.2.0]'),
# pip
('python2 -m pip --version', "pip 19.1.1 from /home/docs/.pyenv/versions/2.7.18/lib/python2.7/site-packages/pip (python 2.7)"),
('python3.6 -m pip --version', "pip 19.1.1 from /home/docs/.pyenv/versions/3.6.12/lib/python3.6/site-packages/pip (python 3.6)"),
('python3.7 -m pip --version', "pip 19.1.1 from /home/docs/.pyenv/versions/3.7.9/lib/python3.7/site-packages/pip (python 3.7)"),
# setuptools
('python2 -c "import setuptools; print(setuptools.__version__)"', "41.0.1"),
('python3.6 -c "import setuptools; print(setuptools.__version__)"', "41.0.1"),
('python3.7 -c "import setuptools; print(setuptools.__version__)"', "41.0.1"),
# virtualenv
('python2 -m virtualenv --version', '16.6.0'),
('python3.6 -m virtualenv --version', '16.6.0'),
('python3.7 -m virtualenv --version', '16.6.0'),
# others
('node --version', 'v8.10.0'),
('npm --version', '3.5.2'),
('conda --version', 'conda 4.6.14'),
('git --version', 'git version 2.17.1'),
]
)
def test_command_versions_image_50(command, expected_output):
cmd_output = run_command_in_container('readthedocs/build:5.0', command)
assert cmd_output == expected_output
37 changes: 37 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from docker import APIClient


def run_command_in_container(container_image, command):
client = APIClient()

# Create the container
container = client.create_container(
image=container_image,
command=(
'/bin/sh -c "sleep {time}; exit {exit}"'.format(
time=60,
exit=42,
)
),
detach=True,
user='docs',
)

# Start the container
container_id = container.get('Id')
client.start(container=container_id)

# Execute commands to verify versions
exec_cmd = client.exec_create(
container=container_id,
cmd=f"/bin/sh -c '{command}'",
stdout=True,
stderr=True,
)
cmd_output = client.exec_start(exec_id=exec_cmd['Id'], stream=False)
cmd_output = cmd_output.decode('utf-8', 'replace').strip()

# Kill container
client.kill(container_id)

return cmd_output