-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add consistent local environment for testing with docker and docker-compose #86
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM buildpack-deps:jessie | ||
|
||
ENV PHP_VERSION 5.3.29 | ||
|
||
# php 5.3 needs older autoconf | ||
RUN set -eux; \ | ||
\ | ||
apt-get update; \ | ||
apt-get install -y \ | ||
curl \ | ||
autoconf2.13 \ | ||
; \ | ||
rm -r /var/lib/apt/lists/*; \ | ||
\ | ||
curl -sSLfO http://launchpadlibrarian.net/140087283/libbison-dev_2.7.1.dfsg-1_amd64.deb; \ | ||
curl -sSLfO http://launchpadlibrarian.net/140087282/bison_2.7.1.dfsg-1_amd64.deb; \ | ||
dpkg -i libbison-dev_2.7.1.dfsg-1_amd64.deb; \ | ||
dpkg -i bison_2.7.1.dfsg-1_amd64.deb; \ | ||
rm *.deb; \ | ||
\ | ||
curl -sSLf "https://php.net/get/php-$PHP_VERSION.tar.bz2/from/this/mirror" -o php.tar.bz2; \ | ||
echo 'c4e1cf6972b2a9c7f2777a18497d83bf713cdbecabb65d3ff62ba441aebb0091 php.tar.bz2' | sha256sum -cw --status; \ | ||
\ | ||
mkdir -p /usr/src/php; \ | ||
tar -xf php.tar.bz2 -C /usr/src/php --strip-components=1; \ | ||
rm php.tar.bz2*; \ | ||
\ | ||
cd /usr/src/php; \ | ||
./buildconf --force; \ | ||
./configure --disable-cgi \ | ||
$(command -v apxs2 > /dev/null 2>&1 && echo '--with-apxs2' || true) \ | ||
--with-pdo-mysql \ | ||
--with-zlib \ | ||
--enable-mbstring \ | ||
; \ | ||
make -j"$(nproc)"; \ | ||
make install; \ | ||
\ | ||
dpkg -r \ | ||
bison \ | ||
libbison-dev \ | ||
; \ | ||
apt-get purge -y --auto-remove \ | ||
autoconf2.13 \ | ||
; \ | ||
rm -r /usr/src/php | ||
|
||
CMD ["php", "-a"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM php:5.4-cli | ||
|
||
RUN docker-php-ext-install pdo | ||
RUN docker-php-ext-install pdo_mysql | ||
RUN docker-php-ext-install mbstring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ARG PHP_TAG | ||
FROM php:${PHP_TAG} | ||
|
||
RUN docker-php-ext-install pdo | ||
RUN docker-php-ext-install pdo_mysql | ||
RUN docker-php-ext-install mbstring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ARG PHP_VERSION | ||
FROM php:${PHP_VERSION}-cli | ||
|
||
RUN docker-php-ext-install pdo | ||
RUN docker-php-ext-install pdo_mysql | ||
RUN docker-php-ext-install mbstring | ||
|
||
# For consistent mime type file guesser | ||
RUN set -eux; \ | ||
distFilePath=`which file`; \ | ||
\ | ||
mv ${distFilePath} ${distFilePath}.dist; \ | ||
{ \ | ||
echo '#! /bin/sh -eu'; \ | ||
echo ''; \ | ||
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \ | ||
} | tee ${distFilePath}; \ | ||
\ | ||
chmod +x ${distFilePath}; \ | ||
\ | ||
file /bin/ls --mime | grep application/x-executable; \ | ||
:; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
ARG PHP_VERSION | ||
FROM php:${PHP_VERSION}-cli | ||
|
||
RUN docker-php-ext-install pdo | ||
RUN docker-php-ext-install pdo_mysql | ||
|
||
# Install mbstring PHP extension | ||
# | ||
RUN set -eux; \ | ||
apt-get update; \ | ||
apt-get install -y --no-upgrade --no-install-recommends \ | ||
libonig-dev \ | ||
; \ | ||
\ | ||
apt-get clean; \ | ||
rm -rf /var/lib/apt/lists/*; \ | ||
\ | ||
docker-php-ext-install mbstring | ||
|
||
# For consistent mime type file guesser | ||
RUN set -eux; \ | ||
distFilePath=`which file`; \ | ||
\ | ||
mv ${distFilePath} ${distFilePath}.dist; \ | ||
{ \ | ||
echo '#! /bin/sh -eu'; \ | ||
echo ''; \ | ||
echo "${distFilePath}"'.dist "$@" | sed -e s,application/x-pie-executable,application/x-executable,g'; \ | ||
} | tee ${distFilePath}; \ | ||
\ | ||
chmod +x ${distFilePath}; \ | ||
\ | ||
file /bin/ls --mime | grep application/x-executable; \ | ||
:; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
tests/DoctrineTest/doctrine_tests/* | ||
*TestCase.php | ||
/composer.lock | ||
/tests/tmp | ||
/tests/foo.sq3 | ||
/vendor/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Doctrine1 | ||
========= | ||
|
||
About this version | ||
------------------ | ||
|
||
This is a community driven fork of doctrine 1, as official support has been interrupted long time ago. | ||
|
||
**Do not use it for new projects: this version is great to improve existing symfony1 applications using doctrine1, but [Doctrine2](https://www.doctrine-project.org/projects/orm.html) is the way to go today.** | ||
|
||
|
||
Requirements | ||
------------ | ||
|
||
PHP 5.3 and up. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
Using [Composer](http://getcomposer.org/doc/00-intro.md) as dependency management: | ||
|
||
composer require friendsofsymfony1/doctrine1 "1.5.*" | ||
composer install | ||
|
||
|
||
|
||
Tests | ||
----- | ||
|
||
### Prerequisites | ||
|
||
* docker-engine version 17.12.0+ | ||
* docker-compose version 1.20.0+ | ||
|
||
### How to execute all tests on all supported PHP versions and dependencies? | ||
|
||
tests/bin/test | ||
|
||
### When you finish your work day, do not forget to clean up your desk | ||
|
||
docker-compose down | ||
|
||
|
||
Documentation | ||
------------- | ||
|
||
Read the official [doctrine1 documentation](https://web.archive.org/web/20171008235327/http://docs.doctrine-project.org:80/projects/doctrine1/en/latest/en/manual/index.html) | ||
|
||
|
||
Contributing | ||
------------ | ||
|
||
You can send pull requests or create an issue. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
version: '3.5' | ||
|
||
volumes: | ||
db_socket: | ||
|
||
services: | ||
composer: | ||
image: composer | ||
working_dir: /app | ||
volumes: | ||
- .:/app | ||
entrypoint: | ||
- sh | ||
- -c | ||
- | | ||
exec tail -f /dev/null | ||
|
||
php53: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of multiple service, we could merge together multiple docker-compose files WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice refacto. I do not have time to implements right now. |
||
build: .docker/php53 | ||
working_dir: /app/tests | ||
volumes: | ||
- .:/app | ||
- db_socket:/var/run/mysqld | ||
entrypoint: | ||
- sh | ||
- -c | ||
- | | ||
{ | ||
echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this into a file, and copy it into the build image? WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly |
||
echo 'memory_limit = -1' | ||
echo 'short_open_tag = off' | ||
echo 'magic_quotes_gpc = off' | ||
echo 'date.timezone = "UTC"' | ||
} | tee -a /usr/local/lib/php.ini | ||
|
||
exec tail -f /dev/null | ||
|
||
php54: &services_php54 | ||
build: | ||
context: .docker/php54 | ||
working_dir: /app/tests | ||
volumes: | ||
- .:/app | ||
- db_socket:/var/run/mysqld | ||
entrypoint: | ||
- sh | ||
- -c | ||
- | | ||
{ | ||
echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock' | ||
echo 'memory_limit = -1' | ||
echo 'short_open_tag = off' | ||
echo 'magic_quotes_gpc = off' | ||
echo 'date.timezone = "UTC"' | ||
} | tee -a /usr/local/etc/php/php.ini | ||
|
||
exec tail -f /dev/null | ||
depends_on: | ||
- db | ||
|
||
php55: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php55_71 | ||
args: | ||
PHP_TAG: '5.5-cli' | ||
|
||
php56: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php55_71 | ||
args: | ||
PHP_TAG: '5.6-cli-jessie' | ||
|
||
php70: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php55_71 | ||
args: | ||
PHP_TAG: '7.0-cli-jessie' | ||
|
||
php71: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php55_71 | ||
args: | ||
PHP_TAG: '7.1-cli-jessie' | ||
|
||
php72: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php72_73 | ||
args: | ||
PHP_VERSION: '7.2' | ||
|
||
php73: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php72_73 | ||
args: | ||
PHP_VERSION: '7.3' | ||
|
||
php74: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php74_81 | ||
args: | ||
PHP_VERSION: '7.4' | ||
|
||
php80: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php74_81 | ||
args: | ||
PHP_VERSION: '8.0' | ||
|
||
php81: | ||
<<: *services_php54 | ||
build: | ||
context: .docker/php74_81 | ||
args: | ||
PHP_VERSION: '8.1' | ||
|
||
db: | ||
image: mysql:5.5.62 | ||
environment: | ||
- MYSQL_ALLOW_EMPTY_PASSWORD=yes | ||
volumes: | ||
- db_socket:/tmp | ||
entrypoint: | ||
- bash | ||
- -c | ||
- | | ||
{ | ||
echo "CREATE DATABASE IF NOT EXISTS test;" | ||
} | tee /docker-entrypoint-initdb.d/init.sql | ||
|
||
exec /usr/local/bin/docker-entrypoint.sh mysqld |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#! /bin/sh -eu | ||
# | ||
# [<php-version>] [<dependency-preference>] [<php-test-runtime>] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to split this into 2 scripts?
WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What issue should this fix ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, what I think. The current script if a first step that can be improved. Regarding developer experienceWe need simplicity over complexity or confusion. 2 test scripts available are already too much. 2 test scripts will bring too much complexity and confusion. The goal is to have only one command to execute the test suite and that done things well.
If this command done successfully you should feel safe to merge the code or submit the pull request. Quote from the book "Clean Code" wrote by Robert C. Martin
|
||
# | ||
# <php-version> example: php70 | ||
# <dependency-preference> One of highest (default), lowest | ||
# | ||
# Both arguments can be a space separated value. | ||
# Example: "lowest highest" | ||
# | ||
|
||
# Configuration | ||
# | ||
dependencyPreferences='highest' | ||
skipPHPVersions='php8' | ||
|
||
# Commands | ||
# | ||
dcexec="docker-compose exec -u `id -u`:`id -g`" | ||
composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader' | ||
doctrineTestSuite='run.php' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would we need to change this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To speed up feedback loop during TDD sessions, when the modified does not touch outside. The full test suite is slow, moreover, with all PHP version to execute. That's a problem. So, need to run only one test case. |
||
|
||
# Parse arguments | ||
# | ||
phpVersions="${1-}" | ||
dependencyPreferences="${2-${dependencyPreferences}}" | ||
phpTestRuntime="${3-${doctrineTestSuite}}" | ||
|
||
script () | ||
{ | ||
echo | ||
echo | ||
echo $0 ${1} ${2} | ||
echo | ||
${dcexec} ${1} php ${phpTestRuntime} | ||
} | ||
|
||
scriptAll () | ||
{ | ||
for dependencyPreference in ${dependencyPreferences} | ||
do | ||
install_${dependencyPreference} | ||
|
||
for phpVersion in ${phpVersions} | ||
do | ||
script ${phpVersion} ${dependencyPreference} | ||
done | ||
done | ||
} | ||
|
||
fetchAllPHPVersions () | ||
{ | ||
docker-compose 2>/dev/null ps --services --filter status=running \ | ||
| grep php \ | ||
| sort \ | ||
| grep -v ${skipPHPVersions} | ||
} | ||
|
||
install_highest () | ||
{ | ||
${dcexec} composer ${composerUpdate} | ||
} | ||
|
||
install_lowest () | ||
{ | ||
${dcexec} composer ${composerUpdate} --prefer-lowest | ||
} | ||
|
||
echo '+ docker-compose build' | ||
docker-compose up -d --build --remove-orphans > /dev/null | ||
|
||
test x"" != x"${phpVersions}" || { | ||
phpVersions=`fetchAllPHPVersions` | ||
} | ||
|
||
scriptAll |
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.
The heading is not consistent within the file (using
### Header 3
and underlines, like on this like)We should keep the formatting consistent, I suggest to use:
# Header 1
## Hader 2
wdyt?
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.
I do not have any point of view about Markdown formatting.
I am curious about that, do you have some resources to share ?