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

[BUG] files_ignore used with files not ignoring as expected #901

Closed
3 tasks done
koshy1123 opened this issue Dec 29, 2022 · 8 comments · Fixed by #902 or #923
Closed
3 tasks done

[BUG] files_ignore used with files not ignoring as expected #901

koshy1123 opened this issue Dec 29, 2022 · 8 comments · Fixed by #902 or #923
Labels
bug Something isn't working

Comments

@koshy1123
Copy link

koshy1123 commented Dec 29, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Does this issue exist in the latest version?

  • I'm using the latest release

Describe the bug?

Maybe I'm misunderstanding the capabilities of these two levers, but I used files_ignore and files in conjunction, but the outputs of this action is undesirable for my use case. By using files_ignore, I want to exclude files listed in that section from being considered as "changes", but that's not what's happening.

The closest I could find was this issue: #675 but it looks like that was user error - hoping that's the same here.

To Reproduce

  1. Set up a folder structure as so:
.
├── products/
│   ├── gri/
│   │   └── {package code}
│   └── README.md
└── README.md
  1. Set up actions as so:
- name: Get changed folders
  id: changed-folders
  uses: tj-actions/changed-files@v35
  with:
    json: "true"
    dir_names: "true"
    dir_names_max_depth: 2
    files_ignore: |
      **/docs/**
      **.md
    files: |
      products/**
  1. If I make a change to the file products/README.md and some nested file under products/gri, I expected the output to be a list with one element products/gri, but what I get is a list of two elements: products/gri AND products.

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

I thought by specifying files_ignore: **.md, it wouldn't capture products as a changed directory, since the only change in that directory is the README.md file.

I expected the output to be a list with one element products/gri, but what I get is a list of two elements: products/gri AND products.

Relevant log output

2022-12-29T20:52:51.4277434Z ##[debug]file patterns: packages/**
2022-12-29T20:52:51.4277736Z ##[debug]products/**
2022-12-29T20:52:51.4281309Z ##[debug]excluded file patterns: !**/docs/**
2022-12-29T20:52:51.4281588Z ##[debug]!**.md
2022-12-29T20:52:51.4286486Z ##[debug]file patterns: /home/runner/work/uf-team-data/uf-team-data/packages/**
2022-12-29T20:52:51.4286925Z ##[debug]/home/runner/work/uf-team-data/uf-team-data/products/**
2022-12-29T20:52:51.4287321Z ##[debug]!/home/runner/work/uf-team-data/uf-team-data/**/docs/**
2022-12-29T20:52:51.4287689Z ##[debug]!/home/runner/work/uf-team-data/uf-team-data/**.md
2022-12-29T20:52:51.4288068Z ##[debug]!/home/runner/work/uf-team-data/uf-team-data/.git/**
2022-12-29T20:52:51.4288464Z ##[debug]!/home/runner/work/uf-team-data/uf-team-data/**/node_modules/**
2022-12-29T20:52:51.4288861Z ##[debug]!/home/runner/work/uf-team-data/uf-team-data/node_modules/**
2022-12-29T20:52:51.4289741Z ##[debug]followSymbolicLinks 'true'
2022-12-29T20:52:51.4290738Z ##[debug]matchDirectories 'true'
2022-12-29T20:52:51.4338697Z ##[debug]followSymbolicLinks 'true'
2022-12-29T20:52:51.4339489Z ##[debug]implicitDescendants 'true'
2022-12-29T20:52:51.4340429Z ##[debug]matchDirectories 'true'
2022-12-29T20:52:51.4341159Z ##[debug]omitBrokenSymbolicLinks 'true'
2022-12-29T20:52:51.4343934Z ##[debug]Search path '/home/runner/work/uf-team-data/uf-team-data/packages'
2022-12-29T20:52:51.4357877Z ##[debug]Search path '/home/runner/work/uf-team-data/uf-team-data/products'
2022-12-29T20:52:51.4977328Z ##[debug]followSymbolicLinks 'true'
2022-12-29T20:52:51.4982220Z ##[debug]matchDirectories 'true'
2022-12-29T20:52:51.5116826Z ##[debug]followSymbolicLinks 'true'
2022-12-29T20:52:51.5117718Z ##[debug]implicitDescendants 'true'
2022-12-29T20:52:51.5118742Z ##[debug]matchDirectories 'true'
2022-12-29T20:52:51.5119497Z ##[debug]omitBrokenSymbolicLinks 'true'
2022-12-29T20:52:51.6100393Z Retrieving changes between 9dd49cb6d808f9b3fedca3bbe627d2387ac9f1cc (main) → bd70ae13f7a2c353b21424925f025cafff6f38ac (koshy-ignore-md)
2022-12-29T20:52:52.0907419Z ##[debug]Matching changed files: products|products/gri
2022-12-29T20:52:52.1324336Z ##[debug]Non Matching changed files: [\".github/workflows\"]
2022-12-29T20:52:52.1722034Z ##[debug]Matching modified files: products|products/gri
2022-12-29T20:52:52.2126486Z ##[debug]Non Matching modified files: [\".github/workflows\"]
2022-12-29T20:52:52.6510496Z ##[debug]Added files: []
2022-12-29T20:52:52.6551940Z ##[debug]Copied files: []
2022-12-29T20:52:52.6552610Z ##[debug]Deleted files: []
2022-12-29T20:52:52.6553331Z ##[debug]Modified files: [\"products\",\"products/gri\"]
2022-12-29T20:52:52.6554005Z ##[debug]Renamed files: []
2022-12-29T20:52:52.6554639Z ##[debug]Type Changed files: []
2022-12-29T20:52:52.6555246Z ##[debug]Unmerged files: []
2022-12-29T20:52:52.6555861Z ##[debug]Unknown files: []
2022-12-29T20:52:52.6556600Z ##[debug]All changed and modified files: [\"products\",\"products/gri\"]
2022-12-29T20:52:52.6557424Z ##[debug]All changed files: [\"products\",\"products/gri\"]
2022-12-29T20:52:52.6558199Z ##[debug]All modified files: [\"products\",\"products/gri\"]

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@koshy1123 koshy1123 added the bug Something isn't working label Dec 29, 2022
@github-actions
Copy link
Contributor

Thanks for reporting this issue, don't forget to star this project if you haven't already to help us reach a wider audience.

@jackton1 jackton1 linked a pull request Dec 29, 2022 that will close this issue
@jackton1
Copy link
Member

@koshy1123 I believe this can be configured by setting the match-directories input to false

@koshy1123
Copy link
Author

Thanks! I'll give it a shot and report back.

@koshy1123
Copy link
Author

koshy1123 commented Dec 29, 2022

@jackton1 This isn't quite what I expected, now I get an empty set instead.

My expectation was that products/gri would still be picked up as a change, but with the option match_directories: "false", I just get an empty set. I suspect because it has products/ in it? Unclear to me.

I'll see what else I can do.

EDIT: I realize I should've moved this sentence

I expected the output to be a list with one element products/gri, but what I get is a list of two elements: products/gri AND products.

to the "Expected Behavior" section 🤦

@jackton1 jackton1 reopened this Dec 29, 2022
@jackton1
Copy link
Member

@koshy1123 In that case I’ll reopen this and double check why it doesn’t work as expected.

@jackton1
Copy link
Member

jackton1 commented Dec 30, 2022

Actually @koshy1123 I believe the bug is with your implementation

Notice you used

- name: Get changed folders
  id: changed-folders
  uses: tj-actions/changed-files@v35
  with:
    json: "true"
    dir_names: "true"
    dir_names_max_depth: 2
    files_ignore: |
      **/docs/**
      **.md
    files: |
      products/**

**.md would only ignore all markdown files in the top level directory as opposed to nested directories to ignore nested directories you'll need to use products/**.md OR **/*.md

