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 pre-commit hook to check whether API docs are updated #18820

Merged
merged 6 commits into from
Dec 19, 2019

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Nov 29, 2019

This PR is an alternative to #18657 Instead of automatically adding files to the commit (which could be problematic) this goes the route of checking whether the API docs are unstaged: if so, the commit will be prevented and the user has the choice of either adding them to the commit or skipping the check.

Test instructions

  • Edit the JSON comment of an exported entity in packages/core-data/src/actions.js
  • git add packages/core-data/src/actions.js
  • git commit -m 'testing'

The expected result is that you can't commit due to the unstaged README files that were auto-updated due to the code change and will see a message like:

Screenshot from 2019-12-03 10-33-09

@oandregal oandregal self-assigned this Nov 29, 2019
@oandregal oandregal added the [Status] In Progress Tracking issues with work in progress label Nov 29, 2019
@oandregal oandregal marked this pull request as ready for review December 3, 2019 09:43
@oandregal oandregal removed the [Status] In Progress Tracking issues with work in progress label Dec 3, 2019
@aduth
Copy link
Member

aduth commented Dec 3, 2019

What would need to be done to reconcile this with #18840, notably that I've removed the explicit list of packages in that pull request.

@oandregal
Copy link
Member Author

I'm fine with whatever approach that gets both shipped fast. It looks like this PR makes less changes to update-readmes so it could land first and then #18840?

@oandregal
Copy link
Member Author

oandregal commented Dec 4, 2019

This needs to take also into account potential changes to handbook's API docs as well. Updated the testing instructions to reflect that.

Update: done this at 14f3a3b

package.json Outdated
@@ -120,7 +120,7 @@
"fast-glob": "2.2.7",
"fbjs": "0.8.17",
"glob": "7.1.2",
"husky": "3.0.5",
"husky": "2.7.0",
Copy link
Member

Choose a reason for hiding this comment

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

Was it intentional to downgrade? I would expect it would need corresponding changes to package-lock.json if intended.

Copy link
Member Author

Choose a reason for hiding this comment

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

I need to revert this.

For context: when we updated husky from 0 to 3 we introduced a breaking change: the git version required to work with husky is >= 2.13.2. Git hooks won't be executed in versions below. The git version bundled with my OS is lower than that, so I can't run the hooks (and test this change), so I had to downgrade it for testing.

I asked in core-editor about this change and it doesn't seem a widespread issue. Wasn't able to pin down easily the git versions that come with the supported OS for Windows and Mac to gauge how many could be affected. I guessed another way to look at it was that if people don't complain about hooks not executing for them, it's not an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

bin/api-docs/are-readmes-unstaged.js Outdated Show resolved Hide resolved
bin/api-docs/are-readmes-unstaged.js Outdated Show resolved Hide resolved
@oandregal oandregal merged commit e60b9c4 into master Dec 19, 2019
@oandregal oandregal deleted the try/pre-commit-doc-api branch December 19, 2019 11:24
@youknowriad youknowriad added this to the Gutenberg 7.2 milestone Jan 6, 2020
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