-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fails to parse diff when a file has many (or no) changes #274
Comments
A possible solution from people experiencing the same issue: reviewdog/reviewdog#1696 (comment) |
Until we have a fix for this cpp-linter-action issue: cpp-linter/cpp-linter-action#274
Until we have a fix for this cpp-linter-action issue: cpp-linter/cpp-linter-action#274
According to the logs, the real problem is that a file in the list of changed files did not include the patch info. Let's walk through the logs.
This means the at you hit the problem reported in #249. The solution to that was to fall back to using GitHub's REST API in which each file's diff is parsed individually.
These repeated errors and warnings just mean that libgit2 (python binding) failed to parse the files' individual diff (which we have to assemble on the fly with limited information about each file's patch). This uses brute force regex patterns instead of libgit2's diff parsing algorithm. But then we find a file that doesn't include any patch information: Traceback (most recent call last):
File "/home/runner/work/_actions/cpp-linter/cpp-linter-action/v2/venv/bin/cpp-linter", line 8, in <module>
sys.exit(main())
File "/home/runner/work/_actions/cpp-linter/cpp-linter-action/v2/venv/lib/python3.10/site-packages/cpp_linter/__init__.py", line 46, in main
files = rest_api_client.get_list_of_changed_files(
File "/home/runner/work/_actions/cpp-linter/cpp-linter-action/v2/venv/lib/python3.10/site-packages/cpp_linter/rest_api/github_api.py", line 108, in get_list_of_changed_files
return self._get_changed_files_paginated(
File "/home/runner/work/_actions/cpp-linter/cpp-linter-action/v2/venv/lib/python3.10/site-packages/cpp_linter/rest_api/github_api.py", line 144, in _get_changed_files_paginated
assert "patch" in file
AssertionError This is one of the reasons we originally switched to getting the raw diff of the event instead of parsing each changed file's patch. It means that GitHub refused to give us the patch for a file with too many changes. WorkaroundIf you expect all your PRs to have a large diff, then you should disable any features that rely on having diff information. - uses: cpp-linter/cpp-linter-action@v2
id: linter
with:
lines-changed-only: false
files-changed-only: false
format-review: false
tidy-review: false Possible solution on our endI guess we could silently fail when a file's diff is unknown, but that will cause further unexpected behavior (like unreported syntax/format errors in files with too many changes). If GitHub won't give us the information we need, then we can't be expected to operate correctly. I have to investigate more... I think it would simply be better to improve the error message output. We should point to the file that didn't include the patch in the REST API's response. |
develop
but failing when syncing master
from develop
This didn't help. The solution there was specific to reviewdog software. |
The file in which Github didn't provide the patch info is named "include/libqasm/tree.hpp". According to the PR's diff, this file was renamed with no content changes. This means we need to add a check for content changes when trying to parse a diff for files without content changes. Should renamed files (with no code changes) get skipped when
|
I just published v2.13.3 with included fix. @rturrado you're next CI run in QuTech-Delft/libqasm#263 should automatically pull in the new release's changes. |
@2bndy5 wow, great thanks! That was a lightning fast support! Just a question. I saw your comments yesterday, but it was late to answer. In one of them you were suggesting to keep a few attributes set to false. In other one you were suggesting to keep |
That suggestion was a workaround that avoids needing a diff.
I think that suggestion was from a separate discussion about using the PR review feature for more concise feedback. SummaryThe PR review features ( The workaround that avoids using a diff should not be needed with v2.13.3. But it might be a good idea to keep in mind if you keep submitting PRs that have either
|
Perfect, I think I'll keep With that and your last fix we're playing safe. Thanks for all the detailed explanations! |
If we expect some of our PRs to have a large diff, then we should disable any features that rely on having diff information: - lines-changed-only, - files-changed-only, - format-review, and - tidy-review. For a more detailed explanation: cpp-linter/cpp-linter-action#274 (comment)
What events trigger your workflow?
What OS does your workflow use?
How is cpp-linter-action configured?
What was the unexpected behavior?
I'm getting this error from GitHub Actions:
You can see the full log here: https://github.com/QuTech-Delft/libqasm/actions/runs/11381786455/job/31663943797
I'm updating a
master
branch from adevelop
branch, and the PR includes over 500 files. But I don't see how that can affect the C++ linters.The text was updated successfully, but these errors were encountered: