-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (64 loc) · 3.1 KB
/
Copy pathMakefile
File metadata and controls
86 lines (64 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.DEFAULT_GOAL := help
SHELL := /bin/bash
PLUGIN_NAME := wp-super-cache
# Use the locally-installed @wordpress/env (a devDependency) rather than fetching
# it via `npx --yes` on every call, which needs registry access on each run.
# Run `make install` (npm install) once to populate it.
WP_ENV_BIN := node_modules/.bin/wp-env
WP_ENV := COMPOSE_PROJECT_NAME=$(PLUGIN_NAME) $(WP_ENV_BIN)
# Guard: any wp-env target depends on this. If the binary is missing the recipe
# below runs and exits with a helpful message; if it exists, it's up to date and
# the recipe is skipped.
$(WP_ENV_BIN):
@echo "Error: wp-env is not installed. Run 'make install' first." >&2
@exit 1
## Development environment
install: ## Install PHP (Composer) and JS (npm) dependencies
composer install
npm install
up: $(WP_ENV_BIN) ## Start WordPress in Docker (http://localhost:8888, admin/password)
$(WP_ENV) start
down: $(WP_ENV_BIN) ## Stop the WordPress containers
$(WP_ENV) stop
destroy: $(WP_ENV_BIN) ## Remove the WordPress containers and database
$(WP_ENV) destroy
logs: $(WP_ENV_BIN) ## Tail the WordPress container logs
$(WP_ENV) logs
cli: $(WP_ENV_BIN) ## Open a shell inside the cli container
$(WP_ENV) run cli bash
wp: $(WP_ENV_BIN) ## Run an arbitrary wp-cli command, e.g. `make wp CMD="plugin list"`
$(WP_ENV) run cli wp $(CMD)
## Test content
seed: $(WP_ENV_BIN) ## Create 100 randomly named posts and 100 pages for cache testing
$(WP_ENV) run cli wp eval-file wp-content/plugins/wp-super-cache/tests/dev/seed.php
unseed: $(WP_ENV_BIN) ## Delete content created by `make seed`
$(WP_ENV) run cli wp eval-file wp-content/plugins/wp-super-cache/tests/dev/unseed.php
## Test
PLUGIN_DIR_IN_CONTAINER := /var/www/html/wp-content/plugins/wp-super-cache
WPSC_TESTS_CONFIG := $(PLUGIN_DIR_IN_CONTAINER)/tests/php/wp-tests-config.php
test: ## Run the fast PHP smoke suite (no database, no Docker)
composer test-php
test-integration: $(WP_ENV_BIN) ## Run the full WordPress integration suite in Docker (auto-starts wp-env)
$(WP_ENV) start
$(WP_ENV) run tests-cli --env-cwd=wp-content/plugins/wp-super-cache \
env WP_PHPUNIT__TESTS_CONFIG=$(WPSC_TESTS_CONFIG) \
vendor/bin/phpunit -c phpunit-integration.9.xml.dist --colors=always
## Lint
lint: ## Run PHP CodeSniffer
composer lint
lint-all: ## Run PHP CodeSniffer on all files
composer phpcs
lint-fix: ## Auto-fix PHP CodeSniffer issues
composer lint-fix
## Release
release: ## Prepare a release PR. Usage: make release VERSION=x.y.z
@test -n "$(VERSION)" || { echo "Usage: make release VERSION=x.y.z"; exit 1; }
node scripts/prepare-release.mjs $(VERSION)
build: ## Build build/wp-super-cache.zip from the current working tree
./scripts/build-plugin.sh
i18n: ## Regenerate translation files (no-op: WPSC translations come from translate.wordpress.org)
@echo "No POT generation step for WP Super Cache."
## Help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-12s\033[0m %s\n", $$1, $$2}'
.PHONY: install up down destroy logs cli wp seed unseed test test-integration lint lint-all lint-fix release build i18n help