From d4f630ae356772d148554d8842eeec9dee1ac569 Mon Sep 17 00:00:00 2001 From: k911 Date: Sun, 11 Nov 2018 23:50:05 +0100 Subject: [PATCH] build(docker): Provide configuration for testing --- .dockerignore | 9 + Dockerfile | 90 ++++++++++ composer.json | 29 ++-- docker-compose.yml | 339 ++++++++++++++++++++++++++++++++++++++ docker-test.sh | 149 +++++++++++++++++ tests/run-server-tests.sh | 16 ++ 6 files changed, 621 insertions(+), 11 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100755 docker-test.sh create mode 100755 tests/run-server-tests.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..60427b01 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +* +!/src +!/tests +!composer.json +!composer.lock +!phpstan.neon.dist +!phpstan.tests.neon +!phpunit.xml +!.php_cs.dist diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9fd51fc5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,90 @@ +ARG ALPINE_TAG="3.8" +ARG PHP_TAG="7.2-cli-alpine3.8" + +FROM php:$PHP_TAG as ext-builder +RUN docker-php-source extract && \ + apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS + +FROM ext-builder as ext-inotify +RUN pecl install inotify && \ + docker-php-ext-enable inotify + +FROM ext-builder as ext-pcntl +RUN docker-php-ext-install pcntl + +FROM ext-builder as ext-xdebug +RUN pecl install xdebug && \ + docker-php-ext-enable xdebug + +FROM ext-builder as ext-swoole +ARG SWOOLE_VERSION=4.2.13 +RUN pecl install swoole-$SWOOLE_VERSION && \ + docker-php-ext-enable swoole + +FROM composer:latest as app-installer +WORKDIR /usr/src/app +RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --classmap-authoritative --ansi +COPY composer.json composer.lock ./ +RUN composer validate +ARG COMPOSER_ARGS=install +RUN composer "$COMPOSER_ARGS" --prefer-dist --ignore-platform-reqs --no-progress --no-suggest --no-scripts --no-autoloader --ansi +COPY . ./ +RUN composer dump-autoload --classmap-authoritative --ansi + +FROM php:$PHP_TAG as base +RUN apk add --no-cache libstdc++ +WORKDIR /usr/src/app +COPY --from=ext-swoole /usr/local/lib/php/extensions/no-debug-non-zts-20170718/swoole.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/swoole.so +COPY --from=ext-swoole /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini +COPY --from=ext-inotify /usr/local/lib/php/extensions/no-debug-non-zts-20170718/inotify.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/inotify.so +COPY --from=ext-inotify /usr/local/etc/php/conf.d/docker-php-ext-inotify.ini /usr/local/etc/php/conf.d/docker-php-ext-inotify.ini +COPY --from=ext-pcntl /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pcntl.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/pcntl.so +COPY --from=ext-pcntl /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini + +FROM base as base-with-xdebug +COPY --from=ext-xdebug /usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so +COPY --from=ext-xdebug /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +FROM base as base-cli +COPY --from=app-installer /usr/src/app ./ + +FROM base as base-server +RUN apk add --no-cache bash +COPY --from=app-installer /usr/src/app ./ + +FROM base-with-xdebug as base-coverage +ENV COVERAGE=1 +COPY --from=app-installer /usr/src/app ./ + +FROM base-with-xdebug as base-server-coverage +RUN apk add --no-cache bash +ENV COVERAGE=1 +COPY --from=app-installer /usr/src/app ./ + +FROM base-cli as Cli +ENTRYPOINT ["./tests/Fixtures/Symfony/app/console"] +CMD ["swoole:server:run"] + +FROM base-cli as Composer +ENV COMPOSER_ALLOW_SUPERUSER=1 +COPY --from=app-installer /usr/bin/composer /usr/local/bin/composer +ENTRYPOINT ["composer"] +CMD ["test"] + +FROM base-coverage as ComposerCoverage +ENV COMPOSER_ALLOW_SUPERUSER=1 +COPY --from=app-installer /usr/bin/composer /usr/local/bin/composer +ENTRYPOINT ["composer"] +CMD ["code-coverage"] + +FROM base-server as Server +WORKDIR /usr/src/app/tests/Server +ENTRYPOINT ["/bin/bash"] +CMD ["../run-server-tests.sh"] + +FROM base-server-coverage as ServerCoverage +WORKDIR /usr/src/app/tests/Server +ENV APP_ENV=cov \ + SWOOLE_ALLOW_XDEBUG=1 +ENTRYPOINT ["/bin/bash"] +CMD ["../run-server-tests.sh"] diff --git a/composer.json b/composer.json index d4fdb1b7..8c46e41c 100644 --- a/composer.json +++ b/composer.json @@ -12,13 +12,11 @@ ], "license": "MIT", "homepage": "https://github.com/k911/swoole-bundle", - "authors": [ - { - "name": "Konrad Obal", - "email": "konrad.obal@gmail.com", - "homepage": "https://github.com/k911" - } - ], + "authors": [{ + "name": "Konrad Obal", + "email": "konrad.obal@gmail.com", + "homepage": "https://github.com/k911" + }], "require": { "php": "^7.2", "ext-swoole": "^4", @@ -72,12 +70,21 @@ "console": [ "php tests/Fixtures/Symfony/app/console --ansi" ], + "static-analyse-src": [ + "phpstan analyze src -l 7 --ansi" + ], + "static-analyse-tests": [ + "phpstan analyze tests -l 4 -c phpstan.tests.neon --ansi" + ], + "cs-analyse": [ + "php-cs-fixer fix -v --dry-run --diff --stop-on-violation --ansi" + ], "analyse": [ - "phpstan analyze src -l 7 --ansi", + "@static-analyse-src", "", - "phpstan analyze tests -l 4 -c phpstan.tests.neon --ansi", + "@static-analyse-tests", "", - "php-cs-fixer fix -v --dry-run --diff --stop-on-violation --ansi" + "@cs-analyse" ], "test": [ "@analyse", @@ -93,7 +100,7 @@ "COVERAGE=1 phpunit tests/Feature --coverage-php cov/feature-tests.cov --colors=always --process-isolation" ], "merge-code-coverage": [ - "phpcov merge cov --clover clover.xml" + "phpcov merge cov --clover=clover.xml" ], "fix": "php-cs-fixer fix -v --ansi", "unit-tests": [ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9d25ccb7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,339 @@ +version: "3.6" +services: + ext-builder: + image: "k911/swoole-bundle:ext-builder" + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + target: ext-builder + + ext-inotify: + image: "k911/swoole-bundle:ext-inotify" + depends_on: + - ext-builder + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + target: ext-inotify + + ext-pcntl: + image: "k911/swoole-bundle:ext-pcntl" + depends_on: + - ext-inotify + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + target: ext-pcntl + + ext-xdebug: + image: "k911/swoole-bundle:ext-xdebug" + depends_on: + - ext-pcntl + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + target: ext-xdebug + + ext-swoole: + image: "k911/swoole-bundle:ext-swoole" + depends_on: + - ext-xdebug + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + target: ext-swoole + + app-installer: + image: "k911/swoole-bundle:app-installer" + depends_on: + - ext-swoole + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + target: app-installer + + base: + image: "k911/swoole-bundle:base" + depends_on: + - app-installer + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + target: base + + base-with-xdebug: + image: "k911/swoole-bundle:base-with-xdebug" + depends_on: + - base + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + target: base-with-xdebug + + base-cli: + image: "k911/swoole-bundle:base-cli" + depends_on: + - base-with-xdebug + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + target: base-cli + + base-server: + image: "k911/swoole-bundle:base-server" + depends_on: + - base-cli + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + target: base-server + + base-coverage: + image: "k911/swoole-bundle:base-coverage" + depends_on: + - base-server + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + target: base-server + + base-server-coverage: + image: "k911/swoole-bundle:base-server-coverage" + depends_on: + - base-coverage + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + - "k911/swoole-bundle:base-server-coverage" + target: base-server-coverage + + cli: + image: "k911/swoole-bundle:cli" + depends_on: + - base-server-coverage + build: + context: . + target: Cli + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + - "k911/swoole-bundle:base-server-coverage" + - "k911/swoole-bundle:cli" + ports: + - 9501:9501 + + composer: + image: "k911/swoole-bundle:composer" + depends_on: + - cli + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + - "k911/swoole-bundle:base-server-coverage" + - "k911/swoole-bundle:cli" + - "k911/swoole-bundle:composer" + target: Composer + + composer-coverage: + image: "k911/swoole-bundle:composer-coverage" + depends_on: + - composer + build: + context: . + target: ComposerCoverage + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + - "k911/swoole-bundle:base-server-coverage" + - "k911/swoole-bundle:cli" + - "k911/swoole-bundle:composer" + - "k911/swoole-bundle:composer-coverage" + volumes: + - "./cov:/usr/src/app/cov" + + server: + image: "k911/swoole-bundle:server" + depends_on: + - composer-coverage + build: + context: . + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + - "k911/swoole-bundle:base-server-coverage" + - "k911/swoole-bundle:cli" + - "k911/swoole-bundle:composer" + - "k911/swoole-bundle:composer-coverage" + - "k911/swoole-bundle:server" + target: Server + + server-coverage: + image: "k911/swoole-bundle:server-coverage" + depends_on: + - server + build: + context: . + target: ServerCoverage + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + - "k911/swoole-bundle:base-server-coverage" + - "k911/swoole-bundle:cli" + - "k911/swoole-bundle:composer" + - "k911/swoole-bundle:composer-coverage" + - "k911/swoole-bundle:server" + - "k911/swoole-bundle:server-coverage" + volumes: + - "./cov:/usr/src/app/cov" + + merge-code-coverage: + image: "k911/swoole-bundle:composer-coverage" + command: "merge-code-coverage" + depends_on: + - composer + build: + context: . + target: ComposerCoverage + cache_from: + - "k911/swoole-bundle:ext-builder" + - "k911/swoole-bundle:ext-inotify" + - "k911/swoole-bundle:ext-pcntl" + - "k911/swoole-bundle:ext-xdebug" + - "k911/swoole-bundle:ext-swoole" + - "k911/swoole-bundle:app-installer" + - "k911/swoole-bundle:base" + - "k911/swoole-bundle:base-with-xdebug" + - "k911/swoole-bundle:base-cli" + - "k911/swoole-bundle:base-server" + - "k911/swoole-bundle:base-coverage" + - "k911/swoole-bundle:base-server-coverage" + - "k911/swoole-bundle:cli" + - "k911/swoole-bundle:composer" + - "k911/swoole-bundle:composer-coverage" + volumes: + - "./cov:/usr/src/app/cov:ro" + - "./clover.xml:/usr/src/app/clover.xml" diff --git a/docker-test.sh b/docker-test.sh new file mode 100755 index 00000000..0efe15ba --- /dev/null +++ b/docker-test.sh @@ -0,0 +1,149 @@ +#!/usr/bin/env bash + +COVERAGE_DIR="cov" +COVERAGE_FILE="clover.xml" +REGISTRY="docker.io" +NAMESPACE="k911" +IMAGE_NAME="swoole-bundle" +IMAGE_WORKDIR="/usr/src/app" +IMAGE_APP_INSTALLER_TAG="app-installer" +IMAGE_EXT_BUILDER_TAG="ext-builder" +IMAGE_EXT_PCNTL_TAG="ext-pcntl" +IMAGE_EXT_XDEBUG_TAG="ext-xdebug" +IMAGE_EXT_INOTIFY_TAG="ext-inotify" +IMAGE_EXT_SWOOLE_TAG="ext-swoole" +IMAGE_BASE_TAG="base" +IMAGE_BASE_CLI_TAG="base-cli" +IMAGE_BASE_SERVER_TAG="base-server" +IMAGE_BASE_COVERAGE_TAG="base-coverage" +IMAGE_BASE_SERVER_COVERAGE_TAG="base-server-coverage" +IMAGE_BASE_WITH_XDEBUG_TAG="base-with-xdebug" +IMAGE_CLI_TAG="cli" +IMAGE_COMPOSER_TAG="composer" +IMAGE_COMPOSER_COVERAGE_TAG="composer-coverage" +IMAGE_SERVER_TAG="server" +IMAGE_SERVER_COVERAGE_TAG="server-coverage" + +# DOCKER_USER="" +# DOCKER_PASSWORD="" + +# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin + +# requires docker-ce 18.09 +# export DOCKER_BUILDKIT=1 + + +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_APP_INSTALLER_TAG" + +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_BUILDER_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_SWOOLE_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_PCNTL_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_INOTIFY_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_XDEBUG_TAG" + +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_CLI_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_WITH_XDEBUG_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_COVERAGE_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_TAG" +docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_COVERAGE_TAG" + +# docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_CLI_TAG" +# docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_TAG" +# docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_COVERAGE_TAG" +# docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_TAG" +# docker pull "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_COVERAGE_TAG" + +docker build --target Cli . \ + --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_CLI_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_BUILDER_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_INOTIFY_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_PCNTL_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_SWOOLE_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_XDEBUG_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_APP_INSTALLER_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_CLI_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_WITH_XDEBUG_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_COVERAGE_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_COVERAGE_TAG" + +docker build --target Composer . \ + --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_BUILDER_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_INOTIFY_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_PCNTL_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_SWOOLE_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_XDEBUG_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_APP_INSTALLER_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_CLI_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_WITH_XDEBUG_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_COVERAGE_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_TAG" \ + --cache-from "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_COVERAGE_TAG" + +docker run "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_TAG" cs-analyse +docker run "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_TAG" static-analyse-src +docker run "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_TAG" static-analyse-tests + +rm -rf "$COVERAGE_DIR" +mkdir "$COVERAGE_DIR" + +docker build -t "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_COVERAGE_TAG" . \ + --target ComposerCoverage + +docker run -v "$(pwd)/$COVERAGE_DIR:$IMAGE_WORKDIR/$COVERAGE_DIR" "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_COVERAGE_TAG" + +docker build -t "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_TAG" . \ + --target Server + +docker run "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_TAG" -c ls + +docker run "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_TAG" + +docker build -t "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_COVERAGE_TAG" . \ + --target ServerCoverage + +docker run -v "$(pwd)/$COVERAGE_DIR:$IMAGE_WORKDIR/$COVERAGE_DIR" "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_COVERAGE_TAG" + +rm "$COVERAGE_FILE" +touch "$COVERAGE_FILE" +docker run -v "$(pwd)/$COVERAGE_DIR:$IMAGE_WORKDIR/$COVERAGE_DIR:ro" \ + -v "$(pwd)/$COVERAGE_FILE:$IMAGE_WORKDIR/$COVERAGE_FILE" \ + "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_COVERAGE_TAG" merge-code-coverage + +docker build --target ext-builder --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_BUILDER_TAG" . +docker build --target ext-swoole --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_SWOOLE_TAG" . +docker build --target ext-pcntl --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_PCNTL_TAG" . +docker build --target ext-inotify --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_INOTIFY_TAG" . +docker build --target ext-xdebug --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_XDEBUG_TAG" . + +docker build --target app-installer --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_APP_INSTALLER_TAG" . +docker build --target base --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_TAG" . +docker build --target base-cli --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_CLI_TAG" . +docker build --target base-with-xdebug --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_WITH_XDEBUG_TAG" . +docker build --target base-coverage --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_COVERAGE_TAG" . +docker build --target base-server --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_TAG" . +docker build --target base-server-coverage --tag "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_COVERAGE_TAG" . + +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_BUILDER_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_SWOOLE_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_PCNTL_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_INOTIFY_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_EXT_XDEBUG_TAG" + +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_APP_INSTALLER_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_CLI_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_WITH_XDEBUG_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_COVERAGE_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_BASE_SERVER_COVERAGE_TAG" + +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_CLI_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_COMPOSER_COVERAGE_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_TAG" +docker push "$REGISTRY/$NAMESPACE/$IMAGE_NAME:$IMAGE_SERVER_COVERAGE_TAG" diff --git a/tests/run-server-tests.sh b/tests/run-server-tests.sh new file mode 100755 index 00000000..377b7aa0 --- /dev/null +++ b/tests/run-server-tests.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +cd "$( dirname "${BASH_SOURCE[0]}" )"; + +EXIT_CODE=0 + +for f in ./Server/*.sh; do + echo "[Test] $f"; + if [[ "$COVERAGE" == "1" ]]; then + APP_ENV=cov SWOOLE_ALLOW_XDEBUG=1 bash "$f" -H || EXIT_CODE=1; + else + bash "$f" -H || EXIT_CODE=1; + fi +done + +exit $EXIT_CODE