Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the content files from theme team and a11y team from official repos #19

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

bph
Copy link
Collaborator

@bph bph commented Apr 12, 2024

Uses the content files from theme team and a11y team from official repos.

https://github.com/wpaccessibility/a11y-theme-unit-test
and
https://github.com/WordPress/theme-test-data

@adamziel
Copy link
Contributor

Let's merge WordPress/wordpress-playground#1244 before this one to make sure the twentytwentyfour theme will be installed successfully.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

adamziel added a commit to WordPress/wordpress-playground that referenced this pull request Apr 16, 2024
…steps (#1244)

Adds an `ifAlreadyInstalled?: 'overwrite' | 'skip' | 'error'` option to
installPlugin and installTheme steps. It defaults to `overwrite`.

Consider the following Blueprint:

```json
{
    "preferredVersions": {
        "php": "latest",
        "wp": "6.4"
    },
    "steps": [
        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "wordpress.org/themes",
                "slug": "twentytwentyfour"
            }
        }
    ]
}
```

Before this PR, it would result in an error. After this PR, the
installation just works. If the Blueprint author explicitly wants the
installation to fail, they can specify the `ifAlreadyInstalled` option:

```json
{
    "steps": [
        {
            "step": "installTheme",
            "themeZipFile": {
                "resource": "wordpress.org/themes",
                "slug": "twentytwentyfour"
            },
            "ifAlreadyInstalled": "skip" // or "error"
        }
    ]
}
```

## Motivation

Installing a plugin or theme over a currently installed one is a common
gotcha. Currently it results in an error and blocks the Blueprint
execution. This behavior is, however, often undesirable as it prevents
having a single Blueprint that installs a twentytwentyfour theme on
different versions of WordPress.

An addition of the `ifAlreadyInstalled` option puts the Blueprint author
in control and provides a sensible default behavior where the
installation will "just work" by replacing the already installed version
of the plugin or theme.

Closes #1157
Related to WordPress/blueprints#19

 ## Testing instructions

Confirm the unit tests pass

cc @bgrgicak @brandonpayton
@adamziel
Copy link
Contributor

This looks good! Note the media files are not actually imported because of CORS issues. I proposed a fix in WordPress/wordpress-playground#1250, but it makes the import unusably long so I won't enable the media transfer until we have a better WXR importer. Either way, let's merge this PR – thank you @bph!

@adamziel adamziel merged commit 080bf01 into trunk Apr 16, 2024
1 of 2 checks passed
@adamziel adamziel changed the title 2nd attempt to submit theme test Uses the content files from theme team and a11y team from official repos. Apr 16, 2024
@adamziel adamziel changed the title Uses the content files from theme team and a11y team from official repos. Use the content files from theme team and a11y team from official repos Apr 16, 2024
reimic pushed a commit to reimic/blueprints-library-ci that referenced this pull request Jun 11, 2024
…ma (#23)

Solves the Blueprint parsing problem as follows:

* JSON Schema is the source of truth for the Blueprint data structure
* Model classes are generated from JSON Schema
* Input Validation is done against the JSON Schema
* Mapping validated input into model instances is indirectly done based on the JSON Schema

## Summary of the approach

We use [Janephp](https://github.com/janephp/janephp/) to infer the PHP model class structure from the JSON schema

We then use Jane's output to generate PHP code using [Nette PHP generator](https://github.com/nette/php-generator):

* Model classes
* Interfaces for groups of related classes: `StepDefinitionInterface`, `ResourceDefinitionInterface`.
* Interface resolution map for the [JsonMapper library](https://jsonmapper.net/).
* PHP docstrings with more accurate types than Jane to guide the mapping process

From there, the data pipeline looks as follows:

1. Parse raw JSON
2. Validate it with Opis
3. Map it into PHP models using JsonMapper

Or, if you're consuming the PHP API directly:

1. Create Model instances
2. Validate them with Opis

## Remaining work

- [ ] Solve merge conflicts

## Rationale

Parsing and mapping JSON [in TypeScript is a simple problem, but in PHP it's surprisingly involved](WordPress/blueprints#13 (comment)). This PR combines three previously explored approaches into a single pipeline:

* WordPress/blueprints#17
* WordPress/blueprints#19
* WordPress/blueprints#21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants