document how to run inside docker in github actions
Issue
basedpyright is a breeze to setup on the CI that is unless for some reason one is using it inside docker on CI. Then it is somewhat annoying to figure out what to do.
Would it be worthwhile to have it cater to this usecase?
I am (honestly) unsure about it. Maybe the people involved on this project can comment.
However if you fine folks decide that this feature does not belong here then I urge you to at-least add the following info to the documentation in case someone else runs into a similar situation.
Workaround
Here is how I achieved running it inside docker on github actions.
set -o pipefail
docker run --env GITHUB_ACTIONS=true <tag of the container> basedpyright \
| sed 's|/app/|backend/|g' \
| tee /dev/tty
exit ${PIPESTATUS[0]}
basepyright uses GITHUB_ACTIONS environment variable to figure out if it needs to output "github workflow commands". The issue is when you are inside docker this environment variable does not exist. So, you need to set this explicitly.
sed 's|/app/|backend/|g': Since we copy our project into a different folder inside the Docker container, running basedpyright outputs absolute paths. GitHub Actions workflow commands ignore these absolute paths, so to make the annotations work, we replace /app/ with the relative path inside the repository (backend/ in this case). This ensures the paths in the workflow commands match the repository structure and the annotations appear correctly.
the environment variable seems easy enough to just pass using the --env argument. i believe if you omit the value it will use the value from the host environment.
as for the paths to the files, it sounds like that can be fixed by just changing the working directory to the location of the project before running basedpyright (which you should probably do anyway, otherwise you will probably encounter other issues with imports and stuff like that)
so i think your example can be simplified to something like this:
docker run --env GITHUB_ACTIONS <tag of the container> cd /app && basedpyright
In general what you said should work. In this example it is part of a monorepo so you need to do the sed based replacements. But that part should not be something that basedpyright should have to worry about. This is github workflow commands quirk that one needs to be aware off.
I just think the --env argument part should be in the docs.
Also, kudos on such a fast response and feel free to close this as not applicable.
I just think the
--envargument part should be in the docs.
happy to add this. i intended this feature to "just work" out of the box without any config or additional cli arguments, but i didn't consider the use case of running it inside docker