diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..91becc0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +.gitattributes export-ignore +.gitignore export-ignore +.github export-ignore +phpstan.neon export-ignore diff --git a/.github/workflows/code-analysis.yaml b/.github/workflows/code-analysis.yaml new file mode 100644 index 0000000..0f758a8 --- /dev/null +++ b/.github/workflows/code-analysis.yaml @@ -0,0 +1,54 @@ +name: Code analysis + +on: + push: + pull_request: + +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + static-analysis: + strategy: + fail-fast: false + matrix: + php: + - "7.2" + - "7.3" + - "7.4" + - "8.0" + - "8.1" + - "8.2" + - "8.3" + name: PHPStan at PHP ${{ matrix.php }} + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Get Composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer update --no-progress + + - name: Statically analyze code (PHPStan) + run: composer run phpstan -- --ansi diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml deleted file mode 100644 index a43e1e2..0000000 --- a/.github/workflows/code_analysis.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: Code Analysis - -on: - pull_request: - push: - branches: - - master - -jobs: - code_analysis: - strategy: - fail-fast: false - matrix: - actions: - - name: PHPStan - run: composer phpstan - - php: - - name: PHP 7.3 - version: 7.3 - - - name: PHP 7.4 - version: 7.4 - - - name: PHP 8.0 - version: 8.0 - - name: ${{ matrix.actions.name }} on ${{ matrix.php.name }} - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - # see https://github.com/shivammathur/setup-php - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php.version }} - coverage: none - - - # see https://github.com/actions/cache/blob/main/examples.md#php---composer - - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" - - uses: actions/cache@v2 - with: - path: | - ${{ steps.composer-cache.outputs.dir }} - **/composer.lock - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - ${{ runner.os }}-composer- - - - - name: Install Composer - run: composer install --no-progress - - - run: ${{ matrix.actions.run }} diff --git a/composer.json b/composer.json index 1ecd812..f41f89d 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "jakubboucek/esc-pos", "description": "Native ESC-POS drivers", - "type": "library", "license": "MIT", + "type": "library", "authors": [ { "name": "Jakub Bouček", @@ -11,18 +11,20 @@ ], "require": { "php": ">=7.2", - "composer-runtime-api": "^2.0", - "ext-sockets": "*", - "ext-iconv": "*" + "ext-iconv": "*", + "ext-sockets": "*" }, "require-dev": { - "phpstan/phpstan": "^0.12.89" + "phpstan/phpstan": "^1.10" }, "autoload": { "psr-4": { "JakubBoucek\\EscPos\\": "src/" } }, + "config": { + "sort-packages": true + }, "scripts": { "phpstan": "phpstan analyze src -c phpstan.neon --level 6" }