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

Configured file excludes are not respected when running with changed-files: "true" #13

Open
dmweis opened this issue Oct 30, 2024 · 5 comments

Comments

@dmweis
Copy link

dmweis commented Oct 30, 2024

Hi,

It seems that when using changed-files: "true" the file excludes configured in a pyproject.toml at the root of the repository are not respected.

I believe this is because when using changed-files the action provides a direct list of files to the ruff command which overrides any files excludes in the config file.

The repository I have this issue is in private but I'd be happy to create a public one and replicate it if needed.

Thank you!

@DavidJFelix
Copy link
Contributor

This tracks with my understanding of how changed-files works in this repo. It seems like we'd have to parse the pyproject.toml here or change the way ruff works upstream to have it respect excludes when given files.

@dmweis
Copy link
Author

dmweis commented Nov 4, 2024

This tracks with my understanding of how changed-files works in this repo. It seems like we'd have to parse the pyproject.toml here or change the way ruff works upstream to have it respect excludes when given files.

Thanks for the fast reply!

Makes sense. Would you be open to accepting a PR that adds another config param that allows this action to ignore some directories? It doesn't feel like an ideal solution as it would mean having different file exclude handling for when changed-files is turned on. But it would be a simple workaround for some issues.

@DavidJFelix
Copy link
Contributor

DavidJFelix commented Nov 4, 2024

I'm not a maintainer here, just familiar with the setting. I'd be willing to help though!

Depending on what you're envisioning, this might already be possible. My reading of the CLI arguments says this might work:

- uses: astral-sh/ruff-action@v1
  with:
    args: 'check --exclude "foo,bar,foobar/*" --force-exclude'
    changed-files: 'true'

or

- uses: astral-sh/ruff-action@v1
  with:
    args: 'format --check --exclude "foo,bar,foobar/*" --force-exclude'
    changed-files: 'true'

This isn't quite as good as parsing the pyproject section, but might be similar to the workaround proposed.
I think @charliermarsh is envisioning some kind of overhaul for this action. An additional param could definitely make this cleaner and supply the flag in the correct position if we wanted.

@leon1995
Copy link

It seems that when using changed-files in combination with src only changed-files is respected

files_to_check = shlex.split(CHANGED_FILES or SRC)

Also, when using changed-files and args: check --exclude dir, changed files in dir are still checked. I think that changed-files: "true" will overwrite everything

@eifinger
Copy link
Collaborator

eifinger commented Dec 8, 2024

@dmweis with v2 the changed-files input was removed. The release message contains a workaround to directly use tj-actions/changed-files (which this action was doing before under the hood).

I would like to take you up on your offer to put up a public replication. Could you please do that with the above described use of tj-actions/changed-files?

Even though it is not a built-in part of this action anymore I want to make sure it works as smoothly as possible or at the very least be clear about it in the docs.

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

No branches or pull requests

4 participants