Skip to content

Commit 3e6c7a7

Browse files
committed
♻️ Refactor to injectable architecture with tests & CI
Restructure the library to match the wp-cache-helper/freemius-plugin-licensing template: split the monolithic Async/Task classes into injectable collaborators (StoreInterface, OptionStore, Batch, ServerLimits, ProcessLock, QueueException), add a Brain\Monkey test suite, phpcs/phpunit config, and GitHub workflows. - PHP 7.4+ typed properties/signatures (was 5.6) - Swappable storage driver + server-load guard + process lock via constructor - Fix latent stdClass fatal and null-row deref in get_batch() - Public API and filters unchanged; bump to 2.0.0 - Rewrite README, replace misnamed gitignore
1 parent 50bcac0 commit 3e6c7a7

29 files changed

Lines changed: 2148 additions & 676 deletions

.github/workflows/phpcs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: PHPCS
2+
3+
on:
4+
push:
5+
branches: [main,dev]
6+
pull_request:
7+
8+
jobs:
9+
phpcs:
10+
name: WPCS lint
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: '8.1'
20+
coverage: none
21+
tools: composer:v2, cs2pr
22+
23+
- name: Get Composer cache directory
24+
id: composer-cache
25+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
26+
27+
- name: Cache Composer dependencies
28+
uses: actions/cache@v4
29+
with:
30+
path: ${{ steps.composer-cache.outputs.dir }}
31+
key: ${{ runner.os }}-composer-phpcs-${{ hashFiles('**/composer.json') }}
32+
restore-keys: |
33+
${{ runner.os }}-composer-phpcs-
34+
35+
- name: Install dependencies
36+
run: composer update --no-interaction --no-progress --prefer-dist
37+
38+
- name: Run PHPCS
39+
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Create GitHub Release
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Generate release notes
22+
id: notes
23+
run: |
24+
previous_tag=$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^" 2>/dev/null || true)
25+
{
26+
echo "notes<<EOF"
27+
if [ -n "$previous_tag" ]; then
28+
echo "## Changes since ${previous_tag}"
29+
echo
30+
git log --pretty=format:'- %s (%h)' "${previous_tag}..${GITHUB_REF_NAME}"
31+
else
32+
echo "## Changes"
33+
echo
34+
git log --pretty=format:'- %s (%h)' "${GITHUB_REF_NAME}"
35+
fi
36+
echo
37+
echo EOF
38+
} >> "$GITHUB_OUTPUT"
39+
40+
- name: Create release
41+
uses: softprops/action-gh-release@v2
42+
with:
43+
tag_name: ${{ github.ref_name }}
44+
name: ${{ github.ref_name }}
45+
body: ${{ steps.notes.outputs.notes }}
46+
draft: false
47+
prerelease: ${{ contains(github.ref_name, '-') }}

.github/workflows/tests.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main,dev]
6+
pull_request:
7+
8+
jobs:
9+
phpunit:
10+
name: PHPUnit (PHP ${{ matrix.php }})
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: ${{ matrix.php }}
24+
coverage: none
25+
tools: composer:v2
26+
27+
- name: Get Composer cache directory
28+
id: composer-cache
29+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
30+
31+
- name: Cache Composer dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: ${{ steps.composer-cache.outputs.dir }}
35+
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
36+
restore-keys: |
37+
${{ runner.os }}-composer-${{ matrix.php }}-
38+
39+
- name: Install dependencies
40+
run: composer update --no-interaction --no-progress --prefer-dist
41+
42+
- name: Run PHPUnit
43+
run: vendor/bin/phpunit --no-coverage

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DS_Store
2+
node_modules
3+
vendor
4+
.phpunit.result.cache
5+
.phpcs-cache
6+
phpcs.xml
7+
phpunit.xml
8+
9+
# Generated
10+
/tests/.tmp
11+
12+
# local env files
13+
.env.local
14+
.env.*.local
15+
16+
# Log files
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
pnpm-debug.log*
21+
22+
# Editor directories and files
23+
.idea
24+
.vscode
25+
*.suo
26+
*.ntvs*
27+
*.njsproj
28+
*.sln
29+
*.sw?
30+
31+
# Unwanted config files
32+
package-lock.json
33+
composer.lock

0 commit comments

Comments
 (0)