-
Notifications
You must be signed in to change notification settings - Fork 142
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
Feature: auto-fix for specific linters #439
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…arerequired-master # Conflicts: # yarn.lock
* 'master' of github.com:phamelink/lint-action: Update git.js Update index.js Update test-action.yml Update test-action.yml Update test.yml
…o fix by restoring changes made to the current branch to avoid committing and pushing modifications made by previous linters.
Feature: <linter_id>_auto_fix
phamelink
added a commit
to phamelink/devops-course
that referenced
this pull request
Apr 14, 2022
# Assignment Proposal ## Title Open source contribution on a [Lint Action](https://github.com/marketplace/actions/lint-action), an github action that shows linting errors and allows auto-fixing issues. ## Names and KTH ID - Philip Hamelink (ppjhad@kth.se) - Bastien Faivre (faivre@kth.se) ## Deadline Task 2: April 19, 17h ## Category Contribution to open-source ## Description We want to add a feature mentioned in this [issue](wearerequired/lint-action#426). Currently, this action allows to set auto-fixing linting errors for all linters. There has been a requested feature to only allow auto-fixing for certain linters, which we want to add ourselves. The repo has 329 ⭐ and 509 commits. The community is quite active. The issue was requested 7 days ago, and the author responded and labeled the issue with "help_wanted" 2 days ago. We believe this satisfies the requirements for the open-source contribution assignment as linting code on commits is an invaluabe feature in DevOps. Submission: In our [pull request](wearerequired/lint-action#439), we mention the issues we have had, and how we have come up with our final solution. We tested our new feature [here](https://github.com/phamelink/test-action-repo), where you can see the results from our action where we can specify which linters we want to automatically fix code issues. We believe we satisfy the following grading criteria: | | Yes | No | |-------------------------------------------- | ----|----| |bug: The contribution fixes bugs | Yes ✅ | No | |documentation: The contribution improves documentation | Yes ✅ | No | |feat: The contribution adds new features | Yes ✅ | No | |difficulty: The contribution is a difficult piece of engineering | Yes ✅ | No | |conversation: There is an interesting engineering conversation with the maintainers | Yes | No | |merge: The contribution is merged in the main branch.| Yes | No | We believe we fixed a small bug. Before, when auto-fix was set, when linters did not support auto-fixing there was a warning that could not be prevented. This can now be avoided when the input <linter>_auto_fix is set to `false` for a non auto-fix supporting linter. We improved documentation by adding information about our new feature (since there are new inputs in our version), and we also added an example for our feature. This contribution adds an obvious new feature as requested. Finally, we believe that even though the final changes were minimal and quite simple, this contribution was quite challenging as we had to figure out exactly where and when we needed to add a condition. We went through many stages, most involving manipulations with git to avoid committing and pushing certain files as was tried [here](https://github.com/phamelink/lint-action/tree/implementation) or with this [script](https://github.com/phamelink/lint-action/blob/test-branch/t.sh), or even restore files to their original state done in this [commit](phamelink/lint-action@1cd4c21).
ocean90
reviewed
Apr 14, 2022
Fix after PR comments
This was referenced Apr 16, 2022
khaes-kth
pushed a commit
to KTH/devops-course
that referenced
this pull request
Apr 20, 2022
* Proposal: Contribution to open-source * Submission: Open source contribution # Assignment Proposal ## Title Open source contribution on a [Lint Action](https://github.com/marketplace/actions/lint-action), an github action that shows linting errors and allows auto-fixing issues. ## Names and KTH ID - Philip Hamelink (ppjhad@kth.se) - Bastien Faivre (faivre@kth.se) ## Deadline Task 2: April 19, 17h ## Category Contribution to open-source ## Description We want to add a feature mentioned in this [issue](wearerequired/lint-action#426). Currently, this action allows to set auto-fixing linting errors for all linters. There has been a requested feature to only allow auto-fixing for certain linters, which we want to add ourselves. The repo has 329 ⭐ and 509 commits. The community is quite active. The issue was requested 7 days ago, and the author responded and labeled the issue with "help_wanted" 2 days ago. We believe this satisfies the requirements for the open-source contribution assignment as linting code on commits is an invaluabe feature in DevOps. Submission: In our [pull request](wearerequired/lint-action#439), we mention the issues we have had, and how we have come up with our final solution. We tested our new feature [here](https://github.com/phamelink/test-action-repo), where you can see the results from our action where we can specify which linters we want to automatically fix code issues. We believe we satisfy the following grading criteria: | | Yes | No | |-------------------------------------------- | ----|----| |bug: The contribution fixes bugs | Yes ✅ | No | |documentation: The contribution improves documentation | Yes ✅ | No | |feat: The contribution adds new features | Yes ✅ | No | |difficulty: The contribution is a difficult piece of engineering | Yes ✅ | No | |conversation: There is an interesting engineering conversation with the maintainers | Yes | No | |merge: The contribution is merged in the main branch.| Yes | No | We believe we fixed a small bug. Before, when auto-fix was set, when linters did not support auto-fixing there was a warning that could not be prevented. This can now be avoided when the input <linter>_auto_fix is set to `false` for a non auto-fix supporting linter. We improved documentation by adding information about our new feature (since there are new inputs in our version), and we also added an example for our feature. This contribution adds an obvious new feature as requested. Finally, we believe that even though the final changes were minimal and quite simple, this contribution was quite challenging as we had to figure out exactly where and when we needed to add a condition. We went through many stages, most involving manipulations with git to avoid committing and pushing certain files as was tried [here](https://github.com/phamelink/lint-action/tree/implementation) or with this [script](https://github.com/phamelink/lint-action/blob/test-branch/t.sh), or even restore files to their original state done in this [commit](phamelink/lint-action@1cd4c21). Co-authored-by: Bastien Faivre <57015770+BastienFaivre@users.noreply.github.com>
ocean90
requested changes
Apr 22, 2022
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.
This is looking good, just one minor doc change.
Co-authored-by: Dominik Schilling <dominikschilling+git@gmail.com>
ocean90
approved these changes
Apr 23, 2022
Nice job, thank you! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #426.
With @BastienFaivre, we added a feature to enable auto fix for specific linters requested in this issue #426.
We made several attempts at this, starting with using
<linter>_auto_fix
to only commit and push certain file extensions found in the input for each linter. When we realised that this wasn't very efficient as there could be edge cases where this would cause problems if some linters have common file extensions, we tried another way, where we would restore the branch at the start of every linter iteration. Finally, we realised that this actually wasn't necessary, as we could directly prevent a linter from auto-fixing by usingautoFix && linterAutoFix
as thefix
parameter in a linter'slint
function.We also made sure to add documentation about this feature in the README and made an example where this could be used (typically for linters like flake8 which do not support auto-fixing).
We tested these changes on this repo, and it seems to be working as expected.