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

feat(action): Add support for force-exclude option #1096

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manic
Copy link

@manic manic commented Sep 10, 2024

When using typos with changed-files, the extend-exclude setting in the configuration file is ignored, leading to checks on unwanted directories.

This update ensures target directories are consistently ignored and avoids unnecessary validations.

@epage
Copy link
Collaborator

epage commented Sep 18, 2024

As for this change, I wonder if we should unconditionally set it like we do with pre-commit.

When using typos with changed-files

I'd be curious to see your setup for this

@coveralls
Copy link

Pull Request Test Coverage Report for Build 10783793421

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 22.867%

Totals Coverage Status
Change from base Build 10704630854: -0.03%
Covered Lines: 536
Relevant Lines: 2344

💛 - Coveralls

@manic
Copy link
Author

manic commented Oct 8, 2024

This is our current .github/workflows/typos.yml file with my patch:

name: Check typos
on:
  pull_request:
jobs:
  run:
    name: Spell Check with Typos
    runs-on: ubuntu-latest
    steps:
    - name: Checkout Actions Repository
      uses: actions/checkout@v4
    - name: Get changed files
      id: changed-files
      uses: tj-actions/[email protected]
    - name: Check spelling of file.txt
      if: ${{ steps.changed-files.outputs.all_changed_files != '' }}
      uses: manic/typos@master
      with:
        files: ${{ steps.changed-files.outputs.all_changed_files }}
        config: ./.typos.toml
        force_exclude: true

The goal is to only check the spelling for files that were changed in the pull request. This reduces the number of files to process, allowing for quicker feedback.

@epage
Copy link
Collaborator

epage commented Oct 8, 2024

allowing for quicker feedback.

How much of a time difference does that make?

@manic
Copy link
Author

manic commented Oct 9, 2024

@epage Sorry, after double-checking, there’s no noticeable time difference between running typos with a diff versus running it on all files.

However, our repositories include YAML files and settings that contain other languages and base64 strings, which are incorrectly flagged as typos. We need to ignore these to prevent the check from failing every time.

Here are some examples:

error: `Iy` should be `It`
  --> ./fixtures/vcr_cassettes/..../update_profile_business_token_invalid_token.yml:155:60
    |
155 |         e_proxy="AcLD8bfE3DYo_IwZea6jVgUFxE1h8SfVCg2Dspz0cDIy2xXX2DsBUa2JUEXRzlF9fO-wtLPs3tjpB_vraUVp",

error: `accout` should be `account`
  --> ./fixtures/vcr_cassettes/..../make_reservation_fail_due_to_more_than_allowed_quota.yml:1171:16
     |
1171 |         name=\"accoutID__c\" nillable=\"true\" minOccurs=\"0\" type=\"xsd:string\"/>\n
     |                ^^^^^^
     |

@epage
Copy link
Collaborator

epage commented Oct 9, 2024

Sounds like filtering what files are checked masks problems

  • This will show up if those files are edited or new files created
  • If you update typos (or have it auto-update), you won't find any new typos introduced until those files are touched
  • Running typos locally will fail

Seems like that should be fixed more generally, see https://github.com/crate-ci/typos?tab=readme-ov-file#false-positives. In particular, our refernece has examples of regexes to create directives for disabling typos within sections of files.

When using typos with changed-files, the `extend-exclude` setting in the
configuration file is ignored, leading to checks on unwanted
directories.

This update ensures ensurs target directories are consistently ignored
and avoids unnecessary validations.
@manic
Copy link
Author

manic commented Oct 15, 2024

@epage, I think there might be a slight misunderstanding regarding my patch.

In our GitHub workflow, we are using typos in combination with changed-files to check only the files modified in a PR.
We have also defined an extend-exclude list to ignore certain files or directories, such as the fixtures directory.
However, when a PR contains changes that include files from the fixtures directory, the typos check is still running on those files, despite being on the exclusion list.
After some investigation, we discovered that adding force-exclude is necessary to ensure that the extend-exclude settings work as expected and properly skip those directories.
In short, force-exclude is required to make sure our defined exclusions (like the fixtures directory) are respected during the typo checks.

@epage
Copy link
Collaborator

epage commented Oct 16, 2024

If the performance difference is negligable, why then care? I had thought the statement about YAML files was about why you cared but that appears to not be the case.

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

Successfully merging this pull request may close these issues.

3 participants