-
Notifications
You must be signed in to change notification settings - Fork 187
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 tool config plus cmake-format #3606
Conversation
b9e7fd8
to
efd0c94
Compare
9d1793a
to
e209397
Compare
Codecov Report
@@ Coverage Diff @@
## python #3606 +/- ##
======================================
- Coverage 87% 87% -1%
======================================
Files 525 525
Lines 23398 23371 -27
======================================
- Hits 20583 20556 -27
Misses 2815 2815
Continue to review full report at Codecov.
|
840a561
to
99da7c9
Compare
Just my two cents: I'm not sure that adding |
@fweik once this is merged, we won't be able to call the shell scripts anymore, because the |
@jngrad yes, the alternative is to keep the find expressions. |
Btw. you already have to pip install the autopep8 package, the pycodestyle package and the cmake-format package due to the pinned versions. You will most probably do that via |
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.
ok from my side
interesting Traceback (most recent call last):
24 File "/home/espresso/.local/bin/pre-commit", line 7, in <module>
25 from pre_commit.main import main
26 File "/home/espresso/.local/lib/python3.5/site-packages/pre_commit/main.py", line 189
27 version=f'%(prog)s {C.VERSION}',
28 ^
29 SyntaxError: invalid syntax
30 Passed style check |
@KaiSzuttor We shouldn't delay #3421 any longer and start moving towards Python 3.6 every time our workflow breaks. espressomd/docker#160 moves the style check packages to the Ubuntu 20.04 image, it'll only be a matter of updating the yml file here to use Ubuntu 20.04 image instead of Ubuntu 16.04. |
but, do you understand where the error comes from? |
find . \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' -o -name '*.cuh' \) -not -path './libs/*' | xargs -r -n 5 -P 8 "${CLANGFORMAT}" -i -style=file || exit 3 | ||
find . \( -name '*.py' -o -name '*.pyx' -o -name '*.pxd' \) -not -path './libs/*' | xargs -r -n 5 -P 8 "${AUTOPEP8}" --ignore=E266,W291,W293 --in-place --aggressive || exit 3 | ||
find . -type f -executable ! -name '*.sh' ! -name '*.py' ! -name '*.sh.in' ! -name pypresso.cmakein -not -path './.git/*' | xargs -r -n 5 -P 8 chmod -x || exit 3 | ||
pre-commit run --all-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 think dash and bash return the error code of the last command, so if this line fails due to a Python3.6-specific f-string (Ubuntu 16.04 uses Python3.5), the shell script will keep going to the next instructions and return 0, unless we add the following:
pre-commit run --all-files | |
pre-commit run --all-files || exit 1 |
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.
Actually no, don't do that! pre-commit
returns 1 when it touched a 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.
Is there an older version of pre-commit
compatible with Python 3.5 that we can use?
I just realised that the issue is also that the packaged pip silently installs packages that may not be compatible with the python version. If you upgrade pip and try to install pre-commit in the container, you actually get: ERROR: Package 'pre-commit' requires a different Python: 3.5.2 not in '>=3.6.1' Installing an older version would not help because a dependency of pre-commit needs 3.6. |
You could explicitly install specific (python 3.5-compatible) versions of the dependencies to circumvent that problem. Of course, that means adding all dependencies to the Dockerfile. pip is a terrible package manager. |
I wonder whether this PR takes too much work from too many people.
Personally, I just run JN’s script before committing and that’s that.
Do we really want to follow through with this?
Or is my impression wrong, that this hasn’t converged to the point of just needing a review?
|
my impression is that sometimes we comment on PRs without having looked at the changes |
There wouldn't be so much friction if ICP machines had Clang-9 installed.
The It's also unclear to me why |
the issues came solely from the default pip version, I fixed it in espressomd/docker#162 |
closed for #3622 |
Fixes #3591
Depends on espressomd/docker#158
Description of changes: