-
Notifications
You must be signed in to change notification settings - Fork 50
Conversation
@sarayourfriend we should remove the 'Style' job from the 'Automated tests' workflow as the new 'Linting' job supersedes it (the Flake8 check in 'Linting' already includes the |
Oops, I meant to remove it when I added the linting job 😅 It's gone now, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I only have some additional thoughts on the justfile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks pretty good! I just leave some suggestions and questions to evaluate.
2. Run the tests in a Pipenv subshell. | ||
``` | ||
pipenv run bash ./test/run_test.sh | ||
just testlocal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this by trying to run this command:
error: Justfile does not contain recipe `testlocal`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hmm I removed it for some reason. Let me see.
Do you know why these tests must run in a "pipenv subshell"?
Edit: Oh never mind, I see that the script calls to pytest
.
This is going to throw a wrench in the root Pipfile idea 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I run the tests inside the container, we can leave only those instructions for tests.
docker-compose exec web bash ./test/run_test.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's ever necessary to run it outside of the container 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes, I run the code outside the container when debugging it line by line (I like PyCharm's debugger GUI). Running the tests outside the containers helps in that scenario. I'm open to a different process though if I'm the only one using it like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Pycharm can take the interpreter of a container, it's quite flexible in this aspect. However, I can see the value in the local approach in not being tied up to this particular IDE, neither to the use of just
if that is what is blocking here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krysal from what I had read in the docs, PyCharm can work with a Docker environment only if it created the container. I wasn't able to get it to connect with the existing web
container orchestrated by Docker Compose 😢.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think that's true Dhruv, the docs might be incorrect. At my previous job we were able to get it to connect to the docker container just fine and it was running using docker compose... but maybe things have changed since then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, after making the changes in the latest commits we're able to add back the testlocal
script 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The testlocal
script works perfectly. So does the regular test
one.
@sarayourfriend this might be a silly suggestion but I was playing around with pre-commit in the current setup and came across something that might be a good compromise. Let's say we installed The hook created records the virtualenv that was active when Apart from having to list |
The real cons are for editor integration, but we're already sacrificing the best of editor integration (dependency knowledge) in the current set up, so I think what you propose is better. We can add it to both, but |
Let's use |
Co-authored-by: Krystle Salazar <krystle.salazar@ciens.ucv.ve>
Co-authored-by: Krystle Salazar <krystle.salazar@ciens.ucv.ve>
8813741
to
30ccacc
Compare
@dhruvkb I did as you suggested and it works great 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To finalise the changes, it'll be good to squash the commits in such a way that
- all formatting changes are squashed into one commit to avoid ruining Git blame
- all config changes are squashed into one commit (to make reviewing the PR easier)
.pre-commit-config.yaml
Outdated
- --ensure-newline-before-comments | ||
- --line-length=88 | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to match the official way their org is named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their docs show a GitHub URL. Let's use that.
- repo: https://gitlab.com/pycqa/flake8 | |
- repo: https://github.com/PyCQA/flake8 |
I wonder why the tests are still failing. I'll pull this locally to review so will also look into that then. |
@dhruvkb Sure, I can do that. Alternatively I could also merge using the |
I have no hard preferences, whatever is convenient for you is cool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll review this tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A linter, formatter and Git hook trio is a much needed addition to the repo! Thanks for doing this.
And with passing tests, I have a lot of confidence in this PR. Apart from all the breaking changes this'll cause in all other PRs (especially the big one #194), LGTM.
.pre-commit-config.yaml
Outdated
- --ensure-newline-before-comments | ||
- --line-length=88 | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their docs show a GitHub URL. Let's use that.
- repo: https://gitlab.com/pycqa/flake8 | |
- repo: https://github.com/PyCQA/flake8 |
.pre-commit-config.yaml
Outdated
- --per-file-ignores=*test*:E501,*__init__*:F401,*wsgi.py:E402 | ||
- --max-line-length=88 | ||
- --ignore=E203,W503 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these args won't be necessary as the hook will automatically use the config from .flake8
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't, unfortunately. pre-commit
runs hooks inside a virtualenv that doesn't include the root of your project, so it doesn't know any of your configuration files 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this locally and it seemed to work fine. Are you sure about it not working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarayourfriend for the hook, is it possible to provide a config path instead of defining the rules twice in two different locations? If not I think just leaving a note here should be enough that mentions the rules also being in the other file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm not sure 😅 I'd tried it in the past and it didn't work and I found some SO answers about it to confirm the issue, but if you've got it working I'll try it again!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it worked! I removed the duplicated config. Thanks for testing it out!
2. Run the tests in a Pipenv subshell. | ||
``` | ||
pipenv run bash ./test/run_test.sh | ||
just testlocal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The testlocal
script works perfectly. So does the regular test
one.
@sarayourfriend is there a possibility of holding the merge for this PR and merging other open PRs first? It'll be very hard to update them with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some indentation inconsistencies in the pre-commit config. Is it weird that pre-commit
didn't catch this?
Co-authored-by: Dhruv Bhanushali <dhruv_b@live.com>
Sure! I suppose it'd be easier to just let the repo settle down at some point and then redo this PR from scratch... the merge conflicts will be difficult to resolve either way (usually these types of PRs are best applied quickly before too much work is done in the meantime, but this one has taken longer 😞) so it'll be easy to just copy the configuration from this PR and then run the formatting. I guess can you let me know when you think this PR should be merged? Otherwise we'll be waiting forever for work to settle 🙂 At some point we just have to accept the complications. |
Oh also, indentation is fixed! Thanks for pointing it out. |
Closing in favor of #224 |
Fixes
Fixes #193 by @sarayourfriend
Fixes #187 by @sarayourfriend
Description
Adds
pre-commit
using the same configuration as theopenverse-catalog
with some modifications to ignore rules in certain files that were problematic.Also adds a
justfile
to make docker stuff easier.Technical details
I had to add some
noqa
comments for long strings (I wish flake8 would ignore strings...)I also added
.flake8
that mirrors the pre-commit configuration for flake8 so that editor integration will workTests
Checkout the branch and run
just install
thenpipenv run pre-commit run --all-files
and ensure that there are no errors reported.Checklist
Update index.md
).main
ormaster
).Developer Certificate of Origin
Developer Certificate of Origin