Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Package.json validation tests #2938

Merged
merged 23 commits into from Feb 8, 2022
Merged

Package.json validation tests #2938

merged 23 commits into from Feb 8, 2022

Conversation

teallarson
Copy link
Contributor

@teallarson teallarson commented Feb 2, 2022

Change description

  • Adds schema validation tests for our Package.json files
  • Checks for version matches across the repo
  • Checks file contents for items in our "bad words" list

Went with invoking the version checker and spelling checker within child process inside the jest test as the scripts in place did a more efficient job of the tasks then a JavaScript solution would in my opinion.

Also removed the CI jobs that used to execute those scripts, and added one to run the new suite.

Checklists

Development

  • Application changes have been tested appropriately

Impact

  • Code follows company security practices and guidelines
  • Security impact of change has been considered
  • Performance impact of change has been considered
  • Possible migration needs considered (model migrations, config migrations, etc.)

Please explain any security, performance, migration, or other impacts if relevant:

Code review

  • Pull request has a descriptive title and context useful to a reviewer. Screenshots or screencasts are attached where applicable.
  • Relevant tags have been added to the PR (bug, enhancement, internal, etc.)

@teallarson teallarson force-pushed the 179444024-packagejson-tests branch 13 times, most recently from 275cc40 to 4e8adca Compare February 4, 2022 18:09
@teallarson
Copy link
Contributor Author

the flaky test here in models is fixed by #2943 (missing awaits)

@teallarson teallarson marked this pull request as ready for review February 4, 2022 20:16
@teallarson teallarson added the internal chores and housekeeping label Feb 4, 2022
Copy link
Member

@evantahler evantahler left a comment

Choose a reason for hiding this comment

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

Good setup! I like the consistency of having a top-level test suite, rather then some random bash scripts we run.

I think there are a few topics to look into:

  1. Don't import/require anything from grouparoo/core or grouparoo/spec-helper. They shouldn't be needed and I'm worried that will have an adverse effect on the publishing pipeline
  2. Can JSON-schema assert the contents of the JSON rather than the types? For example, we don't really care that publish config is /any/ string in the packages, we really do want to assert that it is "public". I think that's a better reflection of the goal.

jest.setup.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tools/merger/data/ci/root/job.yml.template Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
__tests__/schemaGeneric.json Show resolved Hide resolved
__tests__/schemaGeneric.json Outdated Show resolved Hide resolved
__tests__/schemaGeneric.json Outdated Show resolved Hide resolved
__tests__/wordCheck Show resolved Hide resolved
Comment on lines 16 to 19
if (error || stderr) {
reject(error || stderr);
}
res();
Copy link
Member

Choose a reason for hiding this comment

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

Same as below - an early reject without a return will still also resolve later

Copy link
Contributor

Choose a reason for hiding this comment

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

I think doing done(error || stderr) and not wrapping all this in a promise may be the best way to handle it.

Copy link
Contributor Author

@teallarson teallarson Feb 8, 2022

Choose a reason for hiding this comment

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

Went with the done() pattern for both the version and license checkers and piped out the most meaningful messaging for each checker (license checker shows it in stderr, but the version checker shows it in stdout)

@teallarson
Copy link
Contributor Author

teallarson commented Feb 8, 2022

Changes since last review:

  • Tighter assertions for the publishConfig (Implemented by adding a third schema for restricted access configs and switching some logic for which schema to use. The only packages using the schemaGeneric now are ones that do not require a publishConfig.)
  • Tighter assertion for engine
  • TSConfig and CI Job cleanup
  • Tests for version and license checking fail correctly now, and display helpful errors (ie: what package it failed on and why)

__tests__/packages.ts Outdated Show resolved Hide resolved
tools/merger/data/ci/root/job.yml.template Outdated Show resolved Hide resolved
@teallarson teallarson merged commit 05a2498 into main Feb 8, 2022
@teallarson teallarson deleted the 179444024-packagejson-tests branch February 8, 2022 18:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
internal chores and housekeeping
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants