Skip to content

Commit 31912a1

Browse files
committed
Example plugin: Update build/test/release workflow, dependencies; Remove wp-now to be replaced by WP Playground CLI
1 parent cd19a05 commit 31912a1

File tree

13 files changed

+103
-444
lines changed

13 files changed

+103
-444
lines changed

.github/workflows/publish.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish NPM package
2+
permissions:
3+
contents: write
4+
on:
5+
workflow_run:
6+
workflows: ["Run Tests"]
7+
tags:
8+
- '*'
9+
types:
10+
- completed
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
# Require tests to pass before publish
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- name: Setup Bun
22+
uses: oven-sh/setup-bun@v2
23+
- name: Install dependencies
24+
run: bun install
25+
- name: Build NPM package
26+
run: bun run build:npm
27+
# - name: Publish NPM package
28+
# run: |
29+
# cd publish/npm
30+
# bun publish --access public
31+
# env:
32+
# NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
name: Release
22
permissions:
33
contents: write
4-
on: push
4+
on:
5+
workflow_run:
6+
workflows: ["Run Tests"]
7+
branches: [main]
8+
types:
9+
- completed
510
jobs:
611
build:
712
runs-on: ubuntu-latest
13+
# Require tests to pass before release
14+
# https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
816
steps:
917
- name: Checkout
1018
uses: actions/checkout@v4

.github/workflows/tests.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Run Tests
2+
permissions:
3+
contents: write
4+
on:
5+
push:
6+
workflow_call: # Allow this workflow to be called from other workflows
7+
jobs:
8+
tests:
9+
timeout-minutes: 15
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- name: Set up Docker
17+
uses: docker/setup-docker-action@v4
18+
- name: Set up PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.2'
22+
tools: phpunit-polyfills
23+
# Configure workspace as safe for Git, to solve: https://github.com/composer/composer/issues/12221
24+
- name: Git safe.directory
25+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
26+
- name: Install Composer dependencies
27+
run: composer install --no-interaction --no-progress --optimize-autoloader
28+
- name: Setup Bun
29+
uses: oven-sh/setup-bun@v2
30+
- name: Install dependencies
31+
run: bun install
32+
- name: PHPUnit - Run tests for PHP 7.4
33+
run: bun run test:7.4
34+
- name: PHPUnit - Run tests for PHP 8.2
35+
run: bun run test:8.2
36+
- name: Jest - Run tests
37+
run: bun run jest:test
38+
- name: Install playwright
39+
run: bun playwright install
40+
- name: End to end - Run tests
41+
run: bun run e2e

.wp-env.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"core": "WordPress/WordPress",
33
"phpVersion": "8.2",
44
"plugins": ["."],
5+
"config": {
6+
"WP_DEBUG": true,
7+
"WP_DEBUG_LOG": true,
8+
"WP_DEBUG_DISPLAY": false
9+
},
510
"mappings": {
611
}
712
}

bitbucket-pipelines.yml

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

blueprint.dev.json

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

example-plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* Plugin Name: Example Plugin
44
* Plugin URI: https://tangibleplugins.com/example-plugin
55
* Description: Description of example plugin
6-
* Version: 0.1.1
6+
* Version: 0.0.1
77
* Author: Team Tangible
88
* Author URI: https://teamtangible.com
99
* License: GPLv2 or later
1010
*/
1111
use tangible\framework;
1212
use tangible\updater;
1313

14-
define( 'EXAMPLE_PLUGIN_VERSION', '0.1.1' );
14+
define( 'EXAMPLE_PLUGIN_VERSION', '0.0.1' );
1515

1616
require __DIR__ . '/vendor/tangible/framework/index.php';
1717
require __DIR__ . '/vendor/tangible/updater/index.php';

