Skip to content

chore(tooling): add PHPStan level 5 to dev tooling + CI #127

chore(tooling): add PHPStan level 5 to dev tooling + CI

chore(tooling): add PHPStan level 5 to dev tooling + CI #127

Workflow file for this run

name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
SLIC_BIN: ${{ github.workspace }}/slic/slic
jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer
- name: Install dependencies
run: |
composer install --no-interaction --prefer-dist --no-scripts
mkdir -p vendor/prefixed && echo '<?php' > vendor/prefixed/autoload.php
env:
COMPOSER_NO_AUDIT: 1
- name: Configure PHPCS standards
run: vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility,vendor/phpcompatibility/phpcompatibility-paragonie,vendor/phpcompatibility/phpcompatibility-wp,vendor/phpcsstandards/phpcsextra,vendor/phpcsstandards/phpcsutils,vendor/wp-coding-standards/wpcs
- name: Run PHPCS
run: vendor/bin/phpcs
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer
coverage: none
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Setup bun
uses: oven-sh/setup-bun@v2
# Composer install MUST run scripts here (unlike the PHPCS job above)
# so Strauss generates the prefixed `WorkOS\Vendor\…` classes that
# PHPStan needs to resolve types.
- name: Install PHP dependencies (with Strauss)
run: composer install --no-interaction --prefer-dist
env:
COMPOSER_NO_AUDIT: 1
# Build the JS bundles so the `build/*.asset.php` files exist —
# PHPStan statically resolves the `include $asset_file` paths in
# Admin/Settings.php, UI/Controller.php, etc. and would otherwise
# fail with `path.notExists` even though every callsite is guarded
# by `file_exists()`.
- name: Install JS dependencies + build
run: |
bun install --frozen-lockfile
bun run build
- name: Run PHPStan
run: composer phpstan -- --no-progress --error-format=github
tests-php:
name: PHP Tests (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]
steps:
- uses: actions/checkout@v6
- name: Checkout slic
uses: actions/checkout@v6
with:
repository: stellarwp/slic
ref: main
path: slic
fetch-depth: 1
- name: Start ssh-agent
run: |
mkdir -p "${HOME}/.ssh"
ssh-agent -a /tmp/ssh_agent.sock
- name: Export SSH_AUTH_SOCK
run: echo "SSH_AUTH_SOCK=/tmp/ssh_agent.sock" >> $GITHUB_ENV
- name: Set up slic env vars
run: |
echo "SLIC_WP_DIR=${GITHUB_WORKSPACE}/slic/_wordpress" >> $GITHUB_ENV
echo "SLIC_WORDPRESS_DOCKERFILE=Dockerfile.base" >> $GITHUB_ENV
- name: Set run context
run: echo "SLIC=1" >> $GITHUB_ENV && echo "CI=1" >> $GITHUB_ENV
- name: Set up slic for CI
run: |
cd ${GITHUB_WORKSPACE}/..
${SLIC_BIN} here
${SLIC_BIN} interactive off
${SLIC_BIN} build-prompt off
${SLIC_BIN} build-subdir off
${SLIC_BIN} xdebug off
${SLIC_BIN} debug on
${SLIC_BIN} info
${SLIC_BIN} config
- name: Set up plugin
run: |
${SLIC_BIN} use integration-workos
${SLIC_BIN} composer install
- name: Run wpunit tests
run: ${SLIC_BIN} run wpunit --ext DotReporter
js-build:
name: JS Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm install
- name: Verify build
run: echo "No JS build step configured yet."