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 isn't respected #1434

Closed
3 tasks done
CITIZENDOT opened this issue Aug 4, 2023 · 20 comments · Fixed by #1435
Closed
3 tasks done

[BUG] files_ignore isn't respected #1434

CITIZENDOT opened this issue Aug 4, 2023 · 20 comments · Fixed by #1435
Labels
configuration error WhiteSource configuration error

Comments

@CITIZENDOT
Copy link

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?

I specified files and files_ignore as below.

- name: Get all script files that have changed
  id: changed-files
  uses: tj-actions/changed-files@v37
  with:
    files: |
      assets/scripts/**.sh
      .github/test-microk8s-ubuntu.yml
    files_ignore: assets/scripts/configure-minikube-linux.sh

And the files changed are [assets/scripts/configure-minikube-linux.sh]. But steps.changed-files.outputs.any_modified == 'true' is evaluated as true.

To Reproduce

  1. Action is running on ubuntu-latest
  2. Config
name: test-microk8s-ubuntu

on:
  pull_request:
    branches: [master]
  push:
    branches: [master]

jobs:
  test-linux:
    runs-on: ubuntu-latest

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v3

      - name: Get all script files that have changed
        id: changed-files
        uses: tj-actions/changed-files@v37
        with:
          files: |
            assets/scripts/**.sh
            .github/test-microk8s-ubuntu.yml
          files_ignore: assets/scripts/configure-minikube-linux.sh

      - name: Configure MicroK8s Cluster
        if: ${{ steps.changed-files.outputs.any_modified == 'true' }}
        run: |
        # blah blah
        shell: bash

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

steps.changed-files.outputs.any_modified should be set to false, when only files changed belong to files_ignore.

Relevant log output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@CITIZENDOT CITIZENDOT added the bug Something isn't working label Aug 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2023

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
Copy link
Member

jackton1 commented Aug 5, 2023

Hi @CITIZENDOT Can you provide the logs associated to your workflow.

Note: This requires a re-run of the workflow and with debug enabled.

@CITIZENDOT
Copy link
Author

How to enable debugging?

@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

Hit the rerun button at the top right by viewing the workflow run

IMG_0434

Enable debugging by checking this box

IMG_0435

@CITIZENDOT
Copy link
Author

CITIZENDOT commented Aug 5, 2023

Here's the log. Didn't include changed-files as it's too long. This is the workflow file.

##[debug]Evaluating condition for step: 'Get all script files that have changed'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Get all script files that have changed
##[debug]Loading inputs
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: github.api_url
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'api_url'
##[debug]=> 'https://api.github.com'
##[debug]Result: 'https://api.github.com'
##[debug]Loading env
Run tj-actions/changed-files@v37
  with:
    files: assets/scripts/**.sh
  .github/test-microk8s-ubuntu.yml
  
    files_ignore: assets/scripts/configure-minikube-linux.sh
    separator:  
    include_all_old_new_renamed_files: false
    old_new_separator: ,
    old_new_files_separator:  
    files_from_source_file_separator: 
  
    files_separator: 
  
    files_yaml_from_source_file_separator: 
  
    files_ignore_yaml_from_source_file_separator: 
  
    files_ignore_separator: 
  
    files_ignore_from_source_file_separator: 
  
    path: .
    quotepath: true
    diff_relative: true
    dir_names: false
    dir_names_exclude_current_dir: false
    json: false
    escape_json: true
    fetch_depth: 50
    skip_initial_fetch: false
    since_last_remote_commit: false
    write_output_files: false
    output_dir: .github/outputs
    output_renamed_files_as_deleted_and_added: false
    recover_deleted_files: false
    recover_files_separator: 
  
    recover_files_ignore_separator: 
  
    token: ***
    api_url: https://api.github.com
::group::changed-files
changed-files
::group::changed-files-patterns
changed-files-patterns
  ##[debug]All filtered diff files: {"A":[],"C":[],"D":[],"M":["assets/scripts/configure-microk8s-linux.sh"],"R":[],"T":[],"U":[],"X":[]}
  ##[debug]Added files: {"paths":"","count":"0"}
  ##[debug]Copied files: {"paths":"","count":"0"}
  ##[debug]Modified files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]Renamed files: {"paths":"","count":"0"}
  ##[debug]Type changed files: {"paths":"","count":"0"}
  ##[debug]Unmerged files: {"paths":"","count":"0"}
  ##[debug]Unknown files: {"paths":"","count":"0"}
  ##[debug]All changed and modified files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]All changed files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]All other changed files: {"paths":".github/workflows/test-microk8s-ubuntu.yml .github/workflows/test-minikube-ubuntu.yml assets/scripts/configure-microk8s-linux.sh assets/scripts/configure-minikube-linux.sh","count":"4"}
  ##[debug]All modified files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]Deleted files: {"paths":"","count":"0"}
  All Done!
  ::endgroup::
##[debug]Node Action run completed with exit code 0
##[debug]Set output added_files = 
##[debug]Set output added_files_count = 0
##[debug]Set output copied_files = 
##[debug]Set output copied_files_count = 0
##[debug]Set output modified_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output modified_files_count = 1
##[debug]Set output renamed_files = 
##[debug]Set output renamed_files_count = 0
##[debug]Set output type_changed_files = 
##[debug]Set output type_changed_files_count = 0
##[debug]Set output unmerged_files = 
##[debug]Set output unmerged_files_count = 0
##[debug]Set output unknown_files = 
##[debug]Set output unknown_files_count = 0
##[debug]Set output all_changed_and_modified_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output all_changed_and_modified_files_count = 1
##[debug]Set output all_changed_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output all_changed_files_count = 1
##[debug]Set output any_changed = true
##[debug]Set output only_changed = false
##[debug]Set output other_changed_files = .github/workflows/test-microk8s-ubuntu.yml .github/workflows/test-minikube-ubuntu.yml assets/scripts/configure-minikube-linux.sh
##[debug]Set output other_changed_files_count = 3
##[debug]Set output all_modified_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output all_modified_files_count = 1
##[debug]Set output any_modified = true
##[debug]Set output only_modified = false
##[debug]Set output other_modified_files = .github/workflows/test-microk8s-ubuntu.yml .github/workflows/test-minikube-ubuntu.yml assets/scripts/configure-minikube-linux.sh
##[debug]Set output other_modified_files_count = 3
##[debug]Set output deleted_files = 
##[debug]Set output deleted_files_count = 0
##[debug]Set output any_deleted = false
##[debug]Set output only_deleted = false
##[debug]Set output other_deleted_files = 
##[debug]Set output other_deleted_files_count = 0
##[debug]Finishing: Get all script files that have changed

@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

@CITIZENDOT I’m still investigating in the meantime you can use multi line input to verify that the file gets ignored when passed

- name: Get all script files that have changed
  id: changed-files
  uses: tj-actions/changed-files@v37
  with:
    files: |
      assets/scripts/**.sh
      .github/test-microk8s-ubuntu.yml
    files_ignore: |
      assets/scripts/configure-minikube-linux.sh

@CITIZENDOT
Copy link
Author

Sure. Thanks a lot for the quick response!

@CITIZENDOT
Copy link
Author

btw, multiline files_ignore didnt work too. I tried that first and since it didnt work, I was trying single line approach.

@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

@CITIZENDOT Actually, this is working as expected

Workflow file

      - name: Get all script files that have changed
        id: changed-files
        uses: tj-actions/changed-files@v37
        with:
          files: |
            assets/scripts/**.sh
            .github/test-microk8s-ubuntu.yml
          files_ignore: assets/scripts/configure-minikube-linux.sh

This means ignoring assets/scripts/configure-minikube-linux.sh but as you can see the file that is getting matched is assets/scripts/configure-microk8s-linux.sh this is because you have assets/scripts/**.sh which matches that pattern an as a result any_changed is set to true

Here's the logs

  ##[debug]All filtered diff files: {"A":[],"C":[],"D":[],"M":["assets/scripts/configure-microk8s-linux.sh"],"R":[],"T":[],"U":[],"X":[]}
  ##[debug]Added files: {"paths":"","count":"0"}
  ##[debug]Copied files: {"paths":"","count":"0"}
  ##[debug]Modified files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]Renamed files: {"paths":"","count":"0"}
  ##[debug]Type changed files: {"paths":"","count":"0"}
  ##[debug]Unmerged files: {"paths":"","count":"0"}
  ##[debug]Unknown files: {"paths":"","count":"0"}
  ##[debug]All changed and modified files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]All changed files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]All other changed files: {"paths":".github/workflows/test-microk8s-ubuntu.yml .github/workflows/test-minikube-ubuntu.yml assets/scripts/configure-microk8s-linux.sh assets/scripts/configure-minikube-linux.sh","count":"4"}
  ##[debug]All modified files: {"paths":"assets/scripts/configure-microk8s-linux.sh","count":"1"}
  ##[debug]Deleted files: {"paths":"","count":"0"}
  All Done!
  ::endgroup::
##[debug]Node Action run completed with exit code 0
##[debug]Set output added_files = 
##[debug]Set output added_files_count = 0
##[debug]Set output copied_files = 
##[debug]Set output copied_files_count = 0
##[debug]Set output modified_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output modified_files_count = 1
##[debug]Set output renamed_files = 
##[debug]Set output renamed_files_count = 0
##[debug]Set output type_changed_files = 
##[debug]Set output type_changed_files_count = 0
##[debug]Set output unmerged_files = 
##[debug]Set output unmerged_files_count = 0
##[debug]Set output unknown_files = 
##[debug]Set output unknown_files_count = 0
##[debug]Set output all_changed_and_modified_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output all_changed_and_modified_files_count = 1
##[debug]Set output all_changed_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output all_changed_files_count = 1
##[debug]Set output any_changed = true
##[debug]Set output only_changed = false
##[debug]Set output other_changed_files = .github/workflows/test-microk8s-ubuntu.yml .github/workflows/test-minikube-ubuntu.yml assets/scripts/configure-minikube-linux.sh
##[debug]Set output other_changed_files_count = 3
##[debug]Set output all_modified_files = assets/scripts/configure-microk8s-linux.sh
##[debug]Set output all_modified_files_count = 1
##[debug]Set output any_modified = true
##[debug]Set output only_modified = false
##[debug]Set output other_modified_files = .github/workflows/test-microk8s-ubuntu.yml .github/workflows/test-minikube-ubuntu.yml assets/scripts/configure-minikube-linux.sh
##[debug]Set output other_modified_files_count = 3
##[debug]Set output deleted_files = 
##[debug]Set output deleted_files_count = 0
##[debug]Set output any_deleted = false
##[debug]Set output only_deleted = false
##[debug]Set output other_deleted_files = 
##[debug]Set output other_deleted_files_count = 0
##[debug]Finishing: Get all script files that have changed

Let me know if you need further clarification.

@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

btw, multiline files_ignore didnt work too. I tried that first and since it didnt work, I was trying single line approach.

You can ignore my earlier recommendation since that's the same thing

@CITIZENDOT
Copy link
Author

CITIZENDOT commented Aug 5, 2023

In the docs, outputs.any_modified says "Returns true when any of the filenames provided using the files* or files_ignore* inputs has been modified. i.e. using a combination of all added, copied, modified, renamed, and deleted files (ACMRD)." So, I thought outputs.any_modified ignores file changes in files_ignore. What should be done to detect changes in files but not files_ignore?

@jackton1 jackton1 linked a pull request Aug 5, 2023 that will close this issue
@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

@CITIZENDOT Yes any_modified is true because like it says the file assets/scripts/configure-microk8s-linux.sh is one of the files you specified in the files input using assets/scripts/**.sh

Both files are detected as being changed

  • assets/scripts/configure-minikube-linux.sh
  • assets/scripts/configure-microk8s-linux.sh

You explicitly ignored assets/scripts/configure-minikube-linux.sh but not assets/scripts/configure-microk8s-linux.sh

For context here's the workflow file

      - name: Get all script files that have changed
        id: changed-files
        uses: tj-actions/changed-files@v37
        with:
          files: |
            assets/scripts/**.sh      -- This includes both assets/scripts/configure-minikube-linux.sh and assets/scripts/configure-microk8s-linux.sh but assets/scripts/configure-minikube-linux.sh is explicitly ignored and not assets/scripts/configure-microk8s-linux.sh 
            .github/test-microk8s-ubuntu.yml
          files_ignore: assets/scripts/configure-minikube-linux.sh

I'm not sure what your expected outcome is but if any file that isn't ignored has changed then any_changed would be set to true

@CITIZENDOT
Copy link
Author

CITIZENDOT commented Aug 5, 2023

@CITIZENDOT Yes any_modified is true because like it says the file assets/scripts/configure-microk8s-linux.sh is one of the files you specified in the files input using assets/scripts/**.sh

For context here's the workflow file

      - name: Get all script files that have changed
        id: changed-files
        uses: tj-actions/changed-files@v37
        with:
          files: |
            assets/scripts/**.sh      -- This includes both assets/scripts/configure-minikube-linux.sh and assets/scripts/configure-microk8s-linux.sh but assets/scripts/configure-minikube-linux.sh is explicitly ignored and not assets/scripts/configure-microk8s-linux.sh 
            .github/test-microk8s-ubuntu.yml
          files_ignore: assets/scripts/configure-minikube-linux.sh

I'm still confused here. assets/scripts/configure-minikube-linux.sh is explicitly marked to ignore and that's the only file modified. If that's marked to ignore , any_modified should be set to false, I think? Or is there any other property which ignores changes in files_ignore?

@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

@CITIZENDOT You changed both files here

Screenshot 2023-08-04 at 11 05 52 PM

Both files are detected as being changed

  • assets/scripts/configure-minikube-linux.sh
  • assets/scripts/configure-microk8s-linux.sh

You explicitly ignored assets/scripts/configure-minikube-linux.sh but not assets/scripts/configure-microk8s-linux.sh

@CITIZENDOT
Copy link
Author

Ohhh, this checks for the whole PR? I was thinking this checks for commit and its preceeding commit.

@jackton1 jackton1 removed the bug Something isn't working label Aug 5, 2023
@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

For checking the commit you might want to use since_last_remote_commit

      - name: Get all script files that have changed
        id: changed-files
        uses: tj-actions/changed-files@v37
        with:
           since_last_remote_commit: true
           ...

@CITIZENDOT
Copy link
Author

Thank you. Also Apologies for incorrectly filing this as a bug.

@jackton1 jackton1 added the configuration error WhiteSource configuration error label Aug 5, 2023
@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

No worries, was a fun debugging session.

@CITIZENDOT
Copy link
Author

CITIZENDOT commented Aug 5, 2023

One small doubt, when a PR is created to dev branch from a feature branch: setting since_last_remote_commit to true gets the changed files from the commit on feature branch and compares with the commit on dev branch right (for the first time)? And for the subsequent commits, it checks using previous commits on the feature branch. Did I understand this correctly?

@jackton1
Copy link
Member

jackton1 commented Aug 5, 2023

Yes, you are spot on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration error WhiteSource configuration error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants