Skip to content

Commit 5a5a2a4

Browse files
authored
Merge pull request #104 from spacedmonkey/fix/php
Enhance PHP compatibility and structure for WP_REST_Blocks
2 parents bafb87a + aa5563b commit 5a5a2a4

36 files changed

+23416
-12193
lines changed

.distignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
.travis.yml
88
.DS_Store
99
.wordpress-org
10+
.wp-env.json
11+
.wp-env.override.json
12+
.wp-env-home
1013
composer.json
1114
composer.lock
1215
Thumbs.db
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: 'Setup PHP with Composer'
2+
description: 'Setup PHP environment with Composer cache and dependencies'
3+
4+
inputs:
5+
php-version:
6+
description: 'PHP version to use'
7+
required: false
8+
default: '7.4'
9+
composer-args:
10+
description: 'Additional arguments for composer install'
11+
required: false
12+
default: '--prefer-dist --no-progress --no-interaction'
13+
tools:
14+
description: 'Tools to install'
15+
required: false
16+
default: 'composer, cs2pr'
17+
coverage:
18+
description: 'Coverage driver'
19+
required: false
20+
default: 'none'
21+
extensions:
22+
description: 'PHP extensions to install'
23+
required: false
24+
default: ''
25+
26+
outputs:
27+
composer-cache-dir:
28+
description: 'Composer cache directory'
29+
value: ${{ steps.composer-cache.outputs.dir }}
30+
31+
runs:
32+
using: 'composite'
33+
steps:
34+
- name: Setup PHP
35+
uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ inputs.php-version }}
38+
coverage: ${{ inputs.coverage }}
39+
tools: ${{ inputs.tools }}
40+
extensions: ${{ inputs.extensions }}
41+
42+
- name: Get Composer cache directory
43+
id: composer-cache
44+
shell: bash
45+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
46+
47+
- name: Setup Composer cache
48+
uses: actions/cache@v4
49+
with:
50+
path: ${{ steps.composer-cache.outputs.dir }}
51+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
52+
restore-keys: |
53+
${{ runner.os }}-composer-
54+
${{ runner.os }}-
55+
56+
- name: Install dependencies
57+
shell: bash
58+
run: composer install ${{ inputs.composer-args }}
59+

.github/dependabot.yml

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
1-
# To get started with Dependabot version updates, you'll need to specify which
2-
# package ecosystems to update and where the package manifests are located.
3-
# Please see the documentation for all configuration options:
4-
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
1+
# Dependabot configuration for keeping GitHub Actions up to date
2+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates
53

64
version: 2
75
updates:
8-
- package-ecosystem: composer
9-
directory: '/'
10-
schedule:
11-
interval: weekly
12-
open-pull-requests-limit: 10
13-
labels:
14-
- Dependencies
15-
- PHP
16-
- package-ecosystem: npm
17-
directory: '/'
18-
schedule:
19-
interval: weekly
20-
open-pull-requests-limit: 15
21-
labels:
22-
- Dependencies
23-
- JavaScript
6+
# Monitor GitHub Actions versions
7+
- package-ecosystem: 'github-actions'
8+
directory: '/'
9+
schedule:
10+
interval: 'weekly'
11+
day: 'monday'
12+
open-pull-requests-limit: 10
13+
labels:
14+
- 'dependencies'
15+
- 'github-actions'
16+
commit-message:
17+
prefix: 'chore(deps)'
18+
include: 'scope'
19+
20+
# Monitor Composer dependencies
21+
- package-ecosystem: 'composer'
22+
directory: '/'
23+
schedule:
24+
interval: 'weekly'
25+
day: 'monday'
26+
open-pull-requests-limit: 10
27+
labels:
28+
- 'dependencies'
29+
- 'php'
30+
commit-message:
31+
prefix: 'chore(deps)'
32+
include: 'scope'
33+
34+
# Monitor npm dependencies
35+
- package-ecosystem: 'npm'
36+
directory: '/'
37+
schedule:
38+
interval: 'weekly'
39+
day: 'monday'
40+
open-pull-requests-limit: 10
41+
labels:
42+
- 'dependencies'
43+
- 'javascript'
44+
commit-message:
45+
prefix: 'chore(deps)'
46+
include: 'scope'
47+

