Merge pull request #529 from x3ro/docker-testrunner

[WIP] Docker test runner
This commit is contained in:
Anton Medvedev 2016-11-03 20:29:21 +07:00 committed by GitHub
commit 4328d6e0fc
4 changed files with 56 additions and 0 deletions

19
test/docker/Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM php:5.6-cli
RUN export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get -qq install openssh-server sudo
ENV DEPLOYER_USERNAME deployer
ENV DEPLOYER_PASSWORD deployer_password
RUN useradd --create-home --base-dir /home "${DEPLOYER_USERNAME}"
RUN echo "${DEPLOYER_USERNAME}:${DEPLOYER_PASSWORD}" | chpasswd
RUN echo "deployer ALL=NOPASSWD: ALL" >> /etc/sudoers
USER deployer
RUN mkdir -p ~/.ssh
RUN ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""
RUN cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
RUN chmod 600 ~/.ssh/*

17
test/docker/README.md Normal file
View File

@ -0,0 +1,17 @@
# Running tests with docker
If you have docker installed on your local system, just run `test/docker/run.sh` from the root of the repository.
If you cannot or don't want to install docker locally, you can use [docker machine](https://docs.docker.com/machine/) do run the tests inside a VM or e.g. a Digital Ocean container. After having created a docker machine (lets say you called it `default`), just load its environment:
eval "$(docker-machine env default)"
Now you can run `test/docker/run.sh` as if docker was installed locally. Or maybe you just want to run a single test?
test/docker/run.sh --filter TaskTest::testTask
Or all tests that contain the word "parallel":
test/docker/run.sh --filter parallel
All parameters are directly passed to the `phpunit` command line tool as documented [here](https://phpunit.de/manual/current/en/textui.html).

View File

@ -0,0 +1,9 @@
#!/bin/bash -xe
sudo service ssh start
eval `ssh-agent`
ssh-add
ssh-keyscan -t rsa localhost > ~/.ssh/known_hosts
cd ~/deployer && vendor/phpunit/phpunit/phpunit $@

11
test/docker/run.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ ! -f composer.json ]; then
echo "Please run this from the deployer repository root"
exit 1
fi
composer install &&
docker build -t deployer-5.6 test/docker &&
docker run -v $(pwd):/home/deployer/deployer -i -t deployer-5.6 \
/home/deployer/deployer/test/docker/docker-bootstrap.sh $@