-
Notifications
You must be signed in to change notification settings - Fork 101
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
Adding a pre-commit hook in Beckn core specification repository #401
base: draft
Are you sure you want to change the base?
Conversation
solves issue #403 Summary of the Issue: |
@vbabuEM Please review this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rajaneesh, should we also make the pre-commit file itself as executable? If so please add that line to the instruction somewhere. Thanks
Thank you, @vbabuEM, for your review of the PR. I appreciate your insights, and I've taken your feedback into consideration. To address the point you raised, I've added an extra line to the README.md instructions. Thanks again for your time and input. Best regards, |
Hi @rajaneeshk90 please provide Testing steps in your PR. |
Description:
Dear Team,
This pull request introduces a crucial enhancement to our repository by implementing a pre-commit hook. This pre-commit hook is designed to ensure the prevention of OpenAPI syntactical errors in specification before changes are committed.
Issue addressed by this PR:
#403
Summary of the Issue:
Need a pre-commit hook for Open API syntax validation for Beckn core specification. The implementation of this script should prevent the introduction of any syntactical errors into the core specification with each new commit.
Changes Made:
A new directory named pre-commit-scripts is added in the root of the Beckn core protocol specification. A shell script is added in the pre-commit-scripts directory which will be called when a user tries to create a commit. The added shell script checks if the relevant files(listed below) are valid OpenAPI documents. The addition of pre-commit script will significantly reduce the likelihood of syntactical errors in the specified files.
The files being validated are:
How to configure the pre-commit scripts on your local machine:
Please follow the README.md file inside the pre-commit-scripts directory at the root of the protocol specification repository for setting up and configuring the hook locally.
Reviewer's guideline
[Note: Sample commands are provides in some of the below steps, these sample commands are tested on a unix machine. The users can choose to use the provided sample commands, but they are not restricted to it. They are free to use other commands to perform the below steps.]
Clone the protocol specification GitHub repository locally. Link to the repository is: https://github.com/beckn/protocol-specifications
Pull this PR on your local machine. Command: 'git fetch origin pull/401/head:test-pre-commit'. This command will create new branch named 'test-pre-commit' on your local machine.
Checkout on the 'test-pre-commit' branch of the cloned protocol specification repository. use the command 'git checkout test-pre-commit'. After successfully executing the checkout command, a new directory named 'pre-commit-scripts' gets created in the root of the repository.
Follow the steps mentioned in pre-commit-scripts/README.md to configure the pre-commit on your local machine.
Introducing a syntax error in the specification and committing the change:
Making a change in the specification (api/transaction/build/transaction.yaml) file which keeps the specification file a valid openAPI document.
[Note: It is not recommended to directly change the api/transaction/build/transaction.yaml file if we are adding/modifying the Beckn core protocol specification. To know how to contribute to the Beckn core protocol specification, please follow the instructions on the Beckn core protocol specification page. We are making direct changes in api/transaction/build/transaction.yaml here only to test this PR]
Benefits of the pre-commit script
Limitations of the pre-commit script:
if the users use '--no-verify' with the git commit command, they can skip the openAPI validation checks performed by the pre-commit-script.
How to tackle the limitations:
We can add a similar check on GitHub protocol specification repository in the form of a GitHub action. The GitHub action would run after a commit is pushed to the GitHub Beckn protocol specification repository.
I welcome any feedback, suggestions, or improvements you may have regarding this pull request.
Thank you for your time and consideration.
Rajaneesh