forked from gitpython-developers/GitPython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a Dockerfile that creates a clean Ubuntu Xenial test environment
- Loading branch information
Showing
9 changed files
with
122 additions
and
10 deletions.
There are no files selected for viewing
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,2 @@ | ||
.git/ | ||
.tox/ |
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,80 @@ | ||
# | ||
# Contributed by: James E. King III (@jeking3) <[email protected]> | ||
# | ||
# This Dockerfile creates an Ubuntu Xenial build environment | ||
# that can run the same test suite as Travis CI. | ||
# | ||
|
||
FROM ubuntu:xenial | ||
MAINTAINER James E. King III <[email protected]> | ||
ENV CONTAINER_USER=user | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
add-apt-key \ | ||
apt \ | ||
apt-transport-https \ | ||
apt-utils \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
net-tools \ | ||
openssh-client \ | ||
sudo \ | ||
vim \ | ||
wget | ||
|
||
RUN add-apt-key -v 6A755776 -k keyserver.ubuntu.com && \ | ||
add-apt-key -v E1DF1F24 -k keyserver.ubuntu.com && \ | ||
echo "deb http://ppa.launchpad.net/git-core/ppa/ubuntu xenial main" >> /etc/apt/sources.list && \ | ||
echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial main" >> /etc/apt/sources.list && \ | ||
apt-get update && \ | ||
apt-get install -y --install-recommends git python2.7 python3.4 python3.5 python3.6 python3.7 && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python2.7 27 && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.4 34 && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 35 && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 36 && \ | ||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 37 | ||
|
||
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \ | ||
python3 get-pip.py && \ | ||
pip3 install tox | ||
|
||
# Clean up | ||
RUN rm -rf /var/cache/apt/* && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
rm -rf /tmp/* && \ | ||
rm -rf /var/tmp/* | ||
|
||
################################################################# | ||
# Build as a regular user | ||
# Credit: https://github.com/delcypher/docker-ubuntu-cxx-dev/blob/master/Dockerfile | ||
# License: None specified at time of import | ||
# Add non-root user for container but give it sudo access. | ||
# Password is the same as the username | ||
RUN useradd -m ${CONTAINER_USER} && \ | ||
echo ${CONTAINER_USER}:${CONTAINER_USER} | chpasswd && \ | ||
echo "${CONTAINER_USER} ALL=(root) ALL" >> /etc/sudoers | ||
RUN chsh --shell /bin/bash ${CONTAINER_USER} | ||
USER ${CONTAINER_USER} | ||
################################################################# | ||
|
||
# The test suite will not tolerate running against a branch that isn't "master", so | ||
# check out the project to a well-known location that can be used by the test suite. | ||
# This has the added benefit of protecting the local repo fed into the container | ||
# as a volume from getting destroyed by a bug exposed by the test suite. :) | ||
ENV TRAVIS=ON | ||
RUN git clone --recursive https://github.com/gitpython-developers/GitPython.git /home/${CONTAINER_USER}/testrepo && \ | ||
cd /home/${CONTAINER_USER}/testrepo && \ | ||
./init-tests-after-clone.sh | ||
ENV GIT_PYTHON_TEST_GIT_REPO_BASE=/home/${CONTAINER_USER}/testrepo | ||
ENV TRAVIS= | ||
|
||
# Ensure any local pip installations get on the path | ||
ENV PATH=/home/${CONTAINER_USER}/.local/bin:${PATH} | ||
|
||
# Set the global default git user to be someone non-descript | ||
RUN git config --global user.email [email protected] && \ | ||
git config --global user.name "GitPython CI User" | ||
|
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,3 +1,5 @@ | ||
.PHONY: all clean release force_release docker-build test nose-pdb | ||
|
||
all: | ||
@grep -Ee '^[a-z].*:' Makefile | cut -d: -f1 | grep -vF all | ||
|
||
|
@@ -16,3 +18,17 @@ force_release: clean | |
git push --tags origin master | ||
python3 setup.py sdist bdist_wheel | ||
twine upload -s -i [email protected] dist/* | ||
|
||
docker-build: | ||
docker build --quiet -t gitpython:xenial -f Dockerfile . | ||
|
||
test: docker-build | ||
# NOTE!!! | ||
# NOTE!!! If you are not running from master or have local changes then tests will fail | ||
# NOTE!!! | ||
docker run --rm -v ${CURDIR}:/src -w /src -t gitpython:xenial tox | ||
|
||
nose-pdb: docker-build | ||
# run tests under nose and break on error or failure into python debugger | ||
# HINT: set PYVER to "pyXX" to change from the default of py37 to pyXX for nose tests | ||
docker run --rm --env PYVER=${PYVER} -v ${CURDIR}:/src -w /src -it gitpython:xenial /bin/bash dockernose.sh |
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,8 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
if [ -z "${PYVER}" ]; then | ||
PYVER=py37 | ||
fi | ||
|
||
tox -e ${PYVER} --notest | ||
PYTHONPATH=/src/.tox/${PYVER}/lib/python*/site-packages /src/.tox/${PYVER}/bin/nosetests --pdb $* |
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
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ ddt>=1.1.1 | |
coverage | ||
flake8 | ||
nose | ||
tox | ||
mock; python_version=='2.7' |