package.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "example-plugin",
33
"description": "Description of example plugin",
4-
"version": "0.1.1",
4+
"version": "0.0.1",
55
"type": "module",
66
"homepage": "https://github.com/tangibleinc/example-plugin",
77
"repository": {
@@ -19,16 +19,15 @@
1919
"update": "roll update",
2020
"install:dev": "roll install --dev",
2121
"update:dev": "roll update --dev",
22-
"archive": "roll archive -y && rm -rf publish/example-plugin && unzip -q publish/example-plugin.zip -d publish/ && npm run now:test:archive",
23-
"now": "wp-now start --blueprint=blueprint.dev.json",
24-
"now:dev": "concurrently --raw 'roll dev' 'npm run now'",
25-
"now:test": "roll run tests/now/index.ts",
26-
"now:test:archive": "roll run tests/now/index.ts TEST_ARCHIVE=1",
22+
"archive": "roll archive -y",
2723
"-- Local environment --": "https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env",
2824
"env": "wp-env",
2925
"composer": "FOLDER=`basename $(realpath $PWD)`; wp-env run cli --env-cwd=wp-content/plugins/$FOLDER composer",
3026
"composer:install": "wp-env run cli sudo apk add git && npm run composer install",
3127
"composer:update": "npm run composer update",
28+
"log": "wp-env run cli cat wp-content/debug.log",
29+
"shell": "wp-env run cli bash",
30+
"wp": "wp-env run cli wp",
3231
"test": "FOLDER=`basename $(realpath $PWD)`; wp-env run tests-wordpress /var/www/html/wp-content/plugins/$FOLDER/vendor/bin/phpunit --testdox -c /var/www/html/wp-content/plugins/$FOLDER/phpunit.xml --verbose",
3332
"test:7.4": "WP_ENV_PHP_VERSION=7.4 wp-env start && npm run test",
3433
"test:8.2": "WP_ENV_PHP_VERSION=8.2 wp-env start && npm run test",
@@ -44,13 +43,12 @@
4443
},
4544
"dependencies": {},
4645
"devDependencies": {
47-
"@playwright/test": "^1.52.0",
48-
"@tangible/now": "^3.0.2",
49-
"@tangible/roller": "^2.1.4",
50-
"@wordpress/e2e-test-utils-playwright": "^1.22.0",
51-
"@wordpress/env": "^10.22.0",
46+
"@playwright/test": "^1.56.1",
47+
"@tangible/roller": "^2.1.7",
48+
"@wordpress/e2e-test-utils-playwright": "^1.33.0",
49+
"@wordpress/env": "^10.33.0",
5250
"chokidar-cli": "^3.0.0",
53-
"concurrently": "^9.1.2",
51+
"concurrently": "^9.2.1",
5452
"testra": "^2.1.5"
5553
},
5654
"author": "Team Tangible",

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ npm run format
3838

3939
### Local dev site
4040

41-
Start a local dev site using [`wp-now`](https://github.com/WordPress/playground-tools/blob/trunk/packages/wp-now/README.md).
41+
Start a local dev site using [`wp-env`](https://github.com/WordPress/playground-tools/blob/trunk/packages/wp-now/README.md).
4242

4343
```sh
44-
npm run now
44+
npm run start
4545
```
4646

47-
The default user is `admin` with `password`. Press CTRL + C to stop.
47+
For details see [Tests](#tests) below.
4848

4949
#### Dev dependencies
5050

@@ -86,7 +86,7 @@ npm run start
8686

8787
This uses [`wp-env`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/) to quickly spin up a local dev and test environment, optionally switching between multiple PHP versions. It requires **Docker** to be installed. There are instructions available for installing Docker on [Windows](https://docs.docker.com/desktop/install/windows-install/), [macOS](https://docs.docker.com/desktop/install/mac-install/), and [Linux](https://docs.docker.com/desktop/install/linux-install/).
8888

89-
Visit [http://localhost:8888](http://localhost:8888) to see the dev site, and [http://localhost:8889](http://localhost:8880) for the test site, whose database is cleared on every run.
89+
Visit [http://localhost:8888](http://localhost:8888) to see the dev site (default user `admin` with `password`); and [http://localhost:8889](http://localhost:8880) for the test site, whose database is cleared on every run.
9090

9191
Before running tests, install PHPUnit as a dev dependency using Composer inside the container.
9292

tests/now/.wp-env.json

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

0 commit comments

Comments
 (0)