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(pre-commit): add pre-commit #259

Merged
merged 2 commits into from
Oct 3, 2020
Merged

Conversation

dafyddj
Copy link
Contributor

@dafyddj dafyddj commented Sep 21, 2020

Making a start on this.

Think rolling this out is best done in stages:

  • keep yamllint files and ignores in .yamllint
  • roll out to all formulas
  • remove standalone lint jobs
  • move yamllint files and ignores from .yamllint to .pre-commit-config.yaml; and
    • implement shellcheck.exclude_paths in .pre-commit-config.yaml

Things to resolve in this PR:

  • start formula by formula?
  • handle use_single_job_for_linters: false
  • what about docs?

@pull-assistant
Copy link

pull-assistant bot commented Sep 21, 2020

Score: 1.00

Best reviewed: commit by commit


Optimal code review plan

     feat(pre-commit): add pre-commit

Powered by Pull Assistant. Last update 796fb1e ... 796fb1e. Read the comment docs.

@dafyddj dafyddj force-pushed the feat/add-pre-commit branch from 89ddaf2 to e30e1ee Compare September 23, 2020 20:52
@dafyddj
Copy link
Contributor Author

dafyddj commented Sep 23, 2020

@myii ready for further testing!

@myii
Copy link
Owner

myii commented Sep 23, 2020

@dafyddj In progress: https://saltstack-formulas.zulipchat.com/#narrow/stream/239693-CI/topic/pre-commit.2F2020-W39_02.

Already completed the first one (apache-formula) which failed on the rstcheck. Decided to comment that out for the time being, so that we use the same linters on both sides. Then reran it and it passed (showing as fixed), so I think that's a better way to go through the whole batch. So now running across all formulas.

@myii
Copy link
Owner

myii commented Sep 23, 2020

@dafyddj After starting that run, I realised we could get even better results by only running the rubocop linter when it isn't configured as a separate job (allowed to fail). Also, noticed some yamllint failures being caused in .travis.yml due to the Zulip notifications section. Fixed both of those and now I'm expecting this run to be the most useful to compare between the lint jobs:

@myii
Copy link
Owner

myii commented Sep 24, 2020

@dafyddj Working through the four failures:

Formula Error Situation
devstack link Fails yamllint, should ignore test/**/states/**/*.sls
eclipse link Fails shellcheck, should only run across certain files (i.e. git ls-files -- '*.sh' '*.bash' '*.ksh' | xargs shellcheck)
lynis link Fails yamllint, should ignore test/**/states/**/*.sls
postfix link Fails yamllint, should ignore test/**/states/**/*.sls

So just the two types of problems to resolve.

@dafyddj
Copy link
Contributor Author

dafyddj commented Sep 27, 2020

saltstack-formulas/postfix-formula#115
saltstack-formulas/lynis-formula#10
saltstack-formulas/eclipse-formula#35
saltstack-formulas/devstack-formula#48

@myii fixes for the failures - pre-commit is actually correct here, these are linting failures to be fixed

@myii
Copy link
Owner

myii commented Sep 28, 2020

@dafyddj Well, that's embarrassing! I mixed up the two blocks when evaluating the situation and writing the last message:

ignore:
default:
- 'node_modules/'
additional_ssf:
- 'test/**/states/**/*.sls'

additional_ssf:
- '*.example'
- 'test/**/*.sls'

So another victory for pre-commit! I suppose our current yamllint is having some issue with the Python 2 version that's being installed.


Thanks for pushing through all of the fixes and it's nice to see them merged so quickly. I did notice an issue with the lynis-formula fix, so I pushed another commit, as mentioned here.


So that leaves us with our shellcheck linter in the eclipse-formula. The rationale behind restricting the files checked (i.e. git ls-files -- '*.sh' '*.bash' '*.ksh' | xargs shellcheck) is that I came across some formulas where shell files were being used as file templates, containing Jinja in them at times. I didn't fancy having the linter messing with these templates and so restricted to the actual shell files executed by the formula itself. So how do you feel about doing the same with pre-commit?

@dafyddj dafyddj force-pushed the feat/add-pre-commit branch from e30e1ee to 796fb1e Compare September 30, 2020 12:16
@dafyddj
Copy link
Contributor Author

dafyddj commented Sep 30, 2020

To summarize our discussion, for now we will stick to the status quo of shellchecking '*.sh' '*.bash' '*.ksh'. In the future I would like to consider checking files without extension (i.e. pre-commit option types: [shell], excluding zsh and possibly '*.shell') so that we can check commands such as bin\install-hooks.

@myii
Copy link
Owner

myii commented Sep 30, 2020

To summarize our discussion, for now we will stick to the status quo of shellchecking '*.sh' '*.bash' '*.ksh'. In the future I would like to consider checking files without extension (i.e. pre-commit option types: [shell], excluding zsh and possibly '*.shell') so that we can check commands such as bin\install-hooks.

@dafyddj All fixed!

