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

feat(dev): add changelog check into pre-commit #7377

Open
wants to merge 18 commits into
base: 4.x
Choose a base branch
from

Conversation

whitemoshui
Copy link
Contributor

Description

Fix #7219
536294cc1b35f6f0b1b7dae3e9b18f5
03693061342b35d0463ca62fda0825b

I don't know how to write tests for it. The images above show the test results that were done manually

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run lint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:coverage and my test cases cover all the lines and branches of the added code.
  • I ran npm run build and tested dist/web3.min.js in a browser.
  • I have tested my code on the live network.
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have linked Issue(s) with this PR in "Linked Issues" menu.

- [ ] I ran `npm run build` and tested `dist/web3.min.js` in a browser.
- [ ] I have tested my code on the live network.
- [ ] I have checked the Deploy Preview and it looks correct.
- [ ] I have updated the `CHANGELOG.md` file in both the root folder and corresponding packages/web3-xxx folders.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These spaces are added automatically by the check

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.54%. Comparing base (ae99434) to head (ea7013b).

Additional details and impacted files
@@           Coverage Diff           @@
##              4.x    #7377   +/-   ##
=======================================
  Coverage   94.54%   94.54%           
=======================================
  Files         218      218           
  Lines        8637     8637           
  Branches     2364     2364           
=======================================
  Hits         8166     8166           
  Misses        471      471           
Flag Coverage Δ
UnitTests 94.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

scripts/check_changelog.js Outdated Show resolved Hide resolved
@jdevcs
Copy link
Contributor

jdevcs commented Nov 25, 2024

@whitemoshui Thank you for your contribution

@luu-alex
Copy link
Contributor

luu-alex commented Dec 2, 2024

Thanks for the PR, ill try it out this week and get back to you

Copy link
Contributor

@avkos avkos left a comment

Choose a reason for hiding this comment

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

@whitemoshui thank you for your contribution.
I have a question to @jdevcs . What will do in case if changes do not need to be in CHANGELOG.md file?
do we need to have the mechanism to commit without this check?

@jdevcs
Copy link
Contributor

jdevcs commented Dec 3, 2024

@whitemoshui thank you for your contribution. I have a question to @jdevcs . What will do in case if changes do not need to be in CHANGELOG.md file? do we need to have the mechanism to commit without this check?

do we need to have the mechanism to commit without this check?

yes

@whitemoshui
Copy link
Contributor Author

@whitemoshui thank you for your contribution. I have a question to @jdevcs . What will do in case if changes do not need to be in CHANGELOG.md file? do we need to have the mechanism to commit without this check?

I believe a CI task would be more suitable for this purpose. Pre-commit is a client-side validation, and exposing such a skip mechanism to all contributors would require a considerable learning cost.

green: text => `\x1b[32m${text}\x1b[0m`,
};

try {
Copy link
Contributor

@Muhammad-Altabba Muhammad-Altabba Dec 4, 2024

Choose a reason for hiding this comment

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

@whitemoshui
What about adding a check on the commit message, such that if it contains something like --skip changelog, then the returns without checking?
This way if someone wants to explicity avoid the changelog check, he/she will add --skip changelog to the end of his commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me have a try

@whitemoshui
Copy link
Contributor Author

I added --skip-changelog --sc check into the commit-msg hook. It may not follow the design pattern of the Husky since the commit-msg hook is used to refine the message. However, it works well. 😄

@whitemoshui
Copy link
Contributor Author

Hi~ Can we re-trigger the CI process?

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.

Git pre-commit hook for changelog updates
5 participants