add support for PHPStan 2 #113
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://github.com/slevomat/coding-standard/blob/5730c4cdace33d2fb073b7d125dc64719f869d2b/.github/workflows/build.yml | |
name: "Build" | |
on: | |
pull_request: | |
push: | |
branches: | |
- "master" | |
jobs: | |
coding-standards: | |
name: "Coding standards" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
- name: "Install PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
coverage: "none" | |
php-version: "8.2" | |
- name: "Get composer cache directory" | |
id: "composer-cache" | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- 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 dependencies" | |
run: "composer update --prefer-dist --no-interaction --no-progress" | |
- name: "Coding Standard" | |
run: "make cs" | |
static-analysis: | |
name: "Static analysis" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
- name: "Install PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
coverage: "none" | |
php-version: "8.2" | |
- name: "Get composer cache directory" | |
id: "composer-cache" | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- 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 dependencies" | |
run: "composer update --prefer-dist --no-interaction --no-progress" | |
- name: "PHPStan" | |
run: "make phpstan" | |
tests: | |
name: "Tests" | |
runs-on: "ubuntu-latest" | |
strategy: | |
matrix: | |
dependencies: ["lowest", "highest"] | |
php-version: | |
- "8.1" | |
- "8.2" | |
- "8.3" | |
include: | |
# It seems that PHPStan doesn't specify its PHP version constraint sufficiently. So it still installs 1.10.36 | |
# on PHP 8.4, even though it doesn't work. | |
# TODO: include lowest as well once I bump minimum supported PHPStan. | |
- dependencies: highest | |
php-version: "8.4" | |
services: | |
mariadb: | |
image: "mariadb:10.11.5-jammy" | |
env: | |
MARIADB_ALLOW_EMPTY_PASSWORD: yes | |
MARIADB_DATABASE: "mariastan_test" | |
MARIADB_ROOT_PASSWORD: "root" | |
options: >- | |
--health-cmd "mysqladmin ping --silent" | |
ports: | |
- "3306:3306" | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
- name: "Install PHP" | |
uses: "shivammathur/setup-php@v2" | |
with: | |
coverage: "none" | |
php-version: "${{ matrix.php-version }}" | |
extensions: mysqli | |
- name: "Get composer cache directory" | |
id: "composer-cache" | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- 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 lowest dependencies" | |
if: ${{ matrix.dependencies == 'lowest' }} | |
run: "composer update --prefer-lowest --prefer-dist --no-interaction --no-progress" | |
- name: "Install highest dependencies" | |
if: ${{ matrix.dependencies == 'highest' }} | |
run: "composer update --prefer-dist --no-interaction --no-progress" | |
- name: "Tests" | |
run: "make tests" |