From ce6badfdcc822034ff3af7f2cdd07630e3d96b52 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 10 Oct 2022 16:52:27 +0200 Subject: [PATCH] Streamlined CI setup with `laminas/laminas-ci-matrix-action` --- .github/workflows/coding-standards.yml | 59 -------- .github/workflows/continuous-integration.yml | 143 +++++++++++++++++++ .github/workflows/mutation-tests.yml | 65 --------- .github/workflows/phpunit.yml | 74 ---------- .github/workflows/psalm.yml | 61 -------- 5 files changed, 143 insertions(+), 259 deletions(-) delete mode 100644 .github/workflows/coding-standards.yml create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .github/workflows/mutation-tests.yml delete mode 100644 .github/workflows/phpunit.yml delete mode 100644 .github/workflows/psalm.yml diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml deleted file mode 100644 index 7e400e44..00000000 --- a/.github/workflows/coding-standards.yml +++ /dev/null @@ -1,59 +0,0 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions - -name: "Check Coding Standards" - -on: - pull_request: - push: - -jobs: - coding-standards: - name: "Check Coding Standards" - - runs-on: ${{ matrix.operating-system }} - - strategy: - matrix: - dependencies: - - "locked" - php-version: - - "8.0" - operating-system: - - "ubuntu-latest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - # Many tools rely on this tool staying as `1.x`, therefore we check out the current workdir as - # a compatible branch name - - name: "Switch active branch to 1.99.x" - run: git checkout -b 1.99.x || true - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "pcov" - php-version: "${{ matrix.php-version }}" - ini-values: memory_limit=-1 - tools: composer:v2 - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: | - ~/.composer/cache - vendor - key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - - - name: "Install highest dependencies" - if: ${{ matrix.dependencies == 'highest' }} - run: "composer update --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "Install locked dependencies" - if: ${{ matrix.dependencies == 'locked' }} - run: "composer install --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "Coding Standard" - run: "vendor/bin/phpcs" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 00000000..e63542b2 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,143 @@ +# See https://github.com/laminas/laminas-continuous-integration-action +# Generates a job matrix based on current dependencies and supported version +# ranges, then runs all those jobs +name: "Continuous Integration" + +on: + pull_request: + push: + +jobs: + matrix: + name: Generate job matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + steps: + - name: Gather CI configuration + id: matrix + uses: laminas/laminas-ci-matrix-action@1.18.0 + + qa: + name: QA Checks + needs: [ matrix ] + runs-on: ${{ matrix.operatingSystem }} + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }} + steps: + - name: ${{ matrix.name }} + uses: laminas/laminas-continuous-integration-action@1.26.0 + env: + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "INFECTION_DASHBOARD_API_KEY": ${{ secrets.INFECTION_DASHBOARD_API_KEY }} + "STRYKER_DASHBOARD_API_KEY": ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + with: + job: ${{ matrix.job }} + + check-backwards-compatibility: + name: "Check Backwards Compatibility" + + runs-on: ${{ matrix.operating-system }} + + strategy: + matrix: + dependencies: + - "locked" + php-version: + - "8.1" + - "8.2" + operating-system: + - "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v3" + with: + fetch-depth: 0 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + tools: composer:v2 + + - name: "Cache dependencies" + uses: "actions/cache@v3" + with: + path: | + ~/.composer/cache + vendor + key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" + restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" + + - name: "Install lowest dependencies" + if: ${{ matrix.dependencies == 'lowest' }} + run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest" + + - name: "Install highest dependencies" + if: ${{ matrix.dependencies == 'highest' }} + run: "composer update --no-interaction --no-progress --no-suggest" + + - name: "Install locked dependencies" + if: ${{ matrix.dependencies == 'locked' }} + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Roave Backward Compatibility Check" + run: "bin/roave-backward-compatibility-check --format=github-actions" + + check-composer-dependencies: + name: "Composer Require Checker" + + runs-on: ${{ matrix.operating-system }} + + strategy: + matrix: + dependencies: + - "locked" + php-version: + - "8.1" + - "8.2" + operating-system: + - "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v3" + with: + fetch-depth: 0 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + tools: composer:v2 + + - name: "Cache dependencies" + uses: "actions/cache@v3" + with: + path: | + ~/.composer/cache + vendor + key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" + restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" + + - name: "Install lowest dependencies" + if: ${{ matrix.dependencies == 'lowest' }} + run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest --no-dev" + + - name: "Install highest dependencies" + if: ${{ matrix.dependencies == 'highest' }} + run: "composer update --no-interaction --no-progress --no-suggest --no-dev" + + - name: "Install locked dependencies" + if: ${{ matrix.dependencies == 'locked' }} + run: "composer install --no-interaction --no-progress --no-suggest --no-dev" + + - name: "Install ComposerRequireChecker" + run: "wget https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar" + + - name: "Run ComposerRequireChecker" + run: "php composer-require-checker.phar check composer.json" diff --git a/.github/workflows/mutation-tests.yml b/.github/workflows/mutation-tests.yml deleted file mode 100644 index 76503b35..00000000 --- a/.github/workflows/mutation-tests.yml +++ /dev/null @@ -1,65 +0,0 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions - -name: "Mutation tests" - -on: - pull_request: - push: - branches: - - "master" - -jobs: - mutation-tests: - name: "Mutation tests" - - runs-on: ${{ matrix.operating-system }} - - strategy: - matrix: - dependencies: - - "locked" - php-version: - - "8.0" - operating-system: - - "ubuntu-latest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - # Many tools rely on this tool staying as `1.x`, therefore we check out the current workdir as - # a compatible branch name - - name: "Switch active branch to 1.99.x" - run: git checkout -b 1.99.x || true - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "pcov" - php-version: "${{ matrix.php-version }}" - ini-values: memory_limit=-1 - tools: composer:v2 - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: | - ~/.composer/cache - vendor - key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - - - name: "Install highest dependencies" - if: ${{ matrix.dependencies == 'highest' }} - run: "composer update --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "Install locked dependencies" - if: ${{ matrix.dependencies == 'locked' }} - run: "composer install --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "Infection" - run: "vendor/bin/roave-infection-static-analysis-plugin" - env: - INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }} - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml deleted file mode 100644 index 9b390572..00000000 --- a/.github/workflows/phpunit.yml +++ /dev/null @@ -1,74 +0,0 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions - -name: "PHPUnit tests" - -on: - pull_request: - push: - branches: - - "master" - -jobs: - phpunit: - name: "PHPUnit tests" - - runs-on: ${{ matrix.operating-system }} - - strategy: - matrix: - dependencies: - - "highest" - - "locked" - - "classmap-authoritative" - - "no-scripts" - php-version: - - "8.0" - - "8.1" - - "8.2" - operating-system: - - "ubuntu-latest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - # Many tools rely on this tool staying as `1.x`, therefore we check out the current workdir as - # a compatible branch name - - name: "Switch active branch to 1.99.x" - run: git checkout -b 1.99.x || true - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "pcov" - php-version: "${{ matrix.php-version }}" - ini-values: memory_limit=-1 - tools: composer:v2 - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: | - ~/.composer/cache - vendor - key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - - - name: "Install highest dependencies" - if: ${{ matrix.dependencies == 'highest' }} - run: "composer update --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "Install locked dependencies" - if: ${{ matrix.dependencies == 'locked' }} - run: "composer install --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "Install with classmap authoritative flag" - if: ${{ matrix.dependencies == 'classmap-authoritative' }} - run: "composer install --no-interaction --classmap-authoritative --ignore-platform-req=php" - - - name: "Install without scripts" - if: ${{ matrix.dependencies == 'no-scripts' }} - run: "composer install --no-interaction --no-scripts --ignore-platform-req=php" - - - name: "Tests" - run: "vendor/bin/phpunit" diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml deleted file mode 100644 index 268a6318..00000000 --- a/.github/workflows/psalm.yml +++ /dev/null @@ -1,61 +0,0 @@ -# https://help.github.com/en/categories/automating-your-workflow-with-github-actions - -name: "Static Analysis by Psalm" - -on: - pull_request: - push: - branches: - - "master" - -jobs: - static-analysis-psalm: - name: "Static Analysis by Psalm" - - runs-on: ${{ matrix.operating-system }} - - strategy: - matrix: - dependencies: - - "locked" - php-version: - - "8.0" - operating-system: - - "ubuntu-latest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v3" - - # Many tools rely on this tool staying as `1.x`, therefore we check out the current workdir as - # a compatible branch name - - name: "Switch active branch to 1.99.x" - run: git checkout -b 1.99.x || true - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "pcov" - php-version: "${{ matrix.php-version }}" - ini-values: memory_limit=-1 - tools: composer:v2 - - - name: "Cache dependencies" - uses: "actions/cache@v3" - with: - path: | - ~/.composer/cache - vendor - key: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" - - - name: "Install highest dependencies" - if: ${{ matrix.dependencies == 'highest' }} - run: "composer update --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "Install locked dependencies" - if: ${{ matrix.dependencies == 'locked' }} - run: "composer install --no-interaction --no-progress --no-suggest --ignore-platform-req=php" - - - name: "psalm" - run: "vendor/bin/psalm --shepherd --stats"