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

Running pre-commit hooks reports ‘Passed’ upon execution failure #2646

Closed
sanmai-NL opened this issue May 16, 2023 · 6 comments
Closed
Labels
bug Something isn't working O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity

Comments

@sanmai-NL
Copy link
Contributor

Describe the bug

See title.

pre-commit 3.3.1

REPOSITORY TAG  IMAGE ID CREATED SIZE
docker.io/oxsecurity/megalinter v6 1c7b60f5df4d  6 weeks ago  7.89 GB

Pulling docker.io/oxsecurity/megalinter:v6 again does not update to a more recent container image.

To reproduce

Steps to reproduce the behavior:

  1. Run the pre-commit hook:
$ pre-commit run megalinter-full --verbose --hook-stage manual --all-files
Run MegaLinter...........................................................Passed
- hook id: megalinter-full
- duration: 5.21s

Pulling docker image oxsecurity/megalinter:v6 ... 
INFO: this operation can be long during the first use of mega-linter-runner
The next runs, it will be immediate (thanks to docker cache !)
e33ac88aea10: Already exists 
ea5757f4b3f8: Already exists 
659e073925cc: Already exists 
f56be85fc22e: Already exists 
a67c1d530a10: Already exists 
9c44c1393ea4: Already exists 
afbc5ffdda29: Already exists 
43fb8d690963: Already exists 
757892be48e6: Already exists 
a24e881083d5: Already exists 
0e8ed9c607e0: Already exists 
5a79bdc762e4: Already exists 
64b6d6b0795f: Already exists 
f6a4f892824d: Already exists 
ba1b9ce30829: Already exists 
e4a4afadac50: Already exists 
aa156ffab7b6: Already exists 
db30e32161de: Already exists 
639e9e7ae9fa: Already exists 
3dffddba4493: Already exists 
70e713691930: Already exists 
3bcd314bb71b: Already exists 
3599d55255c9: Already exists 
d2120260540f: Already exists 
02f7ace07655: Already exists 
312a1053ed86: Already exists 
be4cbea85304: Already exists 
02f971c95c45: Already exists 
74c21ffd2dd6: Already exists 
19761ce35d5f: Already exists 
1824df01d9cf: Already exists 
fc730778d0e0: Already exists 
5810ea28f7f8: Already exists 
c1e1e5270f21: Already exists 
f156e5cb6c22: Already exists 
d1830ea30566: Already exists 
68eea6869169: Already exists 
cbcdf6d4d5f5: Already exists 
d423ff415f4c: Already exists 
4f4fb700ef54: Already exists 
7b4363468a71: Already exists 
3a442bfe9619: Already exists 
fac0ae0899c6: Already exists 
b75620581bf8: Already exists 
577fb00977ca: Already exists 
56bb51687f9c: Already exists 
d555153ee4b3: Already exists 
a158769ba460: Already exists 
c1d08be393a3: Already exists 
38b21614b6f4: Already exists 
1c7b60f5df4d: Download complete 
docker.io/oxsecurity/megalinter:v6
Command: docker run --rm --name megalinter-full -v /var/run/docker.sock:/var/run/docker.sock:rw -v /Users/sanderhan/devel/gitlab.com/han-aim/research/u-shaped-assembly-cell/ai-process:/tmp/lint:rw -e APPLY_FIXES=all -e APPLY_FIXES=all -e CLEAR_REPORT_FOLDER=true -e LOG_LEVEL=warning -e MEGALINTER_FILES_TO_LINT=.gitattributes,.gitignore,.gitlab-ci.yml,.gitmodules,README.md,k8s/Containerfile.ai,k8s/pdm_install.sh,k8s/provision_image_build.sh,k8s/provision_image_runtime.sh,k8s/rsyncd.conf,pdm.development.lock,pdm.production.lock,pyproject.toml,src/ai/README.txt,src/ai/__init__.py,src/ai/__main__.py,src/predict/__init__.py,src/predict/test.py,src/train/__init__.py,src/train/detection.py oxsecurity/megalinter:v6
Skipped setting git safe.directory DEFAULT_WORKSPACE:  ...
Setting git safe.directory default: /github/workspace ...
Setting git safe.directory to /tmp/lint ...
[MegaLinter init] ONE-SHOT RUN
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/megalinter/run.py", line 9, in <module>
    linter = megalinter.Megalinter({"cli": True})
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/megalinter/MegaLinter.py", line 59, in __init__
    self.initialize_output()
  File "/megalinter/MegaLinter.py", line 737, in initialize_output
    os.makedirs(self.report_folder, exist_ok=True)
  File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/tmp/lint/megalinter-reports'
[config] Environment variables only (no config file found in /tmp/lint)

Expected behavior

Running pre-commit hooks reports ‘Failed’ or some other non-‘Passed’ result upon execution failure.

@sanmai-NL sanmai-NL added the bug Something isn't working label May 16, 2023
@Kurt-von-Laven
Copy link
Collaborator

Kurt-von-Laven commented May 16, 2023

I will need more details to be able to reproduce this issue. What platform are you running on? What is the relevant portion of your .pre-commit-config.yaml? What code does pre-commit exit with? In the meantime, my main suggestion is to use rootless Docker (or REPORT_OUTPUT_FOLDER: none on beta). If you happen to use GitHub Actions, you can use ScribeMD/rootless-docker. It looks to me like you are already on the latest version of MegaLinter.

@sanmai-NL
Copy link
Contributor Author

sanmai-NL commented May 17, 2023

I use Podman, which is rootless. I'm running under an up-to-date macOS.

I'm not asking to debug the underlying issue, I can understand the failure, since Podman has some stricter security settings than Docker Desktop out-of-the-box. My issue is about MegaLinter and/or pre-commit not detecting a failure when there is one. Should the exit status of pre-commit be non-zero, then the current ‘Passed’ status is problematic.

@nvuillam
Copy link
Member

nvuillam commented May 17, 2023

If you can not write into your folder, you can define variable REPORT_OUTPUT_FOLDER: none so you won't have the permission issue (but just have console logs)

@Kurt-von-Laven
Copy link
Collaborator

Kurt-von-Laven commented May 17, 2023

Ohhh, yeah, I could definitely see MegaLinter not working with Podman since our images are rootful. I am not at my desk right now, but I will try to reproduce the issue using Podman. It would still be helpful to know whether pre-commit exits non-zero so we can evaluate whether this issue can or should be fixed in MegaLinter and/or pre-commit. Another way of narrowing it down would be to run the command pre-commit is running directly.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Jun 18, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2023
@hinricht
Copy link

I am not at my desk right now, but I will try to reproduce the issue using Podman.

@Kurt-von-Laven I'm curious about your findings, I'm also using podman and I can't run megalinter with it (Maybe I'll start a new issue for this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity
Projects
None yet
Development

No branches or pull requests

4 participants