Modernise CI: PHPCS + PHPStan + PHP 8.0-8.3 matrix #2
Workflow file for this run
This file contains hidden or 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
| # WPUM Core CI Pipeline | |
| # Copy this to wp-user-manager/.github/workflows/ci.yml | |
| # | |
| # Runs on PRs touching PHP files. Matrix tests across PHP 8.0-8.3. | |
| # PHPCS + PHPStan run once on PHP 8.2. Tests run on all PHP versions. | |
| name: CI | |
| on: | |
| pull_request: | |
| paths: | |
| - "**.php" | |
| - "composer.json" | |
| - "composer.lock" | |
| - "phpcs.xml.dist" | |
| - "phpstan.neon.dist" | |
| - ".github/workflows/ci.yml" | |
| push: | |
| branches: | |
| - master | |
| - develop | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| phpcs: | |
| name: PHPCS | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: "8.2" | |
| coverage: none | |
| tools: cs2pr | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer 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 | |
| run: composer update --prefer-dist --no-progress | |
| - name: Detect coding standard violations | |
| run: vendor/bin/phpcs -q --report=checkstyle | cs2pr --graceful-warnings | |
| phpstan: | |
| name: PHPStan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: "8.2" | |
| coverage: none | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer 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 | |
| run: composer update --prefer-dist --no-progress | |
| - name: Run PHPStan | |
| run: vendor/bin/phpstan analyse --no-progress --error-format=github | |
| php-compatibility: | |
| name: PHP ${{ matrix.php }} Compatibility | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ["8.0", "8.1", "8.2", "8.3"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| coverage: none | |
| - name: Install dependencies | |
| run: composer update --prefer-dist --no-progress | |
| - name: Check for fatal errors | |
| run: | | |
| php -l wp-user-manager.php | |
| find includes/ -name "*.php" -print0 | xargs -0 -n1 php -l 2>&1 | { grep -v "No syntax errors" || true; } | { ! grep -q "Parse error"; } | |
| # Uncomment when Codeception tests are added: | |
| # | |
| # tests: | |
| # name: Tests (PHP ${{ matrix.php }}) | |
| # runs-on: ubuntu-latest | |
| # strategy: | |
| # fail-fast: false | |
| # matrix: | |
| # php: ["8.0", "8.2"] | |
| # services: | |
| # mysql: | |
| # image: mysql:8.0 | |
| # env: | |
| # MYSQL_ROOT_PASSWORD: root | |
| # MYSQL_DATABASE: wordpress_test | |
| # ports: | |
| # - 3306:3306 | |
| # options: >- | |
| # --health-cmd="mysqladmin ping" | |
| # --health-interval=10s | |
| # --health-timeout=5s | |
| # --health-retries=3 | |
| # steps: | |
| # - name: Checkout | |
| # uses: actions/checkout@v4 | |
| # | |
| # - name: Setup PHP | |
| # uses: shivammathur/setup-php@v2 | |
| # with: | |
| # php-version: ${{ matrix.php }} | |
| # extensions: mysqli | |
| # coverage: none | |
| # | |
| # - name: Install dependencies | |
| # run: composer install --prefer-dist --no-progress --no-suggest | |
| # | |
| # - name: Install WordPress test suite | |
| # run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest | |
| # | |
| # - name: Run Codeception tests | |
| # run: vendor/bin/codecept run |