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

Exclude few folders in one filter #200

Open
oleksandr-kinship opened this issue Aug 30, 2023 · 3 comments
Open

Exclude few folders in one filter #200

oleksandr-kinship opened this issue Aug 30, 2023 · 3 comments

Comments

@oleksandr-kinship
Copy link

oleksandr-kinship commented Aug 30, 2023

Hey, have repo that include two folders, for which I don't want to run some steps, tried following:

      - uses: dorny/paths-filter@v2
        id: changes
        with:
          filters: |
            ga:
              - '!.github/**'
            infra:
              - '!infrastructure/**'
            ga-infra:
              - '!.github/**'
              - '!infrastructure/**'`

Got this results:

Results:
Filter ga = true
  Matching files:
  infrastructure/src/resources/liquibase.ts [modified]
  src/main/java/com/.../file.java [modified]
Filter infra = true
  Matching files:
  .github/workflows/document_tests.yml [modified]
  src/main/java/com/.../file.java [modified] [modified]
Filter ga-infra = true
  Matching files:
  .github/workflows/document_tests.yml [modified]
  infrastructure/src/resources/liquibase.ts [modified]
  src/main/java/com/.../file.java [modified] [modified]

ga and infra looks good, expected that some folders not match, but in ga-infra I expected to see only src/main/java/com/.../file.java because other excluded
Can you point me what I did wrong or this not possible to implement, tried to read picomatch not get answers ..

@y-takebe
Copy link

y-takebe commented Sep 3, 2023

@oleksandr-kinship

I had the same problem recently, but it seems that the negation operator is not supported.
Please also check the following related issue

I'd be happy if it's the same as GitHub's paths.

@oleksandr-kinship
Copy link
Author

@oleksandr-kinship

I had the same problem recently, but it seems that the negation operator is not supported. Please also check the following related issue

I'd be happy if it's the same as GitHub's paths.

Thanks, it works for single rule but not in combination..
so I was tried another action, for me in general it's less comfortable, but at least it works fine so far,
here is example

      - name: Get changes
        uses: tj-actions/changed-files@v38
        id: changes
        with:
          files_yaml: |
            non-infra:
              - '!.github/**'
              - '!infrastructure/**'
              
      - name: Log non-infra changes
        shell: bash
        run: |
          echo "Is there changes for non-infra: ${{ steps.changes.outputs.non-infra_any_changed}}"
          echo "List of all non-infra changed files: ${{ steps.changes.outputs.non-infra_all_changed_files }}"

@Qix-
Copy link

Qix- commented Jan 19, 2024

It appears that !foo is returning a list of files from the entire folder that do not match foo, instead of culling the existing filepaths from other lines. The underlying minimatch/picomatch libs are working as expected.

In our case, our filter was previously

- 'app-*/**'
- '!app-ui/**'

but I'm pretty sure that resulted in a union of:

  • everything in app-*/** (including app-ui)
  • plus everything that didn't match `app-ui/**

resulting in a file list that includes everything in the folder as triggering a rebuild.

Instead, we changed to

- 'app-!(ui)/**'

which is what we wanted. That syntax is described on picomatch's docs, which is what this action uses.


Quick other note: make sure to put the strings in quotes since YAML treats *, ! and & and whatnot as special characters (anchors, tags, etc.)

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

3 participants