- name: Get changed folders
  id: changed-folders
  uses: tj-actions/changed-files@v35
  with:
    json: "true"
    dir_names: "true"
    dir_names_max_depth: 2
    files_ignore: |
      **/docs/**
      **.md
      products/**.md
    files: |
      products/**

Let me know if that resolved the issue.

For more information on this see: #795 (comment)

@koshy1123
Copy link
Author

koshy1123 commented Jan 3, 2023

Thanks for the pointer - I didn't realize there were different rules compared to Github's file filter documentation. The files_ignore still doesn't work for me. I created an example repo with a very minimal example of the problem if you want to investigate exactly:

EDIT: This repo is now deleted.
Repo: https://github.com/koshy1123/changed-files-illustrate-bug
Example PR: https://github.com/koshy1123/changed-files-illustrate-bug/pull/1

Example action run that was undesirable: https://github.com/koshy1123/changed-files-illustrate-bug/actions/runs/3833710707/jobs/6525429909

See matrix output that has two elements as opposed to just the one I expected. matrix={"folder":["Afolder/ASubFolder","Afolder"]}

All that said, I was able to use the file filter rules to work for my use case, I just changed

files: |
      products/**

to

files: |
      products/*/**

which works well enough for me since I don't expect to capture changes from the top level folder for my action.

Happy to leave this closed, but I leave it to your discretion. Thanks again for your help!

@jackton1 jackton1 reopened this Jan 3, 2023
@jackton1 jackton1 linked a pull request Jan 4, 2023 that will close this issue
@jackton1
Copy link
Member

jackton1 commented Jan 5, 2023

@koshy1123 This should now be resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants