Skip to content

add docker feature #10

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text=auto

/tests export-ignore
/utils export-ignore
/.coveralls.yml export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/docker-compose.yml export-ignore
/phpunit.xml export-ignore
/Dockerfile export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.idea
/coverage
/utils/ccat/ccat
composer.lock
13 changes: 4 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: php

php:
- '7.1'

sudo: required

services:
Expand All @@ -13,20 +10,18 @@ compiler:
- g++

before_install:
- composer require satooshi/php-coveralls
- docker-compose run --rm composer require satooshi/php-coveralls

before_script:
- composer self-update
- composer install --prefer-source --dev
- docker run -p 9000:9000 -p 8123:8123 -d --name some-clickhouse-server --ulimit nofile=262144:262144 yandex/clickhouse-server
- docker-compose run --rm composer install --prefer-source --dev
- cd utils/ccat
- make && make install
- cd ../../

script: phpunit --coverage-clover ./tests/logs/clover.xml
script: docker-compose run --rm phpunit --coverage-clover ./tests/logs/clover.xml

after_script:
- php vendor/bin/php-coveralls -v
- docker-compose run cli vendor/bin/php-coveralls -v

notifications:
on_success: never
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM php:7.1-cli

RUN pecl install xdebug-2.6.0 \
&& docker-php-ext-enable xdebug

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php composer-setup.php --install-dir=/usr/bin --filename=composer \
&& php -r "unlink('composer-setup.php');"

WORKDIR "/app"
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,32 @@ $client->writeOne('DROP TABLE table');

## Testing

Install dependencies (one time)

``` bash
$ composer install
```

Run tests

``` bash
$ composer test
```

## Testing with Docker

Install dependencies (one time)

``` bash
$ docker-compose run --rm composer install
```

Run tests

``` bash
$ docker-compose run --rm phpunit
```

## Roadmap

* Add ability to save query result in local file
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3.6"

services:
clickhouse:
image: "yandex/clickhouse-server:19.11.3.11"
composer:
build:
context: .
dockerfile: Dockerfile
entrypoint:
- "composer"
volumes:
- "./:/app"
- ${COMPOSER_HOME:-$HOME/.composer}:/tmp
phpunit:
build:
context: .
dockerfile: Dockerfile
depends_on:
- clickhouse
volumes:
- "./:/app"
entrypoint:
- "./vendor/bin/phpunit"
environment:
"CH_HOST": "clickhouse"
"CH_PORT": "8123"
cli:
build:
context: .
dockerfile: Dockerfile
volumes:
- "./:/app"
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<log type="coverage-html" target="coverage" charset="UTF-8"/>
</logging>
<php>
<const name="CLICKHOUSE_SERVER_HOST" value="127.0.0.1"/>
<const name="CLICKHOUSE_SERVER_PORT" value="8123"/>
<env name="CH_HOST" value="127.0.0.1"/>
<env name="CH_PORT" value="8123"/>
<const name="CCAT_PATH" value="bin/ccat"/>
</php>
</phpunit>
Loading