Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/code-complexity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Analyze code complexity
permissions:
contents: read
on:
workflow_call:

env:
DEV_SCRIPTS_DIR: ${{ github.workspace }}/vendor/publishpress/dev-workspace/scripts

jobs:
check:
name: Run code complexity analysis
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
# actions/checkout@v6.0.2
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Set up PHP
# shivammathur/setup-php@2.37.0
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f
with:
php-version: 8.3
extensions: mbstring,xml,curl,zip,intl,bcmath,gettext,mysqli,phar,gd,iconv,yaml
tools: composer:v2

- name: Create root .env file
run: cp $GITHUB_WORKSPACE/.env.example $GITHUB_WORKSPACE/.env

- name: Validate Composer configuration
run: composer validate --strict

- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --no-progress

- name: Show dev-workspace tool versions
run: composer info:version

- name: Add dev-workspace scripts to PATH
run: echo "$DEV_SCRIPTS_DIR" >> "$GITHUB_PATH"

- name: Run code complexity analysis
run: vendor/publishpress/dev-workspace/scripts/run.sh phpmd . text phpmd.ruleset.xml --exclude vendor,lib/vendor,tests,dist,.claude,.cursor,.github,.wordpress-org,.git,.zed,docs,languages
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Reusable GitHub Actions workflows for PublishPress plugin repositories.

- `.github/workflows/unit-tests.yml`: Runs PHPUnit tests.
- `.github/workflows/code-standards.yml`: Runs PHP compatibility and lint checks.
- `.github/workflows/code-complexity.yml`: Runs PHP code complexity analysis with PHPMD.
- `.github/workflows/deploy-free.yml`: Builds and deploys free plugin releases to WordPress.org and uploads release assets to GitHub.
- `.github/workflows/deploy-free-assets.yml`: Updates WordPress.org plugin assets/readme.
- `.github/workflows/deploy-pro.yml`: Builds pro plugin packages and uploads release assets to GitHub.
Expand Down Expand Up @@ -54,6 +55,25 @@ jobs:
uses: publishpress/github-workflows/.github/workflows/code-check.yml@<commit-sha>
```

### Code complexity example

```yaml
name: Code Complexity

on:
pull_request:
branches: [ master, development ]
push:
branches: [ master, development ]

permissions:
contents: read

jobs:
code_complexity:
uses: publishpress/github-workflows/.github/workflows/code-complexity.yml@<commit-sha>
```

### Deploy free plugin example

```yaml
Expand Down