ZedThree / clang-tidy-review

Create a pull request review based on clang-tidy warnings
MIT License
88 stars 44 forks source link

Post Clang-Tidy Review cannot post comments with PRs from forks #82

Closed jcwchen closed 1 year ago

jcwchen commented 1 year ago

Hi team, thank you for the amazing work! It's very useful and I would like to apply this in our project.

However, after adding the CIs (0.12.1) with specifying split_workflow as mentioned in Readme, although the post comment can only work with internal PRs (coming from internal branch), for PRs coming from forks cannot post comments and have the following errors:

Error details

Run ZedThree/clang-tidy-review/post@ddfe311e5d[2](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:2)ee5ea096cedc21adcbdb8[3](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:3)c32f62b with: token: *** repo: onnx/onnx max_comments: 25 lgtm_comment_body: clang-tidy review says "All clean, LGTM! :+1:" annotations: false workflow_id: [4](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:4)62071477[5](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:5) /usr/bin/docker run --name c0442cfe5ce7bf5594cea8a1cc528edf97a72_8cf4f8 --label [6](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:6)c0442 --workdir /github/workspace --rm -e "INPUT_TOKEN" -e "INPUT_REPO" -e "INPUT_MAX_COMMENTS" -e "INPUT_LGTM_COMMENT_BODY" -e "INPUT_ANNOTATIONS" -e "INPUT_WORKFLOW_ID" -e "INPUT_PR_NUMBER" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/onnx/onnx":"/github/workspace" 6c0442:cfe5ce[7](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:7)bf5594cea[8](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:8)a1cc528edf[9](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:10)7a72 "--token=***" "--repo=onnx/onnx" "--max-comments=25" "--lgtm-comment-body='clang-tidy review says \"All clean, LGTM! :+1:\"'" "--workflow_id=4620714775" "--pr_number=" "--annotations=false" WARNING: Could not find metadata file ('clang-tidy-review-metadata.json') WARNING: Could not find review file ('clang-tidy-review-output.json') Attempting to automatically download review artifacts Traceback (most recent call last): File "/usr/local/bin/post", line 8, in sys.exit(main()) ^^^^^^ File "/usr/local/lib/python3.11/site-packages/clang_tidy_review/post.py", line 74, in main if args.pr_number is not None and int(args.pr_number) != int(metadata["pr_number"]): ^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base [10](https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723#step:3:11): ''

More details: https://github.com/onnx/onnx/actions/runs/4620790027/jobs/8171388723.

May I understand whether post comment from clang-tidy-review is supported for PRs coming from forks? If yes, how can I resolve this? Perhaps I miss some permission settings? Thank you for looking into it.

Dekker1 commented 1 year ago

I'm facing the same problem in the chuffed/chuffed repository.

The problem seems to stem from the fact that the file that the first job is supposed to create have cannot be found:

WARNING: Could not find metadata file ('clang-tidy-review-metadata.json')
WARNING: Could not find review file ('clang-tidy-review-output.json')

I've tried to make my CI configuration as close to the example in the README as possible, but still cannot make it work. I would love to know how to make it work.

ZedThree commented 1 year ago

Sorry about this, it's a tricky thing to test! @Dekker1 @jcwchen if one of you can try out #83 and see if it works for you, that would be very helpful!

Dekker1 commented 1 year ago

I'm happy to try, but must admit that I don't know how to use specific branches/commits/PRs of GitHub actions. Is there a different string that you use instead of ZedThree/clang-tidy-review@v0.12.2?

ZedThree commented 1 year ago

It should just be ZedThree/clang-tidy-review@fix-split-post-metadata

Dekker1 commented 1 year ago

The PR seems to work correctly, I now do get comments again on my PR: https://github.com/chuffed/chuffed/pull/120#issuecomment-1512248571