-
Notifications
You must be signed in to change notification settings - Fork 70
Test command versions on master
branch
#143
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bc02c15
Run some version tests after building the image
humitos 1f27462
Install docker for tests
humitos 5717135
Update Python version to match latest ones
humitos d00ba8f
Check setuptools version on all Python versions
humitos f2f3a87
Refactor to isolate 'run_commnd_in_container' and re-use it
humitos 7bbd96f
Test more docker images (5.0, 6.0 and 7.0)
humitos 0825a17
Add test for cargo/rust version on 7.0
humitos 8d07107
Add tests for readthedocs/build:master tag
humitos fbedc03
Run tests in all the branches we care
humitos 682c9df
Add check for git --version
humitos b7c3aaa
Make this directory a package
humitos fe49abd
Use `readthedocs/build:master` as image name
humitos d10d544
Use --cache-from for `docker build`
humitos c1eebe3
Pull the image before to use is as cache
humitos e3204e8
Fix virtualenv versions on master
humitos cf1a119
Fix pip version for python2 on master
humitos d5f2d62
Py2 pip version, again :(
humitos 3db2351
More versions fixes
humitos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -11,3 +11,4 @@ name = "pypi" | |
requests = "*" | ||
pytest = "*" | ||
pytest-custom-exit-code = "*" | ||
docker = "*" |
Empty file.
This file contains hidden or 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,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 |
This file contains hidden or 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,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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we don't the context, you can pass the dockerfile as
- < Dockerfile