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

Documents how to run linters in docker #8

Open
viroulep opened this issue Sep 22, 2023 · 2 comments
Open

Documents how to run linters in docker #8

viroulep opened this issue Sep 22, 2023 · 2 comments

Comments

@viroulep
Copy link

How do you guys do it these days?

I've tried a naive docker compose exec wca_on_rails bash -c "RAILS_ENV=development BUNDLE_GEMFILE=Gemfile bundle exec overcommit --run", but it failed with:

Unable to determine location of GIT_DIR. Not a recognizable Git repository! (Overcommit::Exceptions::InvalidGitRepo)

Because the ownership in the mounted volume looks weird to git:

root@13d2792a7393:/app# git status
fatal: detected dubious ownership in repository at '/app'
To add an exception for this directory, call:

	git config --global --add safe.directory /app

Running the suggested command let me ran the CI's overcommit commands, but expectedly it changes the .git/config file and sets the ownership to root (which is not what I would expect/like).

One of these must be true:

  • you have an alternate way of running overcommit locally, and it would be great to document it :)
  • you don't run overcommit locally and rely on the CI to tell when your code is wrong (:scream:)
  • you do it the way I did, and in these cases I'd suggest to not use root as the container's user (using user id 1000 is better than nothing, but ideally we'd get the user id to use from the mounted volume)

Apart from that running overcommit the way I did mostly worked, even though it did complain about the commit information:

Running pre-commit hooks
Check for author name....................................[AuthorName] FAILED
Author name must be non-0 in length.
Set your name with `git config --global user.name "Your Name"` or via the GIT_AUTHOR_NAME environment variable
Check author email......................................[AuthorEmail] FAILED
Author has an invalid email address: ''
Set your email with `git config --global user.email [email protected]` or via the GIT_AUTHOR_EMAIL environment variable

(the commit information are actually correct, I think it may be confused because of the aforementioned difference in container/host users)

@gregorbg
Copy link
Member

I can't speak for the whole team, but I personally do rely on the CI for the Overcommit hooks.
I don't perceive the code as being "wrong", and the entire Overcommit "chain" is so lengthy, complicated to setup -- and cumbersome in the way that it mangles your git installation with sign, pre-sign, verify and whatnot... -- that the trouble of setting it up is just not worth it for me

@FinnIckler
Copy link
Member

FinnIckler commented Sep 22, 2023

I just run rubocop and eslint locally and rely on the CI for everything else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants