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] Providing files_ignore without using files input doesn't exclude ignored files #429

Closed
3 tasks done
rwbennett opened this issue Mar 14, 2022 · 7 comments · Fixed by #431
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@rwbennett
Copy link

rwbennett commented Mar 14, 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?

Based on the documentation, using either files or files_ignore should allow users to limit which files are returned in the result set. However, using either or both, I still get files I'm explicitly trying to ignore when accessing all_changed_files.

To Reproduce

- name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v17.3
        with:
          separator: '" , "'
          # Ignore GitHub actions workflow files
          files_ignore: |
            **/*.yml
          files: |
            *.json

The log still shows .yml files being shown:

Resolving repository path...
  Retrieving changes between <redacted>
  Getting diff...
  Added files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml
  Copied files: 
  Deleted files: 
  Modified files: .github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed and modified files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml" , ".github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json
  All changed files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml" , ".github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json
  All modified files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml" , ".github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

The output should only have included .json files and not .yml files.

Relevant log output

No response

Anything else?

No response

Code of Conduct

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

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

@jackton1
Copy link
Member

@rwbennett Interesting can you include the full log output generated by tj-actions/changed-files@v17.3

@rwbennett
Copy link
Author

@jackton1 , here's a newer on in which I've tried the same thing using v18:

0s
Run tj-actions/changed-files@v18
  with:
    separator: " , "
    files_ignore: **/*.yml
  
    files: *.json
  
    token: ***
    files_separator: 
  
    files_ignore_separator: 
  
    sha: <redacted>
    since_last_remote_commit: false
    use_fork_point: false
  env:
    <redacted>
Run # "Set base sha..."
  # "Set base sha..."
  if [[ -n "" ]]; then
    echo "::set-output name=base_sha::"
  elif [[ "false" == "true" && "833[4](<redacted>?check_suite_focus=true#step:3:4)<redacted>" != "0000000000000000000000000000000000000000" ]]; then
      echo "::set-output name=base_sha::<redacted>"
  fi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    <redacted>
Run # "Calculating the previous and current SHA..."
  # "Calculating the previous and current SHA..."
  bash $GITHUB_ACTION_PATH/diff-sha.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    <redacted>
    GITHUB_REPOSITORY: <redacted>
    GITHUB_BASE_REF: 
    GITHUB_HEAD_REF: 
    GITHUB_ACTION_PATH: /home/runner/work/_actions/tj-actions/changed-files/v18
    INPUT_SHA: <redacted>
    INPUT_BASE_SHA: 
    INPUT_TOKEN: ***
    INPUT_PATH: 
    INPUT_USE_FORK_POINT: false
changed-files-diff-sha
Run tj-actions/glob@v7.5
/usr/bin/git rev-parse --show-toplevel
<redacted>
/usr/bin/git diff --diff-filter=D --name-only <redacted> <redacted>

Run bash $GITHUB_ACTION_PATH/entrypoint.sh
  bash $GITHUB_ACTION_PATH/entrypoint.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    <redacted>
    GITHUB_ACTION_PATH: <redacted>
    INPUT_FILES_PATTERN_FILE: 
    INPUT_SEPARATOR: " , "
    INPUT_PATH: 
    INPUT_PREVIOUS_SHA: <redacted>
    INPUT_CURRENT_SHA: <redacted>
    INPUT_TARGET_BRANCH: main
    INPUT_CURRENT_BRANCH: main
changed-files
  Resolving repository path...
  Retrieving changes between <redacted>
  Getting diff...
  Added files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml
  Copied files: 
  Deleted files: 
  Modified files: .github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed and modified files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml" , ".github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json
  All changed files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml" , ".github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json
  All modified files: .github/actions/deploy-ui/action.yml" , ".github/actions/invalidate-cloudfront/action.yml" , ".github/workflows/deploy-portal-frontend.yml" , "dev/portal-frontend.json" , "stage/portal-frontend.json

@jackton1
Copy link
Member

jackton1 commented Mar 14, 2022

@rwbennett Since you only want to detect changes to all json files a good option here would be to use

...
     - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v18
        with:
          separator: '" , "'
          files: |
            **/*.json

From the logs, it seems that None of the patterns are returning any matches i.e *.json doesn't match "dev/portal-frontend.json" and the files_ignore pattern is essentially a noop since it's not a subset of files in the files input.

@rwbennett
Copy link
Author

Thanks @jackton1! Using the above does solve my problem. Out of curiosity though, I tried this as well:

with:
          separator: '" , "'
          # Ignore GitHub actions workflow files (see workaround further below)
          files_ignore: |
            **/*.yml

Using files_ignore by itself should have the same effect as what you posted, I believe. However, it still shows the .yml files in .github/workflows. I also tried adding another .yml file under a non-hidden directory "dev/test.yml", and that file is also included in the result set with the above. Could this be a bug in the files_ignore input?

@jackton1
Copy link
Member

Yes, it appears this is a bug based on the fact that the files_ignore currently works in tandem with the files input as opposed to independently.

@jackton1 jackton1 changed the title [BUG] all_changed_files doesn't honor files and files_ignore filters [BUG] Providing files_ignore without using files input doesn't exclude ignored files Mar 14, 2022
@jackton1 jackton1 linked a pull request Mar 14, 2022 that will close this issue
@jackton1
Copy link
Member

@rwbennett This should be resolved now

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
Development

Successfully merging a pull request may close this issue.

2 participants