Skip to content

Commit 1032d94

Browse files
Copilotsrtfisher
andcommitted
Update to create-php-package structure: composer.json, workflows, PSR-4 tests
Co-authored-by: srtfisher <346399+srtfisher@users.noreply.github.com>
1 parent cbcfda0 commit 1032d94

File tree

11 files changed

+115
-49
lines changed

11 files changed

+115
-49
lines changed

.github/workflows/all-pr-tests.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "All Pull Request Tests"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
types: [opened, synchronize, reopened, ready_for_review]
8+
9+
jobs:
10+
# We use a single job to ensure that all steps run in the same environment and
11+
# reduce the number of minutes used.
12+
pr-tests:
13+
# Don't run on draft PRs
14+
if: github.event.pull_request.draft == false
15+
# Timeout after 10 minutes
16+
timeout-minutes: 10
17+
# Define a matrix of PHP/WordPress versions to test against
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
php: [8.2, 8.3, 8.4]
22+
wordpress: ["latest"]
23+
runs-on: ubuntu-latest
24+
# Cancel any existing runs of this workflow
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-P${{ matrix.php }}-WP${{ matrix.wordpress }}
27+
cancel-in-progress: true
28+
# Name the job in the matrix
29+
name: "PR Tests PHP ${{ matrix.php }} WordPress ${{ matrix.wordpress }}"
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Run General Tests
34+
# See https://github.com/alleyinteractive/action-test-general for more options
35+
uses: alleyinteractive/action-test-general@develop
36+
37+
- name: Run PHP Tests
38+
# See https://github.com/alleyinteractive/action-test-php for more options
39+
uses: alleyinteractive/action-test-php@develop
40+
with:
41+
php-version: '${{ matrix.php }}'
42+
wordpress-version: '${{ matrix.wordpress }}'
43+
skip-wordpress-install: 'true'
44+
skip-services: 'true' # Skip MySQL unless the library is not using SQLite testing.
45+
all-pr-checks-passed:
46+
name: All PR checks passed
47+
needs:
48+
- pr-tests
49+
runs-on: ubuntu-latest
50+
if: always()
51+
steps:
52+
- name: Check job statuses
53+
run: |
54+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
55+
echo "One or more jobs failed"
56+
exit 1
57+
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
58+
echo "One or more jobs were cancelled"
59+
exit 1
60+
else
61+
echo "All jobs passed or were skipped"
62+
exit 0
63+
fi

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/dependabot-auto-approve.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ permissions:
88

99
jobs:
1010
dependabot:
11-
uses: alleyinteractive/.github/.github/workflows/dependabot-auto-approve.yml@main
11+
uses: alleyinteractive/.github/.github/workflows/dependabot-auto-approve.yml@main

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ permissions:
77

88
jobs:
99
dependabot:
10-
uses: alleyinteractive/.github/.github/workflows/dependabot-auto-merge.yml@main
10+
uses: alleyinteractive/.github/.github/workflows/dependabot-auto-merge.yml@main

.github/workflows/unit-test.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/update-changelog.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
ref: main
1616

@@ -21,8 +21,8 @@ jobs:
2121
release-notes: ${{ github.event.release.body }}
2222

2323
- name: Commit updated CHANGELOG
24-
uses: stefanzweifel/git-auto-commit-action@v4
24+
uses: stefanzweifel/git-auto-commit-action@v6
2525
with:
2626
branch: main
2727
commit_message: Update CHANGELOG
28-
file_pattern: CHANGELOG.md
28+
file_pattern: CHANGELOG.md

composer.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
],
1616
"homepage": "https://github.com/alleyinteractive/wp-path-dispatch",
1717
"require": {
18-
"php": "^8.0"
18+
"php": "^8.2",
19+
"alleyinteractive/composer-wordpress-autoloader": "^1.0"
1920
},
2021
"require-dev": {
21-
"alleyinteractive/alley-coding-standards": "^1.0",
22-
"mantle-framework/testkit": "^0.10",
23-
"nunomaduro/collision": "^5.0"
22+
"alleyinteractive/alley-coding-standards": "^2.0",
23+
"mantle-framework/testkit": "^1.0",
24+
"szepeviktor/phpstan-wordpress": "^2.0"
2425
},
2526
"minimum-stability": "dev",
2627
"prefer-stable": true,
@@ -30,6 +31,11 @@
3031
"src/helpers.php"
3132
]
3233
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"WP_Path_Dispatch\\Tests\\": "tests"
37+
}
38+
},
3339
"config": {
3440
"allow-plugins": {
3541
"alleyinteractive/composer-wordpress-autoloader": true,
@@ -39,17 +45,19 @@
3945
},
4046
"extra": {
4147
"wordpress-autoloader": {
42-
"autoload-dev": {
43-
"WP_Path_Dispatch\\Tests\\": "tests"
48+
"autoload": {
49+
"WP_Path_Dispatch\\": "src"
4450
}
4551
}
4652
},
4753
"scripts": {
4854
"phpcbf": "phpcbf .",
4955
"phpcs": "phpcs .",
56+
"phpstan": "phpstan --memory-limit=512M",
5057
"phpunit": "phpunit",
5158
"test": [
5259
"@phpcs",
60+
"@phpstan",
5361
"@phpunit"
5462
]
5563
}

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
includes:
2+
- vendor/szepeviktor/phpstan-wordpress/extension.neon
3+
parameters:
4+
level: 5
5+
paths:
6+
- src
7+
- tests
8+
excludePaths:
9+
- vendor
10+
reportUnmatchedIgnoredErrors: false
11+
checkMissingIterableValueType: false

phpunit.xml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
<?xml version="1.0"?>
12
<phpunit
2-
bootstrap="tests/bootstrap.php"
3-
backupGlobals="false"
4-
colors="true"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
printerClass="NunoMaduro\Collision\Adapters\Phpunit\Printer"
9-
>
10-
<testsuites>
11-
<testsuite name="Feature">
12-
<directory prefix="test-" suffix=".php">tests/feature</directory>
13-
</testsuite>
14-
</testsuites>
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="tests/bootstrap.php"
5+
backupGlobals="false"
6+
colors="true"
7+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
8+
cacheDirectory=".phpunit.result.cache">
9+
<testsuites>
10+
<testsuite name="Feature">
11+
<directory suffix="Test.php">tests/Feature</directory>
12+
</testsuite>
13+
<testsuite name="Unit">
14+
<directory suffix="Test.php">tests/Unit</directory>
15+
</testsuite>
16+
</testsuites>
17+
<php>
18+
<env name="MANTLE_USE_SQLITE" value="true" />
19+
<env name="WP_SKIP_DB_CREATE" value="true" />
20+
</php>
1521
</phpunit>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
namespace WP_Path_Dispatch\Tests\Feature;
33

44
use WP_Path_Dispatch\Path_Dispatch;
5-
use WP_Path_Dispatch\Tests\Test_Case;
5+
use WP_Path_Dispatch\Tests\TestCase;
66

77
use function WP_Path_Dispatch\Path_Dispatch;
88

99
/**
1010
* Visit {@see https://mantle.alley.co/testing/test-framework.html} to learn more.
1111
*/
12-
class Path_Dispatch_Test extends Test_Case {
12+
class PathDispatchTest extends TestCase {
1313
protected function setUp(): void {
1414
parent::setUp();
1515

0 commit comments

Comments
 (0)