Open robin-wayve opened 2 years ago
You should be able to pass in multiple paths (you can on codespell CLI), so I guess it's a case of whether you can generate a list of changed files and pass it into an action. However this doesn't guarantee the outstanding issues won't be elsewhere in the files you're checking.
Given codespell doesn't really care about context, generating a list of the added/changed lines and checking them for typos might be best, perhaps combined with loads of blank padding in the files so they kept the same line numbers. Or probably more simply a filter to run on the output of codespell which removes warnings/errors on lines which weren't in the PR. This feels like something that may have been or could be solved more generally for annotations, rather than in an individual tool like this.
See also https://github.com/TrueBrain/actions-flake8/issues/35 although heed my warning about other breakages within those files.
You should be able to pass in multiple paths (you can on codespell CLI), so I guess it's a case of whether you can generate a list of changed files and pass it into an action.
Interesting, the documentation led me to believe it would be a single path since it says: "Indicates the path to run codespell in."
Is "path" really just the [files [files ...]]
in the codespell
usage? I'll experiment with it now.
seems like my assumption was correct https://github.com/codespell-project/actions-codespell/blob/2391250ab05295bddd51e36a8c6295edb6343b0e/entrypoint.sh#L45
Perhaps the documentation could be updated to make this clearer? I'd even go so far as to rename the argument from path
to files
in a major release. 😄
@robin-wayve can you please show an example of how you pass changes files in the current pr to this action?
@Justin-JHG you probably want an action that checks out the pull request HEAD instead of a merge commit and then do a git-diff --name-only
against the target branch (I can't remember what the Github Actions provided variable for that is).
Putting that list of files into an environment variable is one way to pass them to the codespell
action.
echo "PR_CHANGED_FILES=$(git diff --name-only ...)" >> $GITHUB_ENV
and then
path: ${{ env.PR_CHANGED_FILES }}
Thank you @robin-wayve 👍 I figured out the same and posted my full workflow in #65
It'd be nice if the annotations could be limited to files that changed or were added as part of the PR. If understand correctly right now, I can only limit the action to a single folder (
path
), or filter files out with globs (skip
) which does not quite cover this.If you are running with
only_warn
then its possible you'll end up with the same unaddressed misspells being annotated on every pull request (which could become quite noisy in a large monorepo).