.github/workflows/continuous-integration-lint-php.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,18 @@ on:
77
- release/*
88
pull_request:
99

10-
jobs:
11-
lint-php:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v2
16-
17-
- name: Setup PHP
18-
uses: shivammathur/setup-php@v2
19-
with:
20-
php-version: '7.4'
21-
coverage: none
22-
tools: composer, cs2pr
23-
24-
- name: Get Composer cache directory
25-
id: composer-cache
26-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
10+
# Cancel in-progress runs for the same workflow and branch/PR
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
2714

28-
- name: Setup Composer cache
29-
uses: pat-s/always-upload-cache@v2.1.3
30-
with:
31-
path: ${{ steps.composer-cache.outputs.dir }}
32-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
33-
restore-keys: |
34-
${{ runner.os }}-composer-
35-
${{ runner.os }}-
15+
permissions:
16+
contents: read
17+
pull-requests: write
3618

37-
- name: Validate composer.json
38-
run: composer --no-interaction validate --no-check-all
39-
40-
- name: Install dependencies
41-
run: composer install --prefer-dist --no-suggest --no-progress --no-interaction
19+
jobs:
20+
lint-php:
21+
uses: ./.github/workflows/reusable-php-lint.yml
22+
with:
23+
php-version: '7.4'
4224

43-
- name: Detect coding standard violations (PHPCS)
44-
run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings

.github/workflows/deploytowp.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,27 @@ on:
33
push:
44
tags:
55
- '**'
6+
7+
permissions:
8+
contents: read
9+
610
jobs:
711
tag:
812
name: New tag
913
runs-on: ubuntu-latest
1014
steps:
11-
- uses: actions/checkout@main
15+
- uses: actions/checkout@v4
1216

13-
- name: Setup PHP
14-
uses: shivammathur/setup-php@v2
17+
- name: Setup PHP with Composer
18+
uses: ./.github/actions/setup-php-composer
1519
with:
16-
php-version: '7.0'
17-
coverage: none
18-
tools: composer
20+
php-version: '7.4'
21+
composer-args: '--prefer-dist --no-progress --no-dev --optimize-autoloader --no-interaction'
22+
tools: 'composer'
1923

2024
- name: Validate composer.json and composer.lock
2125
run: composer validate
2226

23-
- name: Get Composer Cache Directory
24-
id: composer-cache
25-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
26-
27-
- name: Cache Composer vendor directory
28-
uses: actions/cache@v2
29-
with:
30-
path: ${{ steps.composer-cache.outputs.dir }}
31-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
32-
restore-keys: |
33-
${{ runner.os }}-composer-
34-
35-
- name: Install PHP Dependencies
36-
run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader --no-interaction
3727

3828
- name: WordPress Plugin Deploy
3929
uses: 10up/action-wordpress-plugin-deploy@stable
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Reusable PHP Lint
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
php-version:
7+
description: 'PHP version to use'
8+
type: string
9+
default: '7.4'
10+
run-phpcs:
11+
description: 'Run PHPCS checks'
12+
type: boolean
13+
default: true
14+
run-phpstan:
15+
description: 'Run PHPStan checks'
16+
type: boolean
17+
default: true
18+
run-phpmd:
19+
description: 'Run PHPMD checks'
20+
type: boolean
21+
default: true
22+
run-composer-normalize:
23+
description: 'Run composer normalize check'
24+
type: boolean
25+
default: true
26+
27+
permissions:
28+
contents: read
29+
pull-requests: write
30+
31+
jobs:
32+
lint:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Setup PHP with Composer
39+
uses: ./.github/actions/setup-php-composer
40+
with:
41+
php-version: ${{ inputs.php-version }}
42+
43+
- name: Validate composer.json
44+
run: composer --no-interaction validate --no-check-all
45+
46+
- name: Normalize composer.json
47+
if: ${{ inputs.run-composer-normalize }}
48+
run: composer normalize --no-interaction --dry-run
49+
50+
- name: Detect coding standard violations (PHPCS)
51+
if: ${{ inputs.run-phpcs }}
52+
run: composer lint -- -q --report=checkstyle --severity=1 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings
53+
54+
- name: Detect PHPStan issues
55+
if: ${{ inputs.run-phpstan }}
56+
run: composer phpstan -- --error-format=checkstyle | cs2pr --graceful-warnings
57+
58+
- name: Detect PHP Mess Detector issues
59+
if: ${{ inputs.run-phpmd }}
60+
run: composer phpmd
61+

.github/workflows/security.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Security Scanning
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
schedule:
9+
# Run weekly on Monday at 00:00 UTC
10+
- cron: '0 0 * * 1'
11+
workflow_dispatch:
12+
13+
# Cancel in-progress runs for the same workflow and branch/PR
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: read
20+
security-events: write
21+
22+
jobs:
23+
dependency-review:
24+
name: Dependency Review
25+
runs-on: ubuntu-latest
26+
if: github.event_name == 'pull_request'
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Dependency Review
32+
uses: actions/dependency-review-action@v4
33+
34+
composer-audit:
35+
name: Composer Security Audit
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Setup PHP with Composer
42+
uses: ./.github/actions/setup-php-composer
43+
with:
44+
php-version: '7.4'
45+
46+
- name: Run Composer Audit
47+
run: composer audit --format=plain
48+

0 commit comments

Comments
 (0)