diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 2df4daa9..6a1af194 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -1,21 +1,21 @@ -name: "coding standards" +name: "docker coding standards" on: ["pull_request", "push"] jobs: coding-standards: - name: "coding standards" + name: "docker coding standards" runs-on: "ubuntu-latest" steps: - name: "checkout" uses: "actions/checkout@v2" - - name: "installing PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "7.4" - ini-values: memory_limit=-1 - tools: composer:v2, cs2pr, php-cs-fixer + - name: "build the environment" + run: "dev/bin/docker-compose build" - name: "checking coding standards" - run: "php-cs-fixer fix --dry-run --diff --ansi" + run: "dev/bin/php php-cs-fixer fix --dry-run --diff --ansi" + + - name: Clear docker volumes + if: ${{ always() }} + run: dev/bin/docker-compose down --volumes diff --git a/.github/workflows/docker-coding-standards.yml b/.github/workflows/docker-coding-standards.yml deleted file mode 100644 index 91601381..00000000 --- a/.github/workflows/docker-coding-standards.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: "docker coding standards" - -on: ["pull_request", "push"] - -jobs: - coding-standards: - name: "docker coding standards" - runs-on: "ubuntu-latest" - steps: - - name: "checkout" - uses: "actions/checkout@v2" - - - name: "build the environment" - run: "dev/bin/docker-compose build" - - - name: "checking coding standards" - run: "dev/bin/php php-cs-fixer fix --dry-run --diff --ansi" diff --git a/.github/workflows/docker-static-analysis.yml b/.github/workflows/docker-static-analysis.yml deleted file mode 100644 index 301468d9..00000000 --- a/.github/workflows/docker-static-analysis.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "docker static analysis" - -on: ["pull_request", "push"] - -jobs: - coding-standards: - name: "docker static analysis" - runs-on: "ubuntu-latest" - steps: - - name: "checkout" - uses: "actions/checkout@v2" - - - name: "build the environment" - run: "dev/bin/docker-compose build" - - - name: "install dependencies" - run: "dev/bin/php composer install" - - - name: "running static analysis" - run: "dev/bin/php psalm --shepherd --stats" diff --git a/.github/workflows/docker-unit-tests.yml b/.github/workflows/docker-unit-tests.yml deleted file mode 100644 index 1303ddee..00000000 --- a/.github/workflows/docker-unit-tests.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "docker unit tests" - -on: ["pull_request", "push"] - -jobs: - coding-standards: - name: "docker unit tests" - runs-on: "ubuntu-latest" - steps: - - name: "checkout" - uses: "actions/checkout@v2" - - - name: "build the environment" - run: "dev/bin/docker-compose build" - - - name: "install dependencies" - run: "dev/bin/php composer install" - - - name: "running unit tests" - run: "dev/bin/php-test vendor/bin/simple-phpunit" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 135ebe7c..1af0edc3 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,25 +1,24 @@ -name: "static analysis" +name: "docker static analysis" on: ["pull_request", "push"] jobs: static-analysis: - name: "static analysis" + name: "docker static analysis" runs-on: "ubuntu-latest" steps: - name: "checkout" uses: "actions/checkout@v2" - - name: "installing PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "7.4" - ini-values: memory_limit=-1 - tools: composer:v2, psalm - extensions: intl, bcmath, curl, openssl, mbstring, pdo, pdo_sqlite + - name: "build the environment" + run: "dev/bin/docker-compose build" - - name: "installing dependencies" - run: "composer update --no-interaction --no-progress" + - name: "install dependencies" + run: "dev/bin/php composer install" - name: "running static analysis" - run: "psalm --shepherd --stats" + run: "dev/bin/php psalm --shepherd --stats" + + - name: Clear docker volumes + if: ${{ always() }} + run: dev/bin/docker-compose down --volumes diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index ec73db57..56f39431 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,65 +1,32 @@ -name: "unit tests" +name: "docker unit tests" -on: [ "pull_request", "push" ] +on: ["pull_request", "push"] jobs: - unit-tests: - name: "unit tests" - - runs-on: "ubuntu-latest" - - strategy: - matrix: - symfony-version: - - "5.3.*" - php-version: - - "7.2" - - "7.3" - - "7.4" - - "8.0" - dependencies: - - "lowest" - - "highest" - - steps: - - name: "checkout" - uses: "actions/checkout@v2" - - - name: "installing PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "${{ matrix.php-version }}" - tools: composer:v2, cs2pr - extensions: intl, bcmath, curl, openssl, mbstring, pdo, pdo_sqlite - coverage: pcov - ini-values: memory_limit=-1 - - - name: "caching dependencies" - uses: "actions/cache@v2" - with: - path: | - ~/.composer/cache - vendor - key: "php-${{ matrix.php-version }}" - restore-keys: "php-${{ matrix.php-version }}" - - - name: "configuring composer platform" - if: (startsWith(matrix.php, '8.0')) - run: composer config platform.php 7.4.99 - - - name: "install lowest dependencies" - if: ${{ matrix.dependencies == 'lowest' }} - run: composer update --prefer-lowest --no-interaction --no-progress --prefer-dist - - - name: "install highest dependencies" - if: ${{ matrix.dependencies == 'highest' }} - run: | - composer require --no-update symfony/config=${{ matrix.symfony-version }} symfony/http-kernel=${{ matrix.symfony-version }} symfony/dependency-injection=${{ matrix.symfony-version }} symfony/options-resolver=${{ matrix.symfony-version }} - composer require --no-update --dev symfony/framework-bundle=${{ matrix.symfony-version }} symfony/yaml=${{ matrix.symfony-version }} - composer update --no-interaction --no-progress --prefer-dist - - - name: "installing phpunit" - run: vendor/bin/simple-phpunit install - - - name: "running unit tests" - run: vendor/bin/simple-phpunit + unit-tests: + name: "docker unit tests" + runs-on: "ubuntu-latest" + strategy: + fail-fast: true + matrix: + php: [ '7.2', '7.3', '7.4', '8.0' ] + symfony: [ '5.3' ] + composer-flags: [ '', '--prefer-lowest', '--prefer-stable'] + env: + SYMFONY_REQUIRE: ${{ matrix.symfony }}.* + steps: + - name: "checkout" + uses: "actions/checkout@v2" + + - name: "build the environment" + run: "dev/bin/docker-compose build --build-arg PHP_VERSION=${{ matrix.php }} php" + + - name: "install dependencies" + run: "dev/bin/php composer update --ansi ${{ matrix.composer-flags }}" + + - name: "running unit tests" + run: "dev/bin/php-test vendor/bin/simple-phpunit --colors=always" + + - name: Clear docker volumes + if: ${{ always() }} + run: dev/bin/docker-compose down --volumes diff --git a/composer.json b/composer.json index adad8d0f..f1c4f198 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=7.2", - "doctrine/doctrine-bundle": "^2.0", + "doctrine/doctrine-bundle": "^2.0.8", "doctrine/orm": "^2.7.1", "league/oauth2-server": "^8.0", "nyholm/psr7": "^1.4", diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index be939ee4..2e8ebc31 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -1,16 +1,8 @@ ARG PHP_VERSION=7.4 -FROM php:${PHP_VERSION}-cli-alpine3.14 +FROM php:${PHP_VERSION}-cli-alpine LABEL maintainer="Petar Obradović " -ARG COMPOSER_VERSION=2.1.9 -ARG FLEX_VERSION=1.17.1 -ARG PHP_CS_FIXER_VERSION=3.2.1 -ARG XDEBUG_VERSION=3.1.1 -ARG PSALM_VERSION=4.11.2 - -ENV XDEBUG_START_WITH_REQUEST 0 - # This is where we're going to store all of our non-project specific binaries RUN mkdir -p /app/bin ENV PATH /app/bin:$PATH @@ -25,13 +17,15 @@ RUN apk add --update --no-cache --virtual .build-deps \ xml \ zip \ && pecl install \ - xdebug-${XDEBUG_VERSION} \ + xdebug \ && docker-php-ext-enable \ xdebug \ && apk del --purge .build-deps RUN mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini +ENV XDEBUG_START_WITH_REQUEST 0 + RUN echo '[xdebug]' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \ && echo 'xdebug.start_with_request = ${XDEBUG_START_WITH_REQUEST}' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \ && echo 'xdebug.mode = debug' >> ${PHP_INI_DIR}/conf.d/docker-php-ext-xdebug.ini \ @@ -47,26 +41,25 @@ RUN apk add --update --no-cache \ shadow # Composer -RUN curl --show-error https://getcomposer.org/installer | php -- \ - --install-dir=/app/bin \ - --filename=composer \ - --version=${COMPOSER_VERSION} +RUN curl --location --output /app/bin/composer --show-error \ + https://github.com/composer/composer/releases/latest/download/composer.phar \ + && chmod a+x /app/bin/composer # PHP-CS-Fixer RUN curl --location --output /app/bin/php-cs-fixer --show-error \ - https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v${PHP_CS_FIXER_VERSION}/php-cs-fixer.phar \ + https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar \ && chmod a+x /app/bin/php-cs-fixer # Psalm RUN curl --location --output /app/bin/psalm --show-error \ - https://github.com/vimeo/psalm/releases/download/${PSALM_VERSION}/psalm.phar \ + https://github.com/vimeo/psalm/releases/latest/download/psalm.phar \ && chmod a+x /app/bin/psalm # Create the user that's going to run our application RUN useradd -ms /bin/sh app # Enable parallel package installation for Composer -RUN su-exec app composer global require symfony/flex:${FLEX_VERSION} +RUN su-exec app composer global require symfony/flex COPY entrypoint.sh /usr/local/bin/docker-entrypoint