bedstuystrong / automation_prime

0 stars 5 forks source link

Improve precommit hook #13

Closed maybejustmaybe closed 3 years ago

maybejustmaybe commented 3 years ago

Users should be able to do git operations outside of the container, and the precommit hook currently precludes that when committing. If we want users to do all git operations inside of the container then we should have better setup instructions to avoid permission issues.

leifwalsh commented 3 years ago

What fails when you run it outside the container? Presumably it can't find the tools to run? If this is a rare thing you do, you can do git commit --no-verify to skip them, is that sufficient or do we need the dev tools to be intrinsically smarter?

maybejustmaybe commented 3 years ago

I don't have python3.9 installed on my mac. And I would prefer not to have to install dev tools on may mac. Ideally we could always run the precommit hook in the container. Not sure how hard that would be to do with some light scripting (e.g. docker exec ...)

leifwalsh commented 3 years ago

Oh interesting, I was thinking we wouldn't want to assume you have docker.

I think we could publish a devcontainer image and make the precommit hook run docker run ... with something mounted in the right place. Probably inside the devcontainer we could make that work with docker-in-docker, or just try to guess whether you're already in a container and run things from that environment.

leifwalsh commented 3 years ago

Actually this is sort of a pain with pre-commit: arguably most of the point of that framework is to manage the installation of hooks and their dependencies that are defined in other repos (e.g. https://github.com/psf/black/blob/master/.pre-commit-hooks.yaml).

Let me think about this more.

In what scenario do all of these hold:

maybejustmaybe commented 3 years ago

Lol I think thats my scenario. I'd prefer to do my git and file operations (e.g. git mv or touch automation/foo.py) on my "local" checkout, and all my dev work inside of the container. I vaguely recall running into a permission issue when I was doing some operations locally and some inside of the container. IIRC it had something to do with files being owned by a user in the container not lining up with my mac user. This issue and the fact that I have git setup on my mac but not inside of the container are my only motivations here.

Feel free to tell me that I should just do everything inside of the container lol

leifwalsh commented 3 years ago

I think maybe you need something from https://code.visualstudio.com/docs/remote/containers#_sharing-git-credentials-with-your-container, I haven't run into any problems with this though. I think starting with "clone repository in devcontainer", vscode does all the right things (using https, setting up credential sharing) and I haven't noticed a problem. I'm guessing you cloned first, possibly with ssh auth, and then set up the container stuff, and maybe that's why you're hitting problems Dev and I didn't?

I would like to make it so that you can do everything inside of the container, but let's figure out how to make that the ideal experience for you. We might need to tweak some more things or document how to do dotfiles repos or something?

maybejustmaybe commented 3 years ago

Very helpful. I'll follow those instructions to get set up!