Skip to content

config file for https://pre-commit.com/#5785

Merged
boegel merged 9 commits intoeasybuilders:developfrom
pescobar:pre-commit-config
Mar 21, 2018
Merged

config file for https://pre-commit.com/#5785
boegel merged 9 commits intoeasybuilders:developfrom
pescobar:pre-commit-config

Conversation

@pescobar
Copy link
Copy Markdown
Member

@pescobar pescobar commented Feb 6, 2018

This PR includes a config file for https://pre-commit.com/ which runs all these checks for any commit:

  • Runs autopep8 over python source (also for every .eb file)
  • check whether the files parse as valid python
  • trims trailing whitespace
  • Ensures that a file is either empty, or ends with one newline
  • Check for files that contain merge conflict strings
  • Check that the url to the old easybuild repo is not present

Many of these checks are also done by Travis but travis usually takes longer to run the checks and trigger the error so this could help to reduce Travis waiting time for common mistakes and also avoid commit messages like "typo fix".."style fix"...and similars one

Copy link
Copy Markdown

@asottile asottile left a comment

Choose a reason for hiding this comment

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

Otherwise, looks good! Hope you enjoy pre-commit :)

Comment thread .pre-commit-config.yaml Outdated
- id: check-merge-conflict

- repo: https://github.com/pescobar/pre-commit-hooks-easybuild
sha: master
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry about the drive-by review -- was just doing some googling and came across this.

Note that branch names aren't going to be repeatable and so they're discouraged

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@asottile Your feedback is much appreciated!

Comment thread .pre-commit-config.yaml Outdated
# so the hooks are deployed to .git/hooks
#
# See http://pre-commit.com for more information
# See http://pre-commit.com/hooks.html for more hooks
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

just a note, we recently switched to https :)

@boegel
Copy link
Copy Markdown
Member

boegel commented Feb 7, 2018

check whether the files parse as valid python

@pescobar Is that also done for easyconfig files? If so, that's not a good idea, since EasyBuild injects constants and stuff like that in the environment in which the easyconfig files are parsed, so they may not parse as Python code, but that doesn't necessarily mean they're broken...

@pescobar
Copy link
Copy Markdown
Member Author

pescobar commented Feb 7, 2018

@asottile thanks for the feedback!

I have created a tag v0.1 in https://github.com/pescobar/pre-commit-hooks-easybuild and pointed the pre-commit config to it. I also updated all the urls to use https

@boegel I have updated the config so the check-ast hook (python syntax check) doesn't apply to .eb files. For .eb files only pep8 is checked

@asottile
Copy link
Copy Markdown

asottile commented Feb 7, 2018

I think check-ast is probably a fine check @boegel ? It doesn't actually evaluate them -- just checks that they are valid syntax.

All of the currently checked in .eb files pass this:

$ git ls-files -- '*.eb' | xargs check-ast 
$ echo $?
0
$ git ls-files -- '*.eb' | wc -l
9493

@pescobar
Copy link
Copy Markdown
Member Author

@boegel I think this one is ready to merge. Please review?

Comment thread .pre-commit-config.yaml Outdated
- id: end-of-file-fixer
- id: check-merge-conflict

- repo: https://github.com/pescobar/pre-commit-hooks-easybuild
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@pescobar Wouldn't it be better to host this under easybuilders?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@boegel fine for me

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, then you should transfer ownership of that repo to the easybuilders organisation, via https://github.com/pescobar/pre-commit-hooks-easybuild/settings

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@boegel I have transferred the repo to the easybuilders organization

I have granted access permissions to all the maintainers in easybuilders. Please let me know if you think the permissions should be adjusted

Comment thread .pre-commit-config.yaml
- id: check-merge-conflict

- repo: https://github.com/pescobar/pre-commit-hooks-easybuild
sha: v0.1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

v0.1 is not a SHA?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's an unfortunate mistake, this is correct though (and tags are preferred here).

When I initially made the framework it only worked with sha1 references. It's confusing, but difficult to change (the oldest open issue in our tracker is to migrate this)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An update on this btw, the latest version of pre-commit supports rev as well as sha (originally part of v1.7.0)

@pescobar
Copy link
Copy Markdown
Member Author

@boegel what do you think about merging this one?

@pescobar
Copy link
Copy Markdown
Member Author

@asottile right now to define a custom pep8 config I am including an extra file .pep8 , see here https://github.com/pescobar/easybuild-easyconfigs/blob/a3136e8eef1d096149ff8e7eb9ddf1396408f349/.pep8

Is this the recommended approach or is there any way to include the custom pep8 config in .pre-commit-config.yaml ?

thanks in advance for your help!

@asottile
Copy link
Copy Markdown

@pescobar I usually keep them separate -- though any pep8 configuration could be set as args: [...] for the particular hooks.

The benefit to keeping them separate is the pre-commit hook will still read that configuration, but any other tool (IDE plugin, etc.) can also read it :)

@pescobar
Copy link
Copy Markdown
Member Author

@asottile thanks for the feedback! I will keep it in a separate file as you recommend

@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 21, 2018

@pescobar: You'll need to sync with develop first...

The PRs that got merged recently (#6045, #6047) in which you removed .pre-commit-config.yaml are causing conflicts between this PR and current develop.

boegel
boegel previously approved these changes Mar 21, 2018
@boegel boegel added this to the 3.6.0 milestone Mar 21, 2018
@pescobar
Copy link
Copy Markdown
Member Author

@boegel I have synced the repo with develop

@boegel boegel merged commit 8e41530 into easybuilders:develop Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants