Skip to content

Commit

Permalink
Port module setup from latest project
Browse files Browse the repository at this point in the history
Used https://github.com/XedinUnknown/red-acre-test-a-1 as source.

- No more `inc`: source files go into `src` (with some exceptions)
- The app is now the main module, and all other modules are optional.
- Modules can simply be autoloaded: no need for explicit factory files.
- Bootstrap improved, making it more versatile, and usable in tests.
- Core WP-related things come from WP context, avoiding needless coupling.
- Tools now work on modules too, adding them to QA.
- Test base classes for modular layers: test modules alone or together with ease.
- Tests improved and added.
- Add Node and WP-CLI to relevant virtual services.
- Add WordPress directory mapping for easier debugging and more IDE features (#25).
- Fix missing `get_plugin_data()` and other WP plugin APIs.
  • Loading branch information
XedinUnknown committed Aug 11, 2023
1 parent f03094d commit 08134e6
Show file tree
Hide file tree
Showing 43 changed files with 989 additions and 190 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ PROJECT_MOUNT_PATH=/var/www/html/wp-content/plugins/plugin
DOCROOT_PATH=/var/www/html
BUILD_ROOT_PATH=/app/
PROJECT_NAME=me_plugin
LANGS_PATH=languages

PHP_BUILD_VERSION=7.2
PHP_TEST_VERSION=7.4
PHP_MEMORY_LIMIT=256M
WORDPRESS_VERSION=5.6
NODE_VERSION=20.2.0

DB_ROOT_PASSWORD=root
DB_NAME=wordpress
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
php-version: ${{ matrix.php-versions }}

- name: Analysing source code
run: find ./src/ ./inc/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
run: find ./src/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l

- name: Validate composer.json and composer.lock
run: composer validate
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/vendor/
/node_modules/
/build/
/wordpress/
/.idea/workspace.xml
/.idea/codeStyles/
/.idea/inspectionProfiles/
Expand Down
19 changes: 12 additions & 7 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions .idea/plugin.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
MODULE_DIRS := $(wildcard modules/* )
.PHONY: all \
build \
install \
install-php \
i18n \
i18n-makepot \
qa \
scan \
test \
test-php \
$(MODULE_DIRS)

include .env

all: build

build: install
$(MAKE) build-modules
$(MAKE) i18n
wait

build-modules: $(MODULE_DIRS)

$(MODULE_DIRS):
@if [ -f "$@/Makefile" ]; then echo "$@/Makefile exists!"; $(MAKE) -C $@ build; fi

install:
$(MAKE) install-php

install-php: composer.lock
composer install

i18n: i18n-makepot i18n-makemo

i18n-makepot:
wp i18n make-pot . $(LANGS_PATH)/strings.pot --allow-root

i18n-makemo:
wp i18n make-mo $(LANGS_PATH) --allow-root

qa:
$(MAKE) test
$(MAKE) scan
wait

test:
$(MAKE) test-php

test-php:
vendor/bin/phpunit

scan:
vendor/bin/psalm
vendor/bin/phpcs -s
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
"php": "^7.2 | ^8.0",
"dhii/module-interface": "^0.3-alpha1",
"psr/container": "^1.0",
"dhii/versions": "^0.1.0-alpha2",
"dhii/containers": "^0.1.4-alpha2",
"dhii/services": "^0.1.1-alpha3",
"wp-oop/wordpress-interface": "^0.1.0-alpha1",
"wikimedia/composer-merge-plugin": "^2.0.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0 | ^8.0 | ^9.0",
"brain/monkey": "^2.6",
"vimeo/psalm": "^3.11.7 | ^4.0",
"slevomat/coding-standard": "^6.0",
"webmozart/path-util": "^2.3@stable",
Expand All @@ -32,7 +35,7 @@
},
"autoload-dev": {
"psr-4": {
"Me\\Plugin\\Test\\": "tests"
"Me\\Plugin\\Test\\": "tests/phpunit"
}
},
"extra": {
Expand Down
Loading

0 comments on commit 08134e6

Please sign in to comment.