From af6c3dc87f5588a3849bd027bdb8f52ffb231971 Mon Sep 17 00:00:00 2001 From: Ksaveras Sakys Date: Sun, 8 May 2022 16:16:28 +0100 Subject: [PATCH] Add GitHub actions, update phpstan rules --- .github/workflows/coding-standards.yaml | 39 ++++++++ .github/workflows/continuous-integration.yaml | 96 +++++++++++++++++++ .github/workflows/static-analysis.yaml | 39 ++++++++ phpstan.neon | 4 +- 4 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/coding-standards.yaml create mode 100644 .github/workflows/continuous-integration.yaml create mode 100644 .github/workflows/static-analysis.yaml diff --git a/.github/workflows/coding-standards.yaml b/.github/workflows/coding-standards.yaml new file mode 100644 index 0000000..554a64e --- /dev/null +++ b/.github/workflows/coding-standards.yaml @@ -0,0 +1,39 @@ +name: "Coding Standards" + +on: + pull_request: + branches: + - "master" + - "main" + + push: + branches: + - "master" + - "main" + - "*.x" + +jobs: + coding-standards: + name: "Coding Standards" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.4" + extensions: "redis" + tools: "composer:v2,cs2pr" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v2" + with: + composer-options: "--prefer-dist --optimize-autoloader" + + - name: "Check code style" + run: "./vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle | cs2pr" diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml new file mode 100644 index 0000000..c5e2502 --- /dev/null +++ b/.github/workflows/continuous-integration.yaml @@ -0,0 +1,96 @@ +name: "Continuous Integration" + +on: + pull_request: + branches: + - "master" + - "main" + + push: + branches: + - "master" + - "main" + - "*.x" + +jobs: + phpunit: + name: "PHPUnit" + runs-on: "ubuntu-latest" + + strategy: + fail-fast: false + matrix: + php-version: + - "7.4" + - "8.0" + - "8.1" + dependencies: + - "highest" + stability: + - "stable" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP with PCOV" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "pcov" + ini-values: "zend.assertions=1, apc.enable_cli=1" + extensions: "redis,apcu" + tools: "composer:v2,flex" + + - name: "Enforce using stable dependencies" + run: "composer config minimum-stability stable" + if: "${{ matrix.stability == 'stable' }}" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "--prefer-dist --optimize-autoloader" + + - name: "Run PHPUnit" + run: "./vendor/bin/phpunit" + +# - name: "Upload coverage file" +# uses: "actions/upload-artifact@v2" +# with: +# name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}.coverage" +# path: "clover.xml" + +# upload_coverage: +# name: "Upload coverage to Codecov" +# runs-on: "ubuntu-latest" +# needs: +# - "phpunit" +# +# steps: +# - name: "Checkout" +# uses: "actions/checkout@v2" +# with: +# fetch-depth: 2 +# +# - name: "Download coverage files" +# uses: "actions/download-artifact@v2" +# with: +# path: "reports" +# +# - name: "Upload to Codecov" +# uses: "codecov/codecov-action@v1" +# env: +# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} +# with: +# directory: reports +# +# - name: "Upload to CodeClimate" +# uses: "paambaati/codeclimate-action@v3.0.0" +# env: +# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} +# with: +# coverageLocations: | +# ${{github.workspace}}/reports/*/clover.xml:clover diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml new file mode 100644 index 0000000..76c20d0 --- /dev/null +++ b/.github/workflows/static-analysis.yaml @@ -0,0 +1,39 @@ +name: "Static Analysis" + +on: + pull_request: + branches: + - "master" + - "main" + + push: + branches: + - "master" + - "main" + - "*.x" + +jobs: + static-analysis: + name: "Static Analysis" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.4" + extensions: "redis" + tools: "composer:v2" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v2" + with: + composer-options: "--prefer-dist --optimize-autoloader" + + - name: "Run PHPStan" + run: "./vendor/bin/phpstan analyse --error-format=github" diff --git a/phpstan.neon b/phpstan.neon index 23d6468..62477bd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,8 +8,8 @@ parameters: - DependencyInjection/Configuration.php ignoreErrors: - - message: '#::loadInternal\(\) has no return typehint specified#' - path: 'DependencyInjection/CircuitBreakerExtension.php' + message: '#::loadInternal\(\) has no return type specified\.#' + path: 'DependencyInjection/KsaverasCircuitBreakerExtension.php' includes: - vendor/phpstan/phpstan-phpunit/extension.neon