diff --git a/.github/linters/.hadolint.yaml b/.github/linters/.hadolint.yaml new file mode 100644 index 0000000..72c73ca --- /dev/null +++ b/.github/linters/.hadolint.yaml @@ -0,0 +1,5 @@ +ignored: + - DL3003 + - DL3008 + - DL3059 + - DL4006 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fd6f66..bfee7a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,8 @@ jobs: strategy: matrix: - php: ['7.1', '7.2', '7.3', '7.4', '8.0'] - prefer: ['lowest', 'stable'] + php: [ '7.1', '7.2', '7.3', '7.4', '8.0' ] + prefer: [ 'lowest', 'stable' ] name: Test on PHP ${{ matrix.php }} with ${{ matrix.prefer }} composer prefer option runs-on: ubuntu-latest @@ -62,4 +62,4 @@ jobs: env: FILTER_REGEX_EXCLUDE: .*vendor.* GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VALIDATE_PHP_PSALM: false \ No newline at end of file + VALIDATE_PHP_PSALM: false diff --git a/.gitignore b/.gitignore index 224d9f2..f73589d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ +/.idea/ /.phpunit.result.cache +/_coverage/ /composer.lock /phpunit.xml /vendor/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c2e56b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM php:7.1 + +# Enable phpdebug +RUN apt-get update \ + && apt-get install -y --no-install-recommends libxml2-dev \ + && rm -rf /var/lib/apt/lists/* \ + && docker-php-source extract \ + && cd /usr/src/php \ + && ./configure --enable-phpdbg \ + && docker-php-source delete + +# Install composer and required packages +RUN apt-get update \ + && apt-get install -y --no-install-recommends unzip \ + && rm -rf /var/lib/apt/lists/* + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +WORKDIR /app diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a3eb9e3 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +## Add dockerized commands to path +PATH := $(PATH):tools + +docker-build: + docker build -t timeweb/phpstan-enum . + +install: + composer install + +test: + php vendor/bin/phpunit + +test-coverage: + phpdbg -qrr vendor/bin/phpunit -d memory_limit=512m --coverage-html=_coverage --coverage-text diff --git a/README.md b/README.md index 6382d8e..7c5ac98 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,24 @@ And include extension.neon in your project's PHPStan config includes: - vendor/timeweb/phpstan-enum/extension.neon ``` + +## Install for Local Development + +### With docker + +```bash +git clone git@github.com:timeweb/phpstan-enum.git +cd phpstan-enum +make docker-build +make install +make phpunit +``` + +### Without docker (localy installed actual version of php, composer, etc) + +```bash +git clone git@github.com:timeweb/phpstan-enum.git +cd phpstan-enum +make install +make phpunit +``` diff --git a/tools/composer b/tools/composer new file mode 100755 index 0000000..7de0507 --- /dev/null +++ b/tools/composer @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +mkdir -p "$HOME/.composer/cache/" + +test -t 1 && USE_TTY="--tty" + +docker run --rm --interactive ${USE_TTY} \ + --user $UID:$UID \ + --volume "$PWD":/app \ + --volume "$HOME/.composer":/tmp/.composer \ + --env COMPOSER_HOME=/tmp/.composer \ + timeweb/phpstan-enum composer "$@" diff --git a/tools/php b/tools/php new file mode 100755 index 0000000..93d6d5d --- /dev/null +++ b/tools/php @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +test -t 1 && USE_TTY="--tty" + +docker run --rm --init --interactive ${USE_TTY} \ + --user $UID:$UID \ + --volume "$PWD:/app" \ + timeweb/phpstan-enum php "$@" diff --git a/tools/phpdbg b/tools/phpdbg new file mode 100755 index 0000000..856cc80 --- /dev/null +++ b/tools/phpdbg @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +test -t 1 && USE_TTY="--tty" + +docker run --rm --init --interactive ${USE_TTY} \ + --user $UID:$UID \ + --volume "$PWD:/app" \ + timeweb/phpstan-enum phpdbg "$@"