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

Add JSON Schema for .wp-env.json files #36276

Merged
merged 9 commits into from
Jun 12, 2024
Merged

Add JSON Schema for .wp-env.json files #36276

merged 9 commits into from
Jun 12, 2024

Conversation

fabiankaegy
Copy link
Member

@fabiankaegy fabiankaegy commented Nov 6, 2021

Description

This PR adds a JSON Schema for .wp-env.json files.

Closes #36275

@t-hamano
Copy link
Contributor

I came across this PR while checking past PRs.

I also strongly agree with adding this schema 👍 Is it possible to move forward with this PR?

cc @noahtallen @gziolo

@fabiankaegy
Copy link
Member Author

@t-hamano where I failed / left off this PR was in my lack of understanding for how the recursive / nested structure of the .wp-env.json file works for defining multiple environments. And how to properly define that in the schema.

@gziolo
Copy link
Member

gziolo commented Dec 18, 2023

Great idea, let's bring it to the finish line.

@t-hamano where I failed / left off this PR was in my lack of understanding for how the recursive / nested structure of the .wp-env.json file works for defining multiple environments. And how to properly define that in the schema.

@ajlende, are you able to share any insights that would unblock it?

Copy link
Contributor

@ajlende ajlende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really familiar with wp-env at all—I don't use it myself—but I tried taking a look and guessing at what the intention was.

Hopefully I've made the correct assumptions and my explanations make sense.

schemas/json/.wp-env.json Outdated Show resolved Hide resolved
schemas/json/.wp-env.json Outdated Show resolved Hide resolved
schemas/json/.wp-env.json Outdated Show resolved Hide resolved
schemas/json/.wp-env.json Outdated Show resolved Hide resolved
schemas/json/.wp-env.json Show resolved Hide resolved
@fabiankaegy fabiankaegy marked this pull request as ready for review April 3, 2024 15:21
Copy link

github-actions bot commented Apr 3, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: ajlende <ajlende@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: PerryRylance <perryrylance@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

fabiankaegy and others added 8 commits April 3, 2024 17:23
Co-authored-by: Alex Lende <alex+github.com@lende.xyz>
Co-authored-by: Alex Lende <alex+github.com@lende.xyz>
Co-authored-by: Alex Lende <alex+github.com@lende.xyz>
Co-authored-by: Alex Lende <alex+github.com@lende.xyz>
Co-authored-by: Alex Lende <alex+github.com@lende.xyz>
@fabiankaegy fabiankaegy added the [Type] Enhancement A suggestion for improvement. label Apr 3, 2024
@ajlende ajlende enabled auto-merge (squash) June 12, 2024 16:29
@ajlende ajlende merged commit 98617fd into trunk Jun 12, 2024
62 checks passed
@ajlende ajlende deleted the add/wp-env-json-schema branch June 12, 2024 17:05
@github-actions github-actions bot added this to the Gutenberg 18.6 milestone Jun 12, 2024
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: ajlende <ajlende@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: PerryRylance <perryrylance@git.wordpress.org>
@sirreal
Copy link
Member

sirreal commented Jun 17, 2024

If the $schema property appears in wp-env configuration, it throws an error:

Invalid /Users/jonsurrell/a8c/wordpress-develop/trunk/.wp-env.json: "$schema" is not a configuration option.

It should allow that property, or possibly even better use the schema to parse configuration.

I created #62619 to track this.

@bph bph added the [Type] Build Tooling Issues or PRs related to build tooling label Jun 18, 2024
Copy link

github-actions bot commented Jun 18, 2024

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: [Type] Enhancement, [Type] Build Tooling, Backported to WP Core, Backport to WP 6.6 Beta/RC.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@ajlende ajlende added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 18, 2024
@ajlende
Copy link
Contributor

ajlende commented Jun 18, 2024

I added the Backport to WP Beta/RC label so this change along with #62626 and #62634 make it into the wp/6.6 branch. This lets us automatically version our schemas based on WordPress releases. Redirects for WordPress releases are based off the wp/x.x branches and lead to https://schemas.wp.org/wp/x.x/schema.json.

I'm wondering if this schema should be versioned along with WordPress releases, though? Would it make more sense to add redirects for Gutenberg releases (https://github.com/WordPress/gutenberg/tree/v18.5.0) or @wordpress/env releases (https://github.com/WordPress/gutenberg/tree/%40wordpress/env%4010.1.0) instead or in addition to the WordPress ones?

One thing of note with both of those is that they're just tags, so we can't backport missing schema changes like we can with the WordPress releases. We'd have to have some way of finding the latest patch version to redirect if we don't want folks to have to update their $schema for every bug fix.

@t-hamano
Copy link
Contributor

Would it make more sense to add redirects for Gutenberg releases (https://github.com/WordPress/gutenberg/tree/v18.5.0) or @wordpress/env releases (https://github.com/WordPress/gutenberg/tree/%40wordpress/env%4010.1.0) instead or in addition to the WordPress ones?

This makes sense to me. env is a library that does not ship with WordPress core, so I think it might be better to redirect to @wordpress/env releases.

@ellatrix
Copy link
Member

I just cherry-picked this PR to the wp/6.6-rc-1 branch to get it included in the next release: 990f23a

ellatrix pushed a commit that referenced this pull request Jun 25, 2024
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: ajlende <ajlende@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: PerryRylance <perryrylance@git.wordpress.org>
@ellatrix ellatrix added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Jun 25, 2024
ellatrix pushed a commit that referenced this pull request Jun 25, 2024
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: ajlende <ajlende@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: PerryRylance <perryrylance@git.wordpress.org>
@swissspidy
Copy link
Member

FWIW this schema is missing things like mysqlPort

@t-hamano
Copy link
Contributor

t-hamano commented Jul 8, 2024

Thank you for noticing. I compared the env specification and schema again, and as far as I can tell, the following fields are not defined:

  • mysqlPort
  • testsPort
  • lifecycleScripts.afterStart
  • lifecycleScripts.afterClean
  • lifecycleScripts.beforeDestroy
@t-hamano
Copy link
Contributor

t-hamano commented Jul 8, 2024

Note: The JSON schema itself is not included in WordPress releases, it exists in the GitHub repository and is simply referenced from the JSON files.

Therefore, if additional fixes can’t be made in time for the WP6.6 release, they can be committed to the wp/6.6 branch (and trunk branch) at a later time.

@bacoords
Copy link
Contributor

@t-hamano I can't find any reference that shows the actual URL of the schema for users to start using it - and I don't see any documentation for it in the package reference.

If there's a preferred URL to the hosted schema I'm happy to add a PR to get this in the package docs: https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/#wp-env-json

@t-hamano
Copy link
Contributor

If there's a preferred URL to the hosted schema I'm happy to add a PR to get this in the package docs:

Thanks for pointing that out! I definitely think references are necessary. The README for the schema itself will also need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Type] Build Tooling Issues or PRs related to build tooling [Type] Enhancement A suggestion for improvement.
9 participants