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

How to get intuitive usage when mixing file paths and ignore paths? #184

Open
ross-nordstrom opened this issue Mar 28, 2023 · 4 comments
Open

Comments

@ross-nordstrom
Copy link

ross-nordstrom commented Mar 28, 2023

I found when I use "exclude paths", then my filter always produces a false positive causing my workflow to do the wrong thing.

Example:

      - uses: dorny/paths-filter@v2
        id: services
        with:
          filters: |
            ui:
              - 'ui/**'
              - '!ui/README.md'
              - '!ui/cypress/**'

I see this is "expected" in the docs:
image

Use Case

I'm using this for a build matrix to only build services with code changes. I'm making use of the slick .changes property you produce for that:

  check-run-flags:
    outputs:
      services: ${{ steps.services.outputs.changes }}
  build:
    needs:
      - check-run-flags
    strategy:
      matrix:
        # See: https://stackoverflow.com/a/65434401/18401629
        node: ${{ needs.check-run-flags.services }}

Workaround

To make this work, I've switched my filters to ONLY use "include paths."

          filters: |
            ui:
              - 'ui/package*.json'
              - 'ui/angular.json'
              - 'ui/Dockerfile'
              - 'ui/Dockerfile'
              - 'ui/nginx.conf'
              - 'ui/src/**'
              - 'ui/ui/**/*.{yml,yaml}'

Expectation

When ! paths (exclude paths) are in the filter, the filter should be true iff any(include_paths) && all(exclude_paths).

Maybe my expectation is actually possible, and I'm just missing an option somewhere??

@makenosound
Copy link

I have exactly the same use-case described here, and would love to see it as a native option in the action.

@ja-leo
Copy link

ja-leo commented Aug 1, 2023

same here, it would be great to see this working with the excludes flag

@francisInfact
Copy link

Also have the same issue - expectation would be that the filter would be true if all rules match.

@DavidVaness
Copy link

DavidVaness commented Apr 22, 2024

I ran into this today, really cumbersome for us because I have 2 files per app per filter I need to ignore (package.json & CHANGELOG.md) in our monorepository. The consequence of targeting all subdirectories and files to ignore these, is a bit problematic because it if a dev adds a new file / directory it will be ignored then, very brittle this approach.

@dorny any ideas how to solve this? 🙏🏼

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

5 participants