Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TT-13669] Add pre-commit, pre-push hooks (#6733)
<details open> <summary><a href="https://tyktech.atlassian.net/browse/TT-13669" title="TT-13669" target="_blank">TT-13669</a></summary> <br /> <table> <tr> <th>Summary</th> <td>Add pre commit hooks to run task lint</td> </tr> <tr> <th>Type</th> <td> <img alt="Task" src="https://tyktech.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium" /> Task </td> </tr> <tr> <th>Status</th> <td>In Dev</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td>-</td> </tr> </table> </details> <!-- do not remove this marker as it will break jira-lint's functionality. added_by_jira_lint --> --- ### **User description** <!-- Provide a general summary of your changes in the Title above --> ## Description This PR adds pre commit hook scripts to the project. A task command `setup` is also added, so that a new contributor can have the dependencies installed and pre commit hook setup locally. ## Related Issue https://tyktech.atlassian.net/browse/TT-13669 ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] 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 change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why ___ ### **PR Type** Enhancement, Documentation ___ ### **Description** - Introduced a pre-commit hook script (`scripts/pre-commit.sh`) to enforce linting before commits. - Added a `setup_hooks` task in `.taskfiles/deps/Taskfile.yml` for setting up pre-commit hooks. - Updated `Taskfile.yml` with a new `setup` task to streamline project initialization, including dependencies and hooks. - Enhanced `CONTRIBUTING.md` with instructions on using Task commands for setup and testing, emphasizing the new pre-commit hook setup. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>pre-commit.sh</strong><dd><code>Add pre-commit script for linting enforcement</code> </dd></summary> <hr> scripts/pre-commit.sh <li>Added a pre-commit script to run linting tasks before commits.<br> <li> Ensures commits are aborted if linting fails.<br> <li> Provides feedback on linting success or failure.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6733/files#diff-daf6c6cbb9aa58db0628121a2e695ff3ec13927c9b3641aebc8f2be89d231552">+14/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>Taskfile.yml</strong><dd><code>Add task for pre-commit hook setup</code> </dd></summary> <hr> .taskfiles/deps/Taskfile.yml <li>Added a <code>setup_hooks</code> task to set up pre-commit hooks.<br> <li> Updated the <code>default</code> task to include <code>setup_hooks</code>.<br> <li> Defined commands for copying and enabling the pre-commit script.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6733/files#diff-bd2d25e8a19db2d54ea34295acdc50b5402b7469eaf3e16b083f3e66dbe4fd9d">+9/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>Taskfile.yml</strong><dd><code>Add setup task for project initialization</code> </dd></summary> <hr> Taskfile.yml <li>Added a <code>setup</code> task to install dependencies and pre-commit hooks.<br> <li> Linked <code>setup</code> task to <code>deps:setup_hooks</code> for hook setup.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6733/files#diff-cd2d359855d0301ce190f1ec3b4c572ea690c83747f6df61c9340720e3d2425e">+6/-0</a> </td> </tr> </table></td></tr><tr><td><strong>Documentation</strong></td><td><table> <tr> <td> <details> <summary><strong>CONTRIBUTING.md</strong><dd><code>Update contributing guide with Task commands</code> </dd></summary> <hr> CONTRIBUTING.md <li>Updated documentation to include Task commands for setup and testing.<br> <li> Added instructions for setting up pre-commit hooks using <code>task setup</code>.<br> <li> Improved clarity on using Task for local development.<br> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6733/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055">+10/-2</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information
- Loading branch information