Now to rerun everything with rstcheck enabled and then push quick fixes to those formulas (hopefully). Will be appearing at the following location soon:

@myii
Copy link
Owner

myii commented Sep 30, 2020

@dafyddj The rstcheck is complete across all formulas at https://saltstack-formulas.zulipchat.com/#narrow/stream/239693-CI/topic/pre-commit.2F2020-W40_02. I count 21 formulas with failures there.

I haven't had a chance to look through in detail but there are some unexpected violations, which we may need to adjust for (probably fairly simple to fix in the files themselves, though):

myii added a commit that referenced this pull request Oct 2, 2020
Pre-requisite for pushing changes across formulas using #259 (`pre-commit`).
myii added a commit to myii/jetbrains-datagrip-formula that referenced this pull request Oct 2, 2020
@myii
Copy link
Owner

myii commented Oct 2, 2020

This PR is held up by #261, which shouldn't take too long to resolve.

@dafyddj
Copy link
Contributor Author

dafyddj commented Oct 2, 2020

Do we need to add docs for this?

@myii
Copy link
Owner

myii commented Oct 2, 2020

Do we need to add docs for this?

Do you mean across the formulas? That's not going to be easy, since we're not currently managing the docs/README.rst file. I've had some thoughts about how to approach this but nothing satisfactory so far. My suggestion is to push this out now so at least the pre-commit linting is being done in Travis. Then we can tackle the remaining situations.

As for this PR, I've got a commit to add to it, to finalise the structure.

@dafyddj
Copy link
Contributor Author

dafyddj commented Oct 2, 2020

I didn't realise that CONTRIBUTING.rst is in another repo. That's where I meant.

@myii
Copy link
Owner

myii commented Oct 2, 2020

I didn't realise that CONTRIBUTING.rst is in another repo. That's where I meant.

@dafyddj Sure, that file is managed from this repo, so please go ahead and update this PR with the necessary additions.

@dafyddj dafyddj force-pushed the feat/add-pre-commit branch from 796fb1e to e53c83b Compare October 2, 2020 16:44
@dafyddj dafyddj marked this pull request as ready for review October 2, 2020 17:03
@dafyddj dafyddj requested a review from myii as a code owner October 2, 2020 17:03
myii added a commit that referenced this pull request Oct 2, 2020
Pre-requisite for pushing changes across formulas using #259 (`pre-commit`).
myii pushed a commit that referenced this pull request Oct 2, 2020
# [1.212.0](v1.211.0...v1.212.0) (2020-10-02)

### Features

* **formulas:** capture recent changes across formulas ([bdce42d](bdce42d)), closes [#259](#259)
* **use_tofs:** use `legacy` setting to avoid managing/removing files ([f0c9018](f0c9018))
myii pushed a commit to saltstack-formulas/apache-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/apt-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/apt-cacher-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/arvados-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/systemd-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/telegraf-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/template-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/timezone-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/tomcat-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/ufw-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/users-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/varnish-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/vault-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/vim-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/vsftpd-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/zabbix-formula that referenced this pull request Oct 3, 2020
@myii
Copy link
Owner

myii commented Oct 3, 2020

@dafyddj All changes pushed across formulas (finally). A couple of things remain:

  1. Please rebase this PR on top of feat(formulas): capture recent changes across formulas #261, so that I can push the finalising commit (that I used locally).
  2. The documentation change you've made will only end up being seen in the main contributing guidelines, not every formula. So some of the wording probably needs to be adjusted, I'll comment inline to be a bit clearer.

myii pushed a commit that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/jetbrains-phpstorm-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/jetbrains-pycharm-formula that referenced this pull request Oct 3, 2020
myii pushed a commit to saltstack-formulas/mysql-formula that referenced this pull request Oct 3, 2020
@dafyddj dafyddj force-pushed the feat/add-pre-commit branch from e53c83b to bbd0149 Compare October 3, 2020 13:50
myii pushed a commit to saltstack-formulas/.github that referenced this pull request Oct 3, 2020
@myii myii force-pushed the feat/add-pre-commit branch from e65dc25 to 506b3bc Compare October 3, 2020 18:31
Copy link
Owner

@myii myii left a comment

Choose a reason for hiding this comment

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

We got there in the end! Thanks for providing this PR, it really helped to get this pre-commit out there.

@myii myii merged commit 4e62728 into myii:master Oct 3, 2020
@myii
Copy link
Owner

myii commented Oct 3, 2020

🎉 This PR is included in version 1.213.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@myii myii added the released label Oct 3, 2020
myii added a commit that referenced this pull request Oct 4, 2020
Completes #259 except for 5 remaining formulas.
myii pushed a commit that referenced this pull request Oct 4, 2020
# [1.214.0](v1.213.0...v1.214.0) (2020-10-04)

### Features

* **pre-commit:** enable/disable `rstcheck` as relevant ([f3a91e8](f3a91e8)), closes [#259](#259)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants