Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
SSR: Add wp-context, wp-bind, wp-class, wp-style (#133)
Browse files Browse the repository at this point in the history
Implement Server-side rendering of those directives via `WP_HTML_Tag_Processor`.

Gutenberg 15.0 is the first version to include [`get_attribute_names_with_prefix()`](WordPress/gutenberg#46840). This means that we now have everything we need to implement `wp-bind`, `wp-class`, and `wp-style`. This PR thus adds those directives, plus `wp-context`.

This also adds PHP unit test infrastructure and CI, in order to allow us to adopt a test-driven development approach for individual directives. Those "infrastructure" files are mostly copied directly from GB, with some minor modifications. Refer to individual commit messages on the PR to learn more.
  • Loading branch information
ockham authored Jan 26, 2023
1 parent cc3301d commit f892bee
Show file tree
Hide file tree
Showing 18 changed files with 1,023 additions and 216 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Unit Tests

on:
pull_request:
push:
branches:
- 'main*'

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
unit-php:
name: PHP
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/block-hydration-experiments' || github.event_name == 'pull_request' }}

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0

- name: Install Composer dependencies
run: |
composer install
- name: Use desired version of NodeJS
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
with:
node-version: 14
cache: npm

- name: Npm install and build
run: |
npm ci
npm run build
- name: Run WordPress
run: |
npm run wp-env start
- name: Running single site unit tests
run: npm run test:unit:php
if: ${{ success() || failure() }}
7 changes: 7 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
],
"config": {
"SCRIPT_DEBUG": true
},
"env": {
"tests": {
"mappings": {
"wp-content/plugins/block-hydration-experiments": "."
}
}
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"squizlabs/php_codesniffer": "^3.5",
"phpcompatibility/phpcompatibility-wp": "^2.1.3",
"wp-coding-standards/wpcs": "^2.2",
"sirbrillig/phpcs-variable-analysis": "^2.8"
"sirbrillig/phpcs-variable-analysis": "^2.8",
"phpunit/phpunit": "^9.5",
"yoast/phpunit-polyfills": "^1.0"
},
"require": {
"composer/installers": "~1.0"
Expand Down
Loading

0 comments on commit f892bee

Please sign in to comment.