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 a local environment for testing purposes #76

Merged
merged 9 commits into from
Apr 6, 2023
Merged

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Mar 6, 2023

This is an initial start at making this self-contained so that test can be run locally without depending on the host system having WP/phpunit configured.

To install:
npm install

To run (This is done as part of the install process)?
npm env start

To run tests:
npm test

See #75

@dd32
Copy link
Member Author

dd32 commented Mar 9, 2023

I'm not a super-fan of how the postinstall route is handled, but it was the only way I could really see how to handle it without expecting that the host system has a viable composer version installed locally.

I'm not a fan of --force being needed there either, but it looks like the data in the settings/package.json is invalid or created with an incompatible version of npm.

Either way, this works, and allows unit testing to be run via GitHub actions without requiring a local WordPress install with all the various functionalities setup

@dd32 dd32 marked this pull request as ready for review March 9, 2023 03:37
@iandunn
Copy link
Member

iandunn commented Mar 9, 2023

looks like the data in the settings/package.json is invalid or created with an incompatible version of npm.

I get this after pulling #71 and trying to install locally:

npm ERR! Could not resolve dependency:
npm ERR! dev @testing-library/react@"^14.0.0" from the root project
npm ERR! Conflicting peer dependency: [email protected]
> npm i
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN old lockfile Error: Integrity checksum failed when using sha512: wanted sha512-AV33EzqiFJ3fj+mPlKABN59YFPReLkDxQnj067Z3uEOeRQf3g05WprL0RDuqM7UBhSRo9W1rMSC2KvZmjE5UOA== but got sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==.
npm WARN old lockfile     at RegistryFetcher.manifest (/opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/registry.js:146:35)
npm WARN old lockfile     at async Array.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:734:24)
npm WARN old lockfile  Could not fetch metadata for [email protected] Error: Integrity checksum failed when using sha512: wanted sha512-AV33EzqiFJ3fj+mPlKABN59YFPReLkDxQnj067Z3uEOeRQf3g05WprL0RDuqM7UBhSRo9W1rMSC2KvZmjE5UOA== but got sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==.
npm WARN old lockfile     at RegistryFetcher.manifest (/opt/homebrew/lib/node_modules/npm/node_modules/pacote/lib/registry.js:146:35)
npm WARN old lockfile     at async Array.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:734:24) {
npm WARN old lockfile   code: 'EINTEGRITY'
npm WARN old lockfile }
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from @wordpress/[email protected]
npm ERR!   node_modules/@wordpress/element
npm ERR!     dev @wordpress/element@"^5.4.0" from the root project
npm ERR!     @wordpress/element@"^4.20.0" from @wordpress/[email protected]
npm ERR!     node_modules/@wordpress/babel-preset-default
npm ERR!       @wordpress/babel-preset-default@"^7.6.0" from @wordpress/[email protected]
npm ERR!       node_modules/@wordpress/eslint-plugin
npm ERR!         @wordpress/eslint-plugin@"^13.6.0" from @wordpress/[email protected]
npm ERR!         node_modules/@wordpress/scripts
npm ERR!       1 more (@wordpress/scripts)
npm ERR!   peer react@">=17" from @wordpress/[email protected]
npm ERR!   node_modules/@wordpress/jest-preset-default
npm ERR!     @wordpress/jest-preset-default@"^10.3.0" from @wordpress/[email protected]
npm ERR!     node_modules/@wordpress/scripts
npm ERR!       dev @wordpress/scripts@"^24.6.0" from the root project
npm ERR!   2 more (@wordpress/scripts, react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @testing-library/react@"^14.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^18.0.0" from @testing-library/[email protected]
npm ERR!   node_modules/@testing-library/react
npm ERR!     dev @testing-library/react@"^14.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/iandunn/.npm/_logs/2023-03-09T18_29_06_349Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/iandunn/.npm/_logs/2023-03-09T18_29_06_349Z-debug-0.log

@StevenDufresne , I'm guessing you're not getting that? I wonder why it'd show up on some systems but not others?

Copy link
Member

@iandunn iandunn left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

run: npm run env start --xdebug=coverage

- name: Test
run: npm run test
Copy link
Member

Choose a reason for hiding this comment

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

It'd be nice to also run the JS unit tests in settings/, but that might be better scoped for a separate issue, since we might need/want to combine the two package.json files, or introduce yarn, etc. LMK what you think and I can open a separate issue for that if desired.

@@ -0,0 +1,46 @@
<?php

// Mimic w.org for testing wporg-two-factor
Copy link
Member

Choose a reason for hiding this comment

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

It'd be good to remove all this from the README now that it's automated, and add the steps to setup this new env.

@StevenDufresne
Copy link
Contributor

@StevenDufresne , I'm guessing you're not getting that? I wonder why it'd show up on some systems but not others.

I didn't run into any issues, other than a version issue with npm:
The package-lock.json file was created with an old version of npm

I agree that we should reorder the project dependencies to be like others and use yarn workspaces. Should be pretty trivial.

@StevenDufresne StevenDufresne mentioned this pull request Mar 13, 2023
@StevenDufresne StevenDufresne merged commit 8081f7e into trunk Apr 6, 2023
@StevenDufresne StevenDufresne deleted the add/local-env branch April 6, 2023 06:14
@StevenDufresne
Copy link
Contributor

I merged this to make it easier to contribute. There are a few improvements mentioned that are left hanging. I'll try to follow up.

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.

3 participants