Skip to content
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

Improve documentation on path option, or rename #38

Open
robin-wayve opened this issue Oct 20, 2021 · 8 comments
Open

Improve documentation on path option, or rename #38

robin-wayve opened this issue Oct 20, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@robin-wayve
Copy link

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).

@peternewman
Copy link
Collaborator

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.

@peternewman peternewman added the enhancement New feature or request label Oct 20, 2021
@peternewman
Copy link
Collaborator

See also TrueBrain/actions-flake8#35 although heed my warning about other breakages within those files.

@robin-wayve
Copy link
Author

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.

@robin-wayve
Copy link
Author

seems like my assumption was correct

res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1`

@robin-wayve
Copy link
Author

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 robin-wayve changed the title Only run against files that changed in a pull request Improve documentation on path option, or rename Nov 17, 2021
@Justin-JHG
Copy link

@robin-wayve can you please show an example of how you pass changes files in the current pr to this action?

@robin-wayve
Copy link
Author

@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 }}

@Justin-JHG
Copy link

Thank you @robin-wayve 👍
I figured out the same and posted my full workflow in #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants