-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix: use relative paths to working directory in annotations #116
fix: use relative paths to working directory in annotations #116
Conversation
c4abf54
to
2c0260d
Compare
Can you please undo the formatting changes? Not sure why the code was entirely reformatted. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #116 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 664 666 +2
Branches 137 166 +29
=========================================
+ Hits 664 666 +2 ☔ View full report in Codecov by Sentry. |
2c0260d
to
f90ec1c
Compare
There are still a lot of random formatting changes which obscure the fix. |
f90ec1c
to
f481bae
Compare
Yes, sorry, had prettier enabled by default in VSCode, should be good now |
Thanks. It's not clear to me how this is correct; the working directory option is pyright-action specific, so how does GitHub understand anything's about the annotations being relative to any random dir like this? I could be in a deeply nested dir and emit an annotation for |
In my case I'm running pyright-action from within a container that already has all the dependencies and code in it, e.g. in I agree that this wouldn't work for running pyright in nested directories though. Would you consider adding a separate input to change the project root path, which would be used for relative paths instead? |
Also, thanks for the very quick response |
Can you provide a link to a workflow where this isn't working today?
I'm not 100% sure what you mean by this, but it sounds like you're asking for a flag which just does that this PR does conditionally, but it's not clear to me how this relative path stuff even works period. I can imagine needing to do things relative to the original working directory for some weird reasons, but no matter what that sure sounds like a workaround for a GitHub bug or something... |
Will create a small example repo and get back to you. I'll switch the PR to draft for now. |
Added demo PRs:
Let me know if you can access workflow logs. In both you can see the errors in the workflow summary, but only the second one has the annotations in the diff. Basically, GitHub has no way of knowing that |
I assume GitHub actions has some magic that converts absolute paths within the workspace to relative paths, which is why it works now. |
Alternative solution, which adds |
Ah, so this is actually to do with the fact that this workflow is running within a docker container? I can see how this wouldn't be working right, yeah. I guess GitHub's own annotation examples don't indicate that the paths can be absolute. There may be a more general fix that needs to happen here; |
The problem I can see is that it's possible to say, |
Is there any chance you could rerun the "broken" workflow again with debug logging enabled? There should be a button for it at the top right of https://github.com/codequest-eu/pyright-action/actions/runs/9286266122/job/25552623528?pr=3 |
done https://github.com/codequest-eu/pyright-action/actions/runs/9286266122/job/26018045227
Looking at
However, if you decide that this is not a supported use case then that's perfectly fine. In the meantime, I'll try the suggestion from actions/checkout#841 (comment) to use the root user in the container, which might fix |
Ran my workflow as root with I don't like running containers as root, but in this context it might be good enough. Closing the PR, since it might overcomplicate this action for a niche use case. |
Thanks for running that; annoyingly, they don't seem to log anything about how they're handling the annotations.
I was mainly meaning that in context of the annotations, but it's definitely telling that they seem to want you to keep your code in I do think there's a real problem here, though; definitely need to figure this out, but will definitely take me attempting to reverse engineer it a bit... |
pyright outputs absolute paths in diagnostics and that's what is currently provided when creating GitHub annotations.
When a working directory is provided, which is outside of the GitHub workspace path, annotations would show up in the workflow summary, but wouldn't appear in the diff.
This PR changes the absolute paths in annotations to relative to the specified working directory to fix this problem.
Absolute paths will still be reported when
working-directory
is omitted. I tried to change that, but some tests failed and I didn't want to make broad changes.