diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100755 index 0000000..60afeaa --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,15 @@ +FROM php:8.4-cli-alpine + +COPY php.ini /usr/local/etc/php/php.ini + +RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ + && apk add --no-cache linux-headers + +RUN pecl install xdebug \ + && docker-php-ext-enable xdebug + +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer + +WORKDIR /app + +COPY . /app diff --git a/.docker/php.ini b/.docker/php.ini new file mode 100644 index 0000000..6f2ba38 --- /dev/null +++ b/.docker/php.ini @@ -0,0 +1 @@ +xdebug.mode=develop,debug,coverage diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000..950f21e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,35 @@ +name: Bug report +description: | + Something didn't work as expected? Create a report to help us improve. +labels: [ "bug", "triage" ] +assignees: [ ] +body: + - type: markdown + attributes: + value: | + Example description + - type: input + id: pkg_version + attributes: + label: Package name version + description: Run `composer show -v | grep package/name`. + placeholder: "example: 1.0.0" + validations: + required: true + - type: input + id: php_version + attributes: + label: PHP version + description: Run `php -v`. + placeholder: "example: 8.4" + validations: + required: true + - type: textarea + id: what-happened + attributes: + label: What happened? + description: | + Example description + placeholder: I ran `php artisan migration:fresh` on prod, and then... + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..c294bf4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,24 @@ +name: Question +description: Ask or suggest something. +labels: ["question", "triage"] +assignees: [] +body: + - type: markdown + attributes: + value: | + Example description + - type: input + id: pkg_version + attributes: + label: Package name version + description: Run `composer show -v | grep package/name`. + placeholder: "example: 1.0.0" + validations: + required: true + - type: textarea + id: question + attributes: + label: Your question + placeholder: + validations: + required: true diff --git a/.github/workflows/code-standart.yml b/.github/workflows/code-standart.yml deleted file mode 100644 index ce5bd95..0000000 --- a/.github/workflows/code-standart.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: CODE CHECK - TESTS - -on: ['push', 'pull_request'] - -jobs: - coding-standard: - name: Coding Standard - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.4' - coverage: none - - - name: Get composer cache directory - id: composer-cache - run: | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --no-progress --no-suggest --prefer-dist --no-interaction - - - name: Check coding style - run: composer cs-check - - - name: Run tests - run: composer tests diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..af876c8 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: LINT + +on: ['push'] + +jobs: + coding-standard: + name: Coding Standard + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup PHP 8.4 + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + coverage: none + extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, intl, gd + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + + - name: Install dependencies + run: composer install + + - name: Run lint code + run: composer lint diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..20e1dd1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,34 @@ +name: TESTS + +on: ['push'] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: + - '8.4' + - '8.3' + - '8.2' + + name: Tests (PHP ${{ matrix.php }} - ${{ matrix.deps }}) + + steps: + - uses: actions/checkout@v3 + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: xdebug + + - name: Install dependencies + run: composer update + + - name: Test code + run: composer tests + + - name: Test coverage + run: composer tests-coverage diff --git a/Dockerfile b/Dockerfile deleted file mode 100755 index 10bb7b7..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM php:8.4-cli-alpine - -WORKDIR /app - -COPY . /app - -COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer \ No newline at end of file diff --git a/README.md b/README.md index b0ee042..6a4a7dc 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ This repository is designed to give you a template with which you can create your own packages. -GitHub Workflow Status +GitHub Workflow Status +GitHub Workflow Status Total Downloads Latest Version License @@ -31,9 +32,12 @@ make init ## What do you get * Ready-made template project using the latest version of PHP -* Tests using pest +* Tests/Test Coverage using pest * Static analyzers: phpstan/rector/phpcs * Ready-made environment using docker +* Xdebug mod +* GitHub actions for lint/tests +* Issue Template for bug/question I would be glad to receive your **feedback** diff --git a/composer.json b/composer.json index fb28d4b..f1a289a 100755 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^8.4.0" + "php": ">=8.1" }, "autoload": { "psr-4": { @@ -25,8 +25,9 @@ }, "minimum-stability": "stable", "scripts": { - "tests": "php ./vendor/bin/pest", - "cs-check": [ + "tests": "pest --stop-on-failure --colors", + "tests-coverage": "pest --coverage --min=90", + "lint": [ "@phpstan", "@cs", "@rector" diff --git a/docker-compose.yml b/docker-compose.yml index cf8392c..ec47ef0 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,8 @@ services: app: container_name: scribe-plugin build: - context: ./ + context: .docker volumes: - ./:/app tty: true - stdin_open: true \ No newline at end of file + stdin_open: true diff --git a/makefile b/makefile index afc4073..2860f47 100755 --- a/makefile +++ b/makefile @@ -9,18 +9,22 @@ up: build: docker compose up -d --build -# command for exec in container +# command for exec in app container exec: docker exec -it scribe-plugin /bin/sh -# command for install pkg +# command for install composer install: docker exec -i scribe-plugin composer install --dev -# command for run verify code -code-check: - docker exec -i scribe-plugin composer cs-check +# command for run lint code +lint: + docker exec -i scribe-plugin composer lint # command for run tests test: - docker exec -i scribe-plugin composer tests \ No newline at end of file + docker exec -i scribe-plugin composer tests + +# command for run tests coverage +test-coverage: + docker exec -i scribe-plugin composer tests diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e6198e0..ee6eaa4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,13 +5,12 @@ colors="true" > - - ./tests + + tests/Unit - app src