-
-
Notifications
You must be signed in to change notification settings - Fork 768
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
Guidance on pre-commit + monorepos #466
Comments
Aww man I typed up a response to this and never pressed reply. I guess I'll try and remember what I said the first time! Though it's not explicitly designed for a monorepo I can imagine one way you could use the existing configuration to support this goal with a single configuration file. # configure shared hooks that you want to run on all repositories here
- repo: https://github.com/pre-commit/pre-commit-hooks.git
sha: v0.6.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
# For hooks that only apply to specific repositories, list them below
- repo: https://github.com/pre-commit/pre-commit-hooks.git
sha: v0.6.1
hooks:
- id: flake8
name: 'flake8 (for repo1)'
# Only run on repo1 files
files: '^repo1/.*\.py'
- id: flake8
name: 'flake8 (for repo2)'
# Only run on repo2 files
files: '^repo2/.*\.py'
# maybe repo2 wants specific argument configuration
args: [--max-line-length=131]
# maybe repo3 is python3 only
- id: flake8
name: 'flake8 (for repo3)'
files: '^repo3/.*\.py'
language_version: python3
# etc. Note that the same |
@snakescott any additional thoughts on this, does this seem reasonable? |
Going to close this as answered, haven't heard back in a few months. If this isn't sufficient, please comment and I'll reopen :) |
@asottile wouldn't that be beneficial to create "folders" array which is compiled into file regexp equal to |
I see no reason to have two ways to do things |
The problem with this approach is that you need to specify the path for each project multiple times. Without explicit support, I need to specify the project path 3 times for pylint:
Maybe adding a new "working_folder" hook field which just performs a "cd" before running the hook could be a quick win? thanks |
I'm not inclined to extend support for this:
fwiw you can optimize your configuration slightly by using: files: ^hubtype_babel/ (no need for |
One drawback is I think two different unrelated subfolders would clobber the other's config when you That means I can't really concurrently work on two projects in the same monorepo. |
if you name it anything other than |
The core issue is I can only have one |
you can likely adapt this solution |
Thanks for developing pre-commit! Back on the best practice, do you think it makes sense to have a pre-commit-config in each subfolder containing a library and then a config in the versioned controlled root folder, pointing at them?
Where the # .pre-commit-config.yaml
configs:
- subfolder1//pre-commit-config.yaml
- subfolder2//pre-commit-config.yaml ? In this way each library can be run independently and can have its own configuration (or read the configuration from its |
please don't grave dig 4 year old issues and no, that will not be implemented |
Any thoughts on using pre-commit in a monorepo (http://danluu.com/monorepo/) setting, with each project having its own
.pre-commit-config.yaml
file? For example, will pre-commit be happy/sad withpre-commit install
I expect to play around and experiment but any early guidance (e.g., "I have seen people try and fail at this, beware" or "Yelp actually does exactly this with steps X, Y, Z") is welcome!
The text was updated successfully, but these errors were encountered: