From 8264c14ffca2511da506eed392ea80f35008d534 Mon Sep 17 00:00:00 2001 From: Peter-Paul van Gemerden Date: Wed, 26 Feb 2025 15:37:13 +0100 Subject: [PATCH] ci: split workflow --- .github/actions/setup/action.yml | 35 +++++++++++++++++++ .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 40 ---------------------- phpstan.neon | 1 - 4 files changed, 94 insertions(+), 41 deletions(-) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..053c54d --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,35 @@ +name: Setup +description: "Setup PHP and composer and install dependencies" + +inputs: + php-version: + default: "8.3" + coverage: + default: xdebug + composer-flags: + default: "" + +runs: + using: "composite" + steps: + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ inputs.php-version }} + coverage: ${{ inputs.coverage }} + + - name: Get composer cache directory + id: composer-cache + shell: bash + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache 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 + shell: bash + run: composer update --prefer-dist --no-interaction ${{ inputs.composer-flags }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4f6c488 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + phpcs: + runs-on: ubuntu-24.04 + name: PHPCS + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup + uses: ./.github/actions/setup + with: + coverage: none + + - name: Run PHPCS + run: vendor/bin/phpcs + + phpstan: + runs-on: ubuntu-24.04 + name: PHPStan + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup + uses: ./.github/actions/setup + with: + coverage: none + + - name: Run PHPStan + run: vendor/bin/phpstan analyse + + test: + runs-on: ubuntu-24.04 + strategy: + max-parallel: 3 + matrix: + php-version: [ 8.2, 8.3 ] + composer-flags: [ "", "--prefer-lowest" ] + name: Test on PHP ${{ matrix.php-version }} ${{ matrix.composer-flags }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup + uses: ./.github/actions/setup + with: + php-version: ${{ matrix.php-version }} + composer-flags: ${{ matrix.composer-flags }} + + - name: Run tests (Unit and Feature) + run: vendor/bin/phpunit --coverage-text diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index cd32a84..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Continuous integration - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - tests: - runs-on: ubuntu-22.04 - strategy: - max-parallel: 3 - matrix: - php: [ 8.2, 8.3 ] - composer_flags: [ "", "--prefer-lowest" ] - name: PHP ${{ matrix.php }} ${{ matrix.composer_flags}} - env: - PHP: ${{ matrix.os }} - COMPOSER_MEMORY_LIMIT: -1 - COMPOSER_FLAGS: ${{ matrix.composer_flags }} - PHP_VERSION: ${{ matrix.php }} - steps: - - uses: actions/checkout@v2 - - name: Install PHP - uses: shivammathur/setup-php@master - with: - php-version: ${{ matrix.php }} - extensions: xdebug - - name: Install dependencies - run: | - composer self-update - COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-dist --no-interaction $COMPOSER_FLAGS - composer require doctrine/dbal - - name: Execute tests (Unit and Feature) - run: vendor/bin/phpunit --coverage-text - - name: Static analysis with PHPStan - run: vendor/bin/phpstan analyse - - name: Coding style PSR12 Check - run: vendor/bin/phpcs diff --git a/phpstan.neon b/phpstan.neon index b4a5b25..9bd72ef 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,5 +3,4 @@ parameters: - src level: 8 inferPrivatePropertyTypeFromConstructor: true - checkMissingIterableValueType: false reportUnmatchedIgnoredErrors: false