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

adding pre-commit install to make dev #6417

Merged
merged 7 commits into from
Jan 3, 2023
Merged

Conversation

justbldwn
Copy link
Contributor

@justbldwn justbldwn commented Dec 10, 2022

resolves #6269

Description

hey @dbeatty10 , I am opening this as a draft PR to review in reference to #6269. i can convert this to no longer be a draft if you are okay with this as a possible solution.

I noticed #6269 was open for adding pre-commit install to the CONTRIBUTING.md file. interestingly enough, the docs mention that make dev should install pre-commit for you here in the second sentence, but it's not currently doing that.

so far, this PR just adds pre-commit install as part of the make dev command in the Makefile, but I can also help add some docs to the CONTRIBUTING.md file to install pre-commit manually as an alternative to using the make dev command if you think it is necessary. i hope it's okay that this change is a bit out of scope for the requirements of the ticket, but this change should help contributors get setup more quickly to dbt-core as long as they are using the make commands.

let me know if there is anything else i can help contribute to this!

Checklist

@cla-bot cla-bot bot added the cla:yes label Dec 10, 2022
@dbeatty10
Copy link
Contributor

Thanks for picking this up @justbldwn! This is looking great ✨ -- let's run with it.

An argument could be made for creating a stand-alone rule within the Makefile for the pre-commit install, but I appreciate how your addition makes the minimal amount of changes to achieve the goals stated in #6269. Let's keep your approach as-is.

Two small suggestions:

  1. split the commands over two lines using && \ (like here) to match the existing conventions
  2. copy-paste the final commands here (similar to here)

Feel free to click the "Ready for review" button as soon as you're up for it 👍

@justbldwn justbldwn marked this pull request as ready for review December 12, 2022 18:51
@justbldwn justbldwn requested a review from a team as a code owner December 12, 2022 18:51
Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

For those who don't want pre-commit run automatically, could you add an additional make target (maybe "dev_req" that doesn't install pre-commit? Thanks.

@justbldwn
Copy link
Contributor Author

For those who don't want pre-commit run automatically, could you add an additional make target (maybe "dev_req" that doesn't install pre-commit? Thanks.

thanks for the feedback! i just added a dev_req script to the Makefile and added some details to the CONTRIBUTING.md for instructions of with and without pre-commit.

@dbeatty10
Copy link
Contributor

For those who don't want pre-commit run automatically

@gerda in which cases would we not want to install and run pre-commit? It seems like such a case would be the (rare) exception rather than the rule, no?

Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

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

Sorry for any churn here @justbldwn and @gshank

Hopefully we can come to a happy medium that:

  1. Gives explicit instructions how to install all the expected tooling
  2. Doesn't end up with longer and longer contributing file

My spicy take is that the contributing file should be closer to 100 lines long than 250 lines long so that it's more readable 🌶️ That's obviously outside of the focus of this PR, but still on my mind!

CONTRIBUTING.md Outdated
Comment on lines 112 to 117
#### Installation without `pre-commit`:
```sh
make dev_req
```
or, alternatively:
```sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the addition of the dev_req rule, adding this section makes sense on first blush.

But... the contributing file already seems unbearably long to me. I wish it was like 75% shorter rather than even just a few lines longer.

Anyone that knows good reasons why they don't want the pre-commit install step probably has keen enough eyes to know that they can omit it and just run:

pip install -r dev-requirements.txt -r editable-requirements.txt

This is a case in which "less is more" and we can just omit explicitly documenting how to do it.

Suggested change
#### Installation without `pre-commit`:
```sh
make dev_req
```
or, alternatively:
```sh

Copy link
Contributor

Choose a reason for hiding this comment

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

@gshank I would prefer to exclude additional instructions to describe how to omit installation of pre-commit hooks for three main reasons:

  1. Installing pre-commit hooks is the happy path!
  2. How to omit installation of pre-commit seems obvious without explanation needed
  3. More text makes it harder to read the document as a whole

How would you feel about going back to the more simple instructions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see no need to describe how to use dev_req. Just have a Makefile target.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good @gshank!

@justbldwn If you commit my two suggestions (including the one to remove the "Installation without pre-commit" section), I think we'll be good to go!

You'll probably want to make a final pass through your edits to make sure everything reads the way you want it to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dbeatty10 @gshank thank you both for the helpful feedback here! i just pushed up a new commit to remove a chunk from the CONTRIBUTING.md about using make dev_req, and instead just left instructions for using make dev. however, the dev_req target in the Makefile still exists for anyone that may want to use it.

Makefile Outdated
Comment on lines 23 to 26
dev: ## Installs dbt-* packages in develop mode along with development dependencies and pre-commit.
@\
pip install -r dev-requirements.txt -r editable-requirements.txt && \
pre-commit install
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a Make guru, but it seems like this would be more DRY if re-factored like this:

Suggested change
dev: ## Installs dbt-* packages in develop mode along with development dependencies and pre-commit.
@\
pip install -r dev-requirements.txt -r editable-requirements.txt && \
pre-commit install
dev: dev_req ## Installs dbt-* packages in develop mode along with development dependencies and pre-commit.
@\
pre-commit install

Copy link
Contributor Author

@justbldwn justbldwn Dec 21, 2022

Choose a reason for hiding this comment

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

i like this a lot - thanks for the tip! hadn't considered this, but it makes total sense this way. it should now be written this way in the latest commit (b4bf3b4)

Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

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

There's two little pieces I didn't notice earlier related to .PHONY targets.

I'm adding them as suggestions in this review, and then I'll go ahead and commit them afterwards.

Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
@dbeatty10 dbeatty10 self-requested a review December 23, 2022 02:32
Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

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

This looks ready to rock 🎸

Thanks for this contribution @justbldwn !

@dbeatty10 dbeatty10 requested a review from gshank December 23, 2022 02:42
@dbeatty10
Copy link
Contributor

Could you re-review @gerda?

One thing to take a look at: the changlog entry currently says kind: Fixes

Should it be kind: Docs or something else instead?

@dbeatty10 dbeatty10 merged commit 76fd12c into dbt-labs:main Jan 3, 2023
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.

[CT-1515] [Docs] pre-commit install
3 participants