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] The only_modified is evaluated to true even when other_modified_files is not empty. #292

Closed
3 tasks done
tk185060 opened this issue Dec 29, 2021 · 2 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@tk185060
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?

The only_modified is evaluated to true eventough other_modified_files is not empty.

Per the documentation, my understanding is that if there are modifications to files outside the files filter, i.e. when other_modified_files is not empty, the only_modified should be false.

Thank you for looking into this.

To Reproduce

This is my usage

    - name: Get changed files
      id: changed-files
      uses: tj-actions/changed-files@v2.0.0
      with:
        files: |
          test_build.yml

While I deleted a bunch of .yml files and modified also README.md. Please see "Relevant log output" and evaluation of the "Non Matching modified files".

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

PROBLEM: the steps.changed-files.outputs.only_modified is evaluated as true. I believe it should be false as there are "Non Matching modified files" (A bunch of deleted files and one modified file README.md) that are not in the files filter. And also (correctly) the other_modified_files is not empty as following

    - name: Run step when only files provided using the files input has been modified (ACMRD)
      if: steps.changed-files.outputs.only_modified
      run: |
        echo "only_modified is true - only files provided using the files input have been modified."
        for file in ${{ steps.changed-files.outputs.other_modified_files }}; do
          echo "$file was modified"
        done

prints this:

Run echo "only_modified is true - only files provided using the files input has been modified."
only_modified is true - only files provided using the files input have been modified.
.github/workflows/choco_packages.yml was modified
.github/workflows/devtestlab.yml was modified
.github/workflows/devtestlab_clean_vms.yml was modified
.github/workflows/gitleaks.yml was modified
.github/workflows/new_rcm_server.yml was modified
.github/workflows/new_rcm_snapshot.yml was modified
.github/workflows/new_snapshot.yml was modified
.github/workflows/new_swatlab.yml was modified
.github/workflows/remove_stale_runners.yml was modified
.github/workflows/rpos_bdd_sc.yml was modified
.github/workflows/test_build_snapshot.yml was modified
.github/workflows/whitesource.yml was modified
README.md was modified

Relevant log output

Run tj-actions/changed-files@v2.0.0
  with:
    files: test_build.yml
  
    token: ***
    separator:  
    sha: 7b95619df36c1ca3c820badfecfd1b290ed55437
    since_last_remote_commit: false
Run bash $GITHUB_ACTION_PATH/sourcefiles.sh
  bash $GITHUB_ACTION_PATH/sourcefiles.sh
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    INPUT_FILES: test_build.yml
  
    INPUT_FILES_FROM_SOURCE_FILE: 
changed-files-from-source-file
  Input Files: test_build.yml
  All Unique Input files: test_build.yml
Run # "Set base sha..."
  # "Set base sha..."
  if [[ -n "" ]]; then
    echo "::set-output name=base_sha::"
  elif [[ "false" == "true" ]]; then
    if [[ "37bd7ddda56ab1d6116cd57511c6bc45b4c7295f" != "0000000000000000000000000000000000000000" ]]; then
      echo "::set-output name=base_sha::37bd7ddda56ab1d6116cd57511c6bc45b4c7295f"
    else
      echo "::set-output name=base_sha::7b95619df36c1ca3c820badfecfd1b290ed55437"
    fi
  fi
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
Run bash $GITHUB_ACTION_PATH/entrypoint.sh
  bash $GITHUB_ACTION_PATH/entrypoint.sh
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    GITHUB_SERVER_URL: https://github.com
    GITHUB_REPOSITORY: ncr-swt-cfr/cfr-build
    GITHUB_BASE_REF: main
    INPUT_SHA: 7b95619df36c1ca3c820badfecfd1b290ed55437
    INPUT_BASE_SHA: 
    INPUT_TOKEN: ***
    INPUT_FILES: test_build.yml
    INPUT_SEPARATOR:  
    INPUT_PATH: 
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0        
changed-files
  From https://github.com/ncr-swt-cfr/cfr-build
   * [new branch]      main       -> main
  Resolving repository path...
   * [new branch]      main       -> temp_changed_files/main
  Setting up 'temp_changed_files' remote...
  No 'temp_changed_files' remote found
  Creating 'temp_changed_files' remote...
  Getting HEAD info...
  Retrieving changes between 6b3fe3d961b294b1a4ade72e19315bde17357fd8 (main) → 7b95619df36c1ca3c820badfecfd1b290ed55437 (RPOS-000-Try-tj-actions-changed-files)
  Getting diff...
  Input files: test_build.yml
  Checking for file changes: "test_build.yml"...
  Matching changed files: .github/workflows/test_build.yml
  Non Matching changed files: README.md
  Matching modified files: .github/workflows/test_build.yml
  Non Matching modified files: .github/workflows/choco_packages.yml .github/workflows/devtestlab.yml .github/workflows/devtestlab_clean_vms.yml .github/workflows/gitleaks.yml .github/workflows/new_rcm_server.yml .github/workflows/new_rcm_snapshot.yml .github/workflows/new_snapshot.yml .github/workflows/new_swatlab.yml .github/workflows/remove_stale_runners.yml .github/workflows/rpos_bdd_sc.yml .github/workflows/test_build_snapshot.yml .github/workflows/whitesource.yml README.md
  Non Matching deleted files: .github/workflows/choco_packages.yml .github/workflows/devtestlab.yml .github/workflows/devtestlab_clean_vms.yml .github/workflows/gitleaks.yml .github/workflows/new_rcm_server.yml .github/workflows/new_rcm_snapshot.yml .github/workflows/new_snapshot.yml .github/workflows/new_swatlab.yml .github/workflows/remove_stale_runners.yml .github/workflows/rpos_bdd_sc.yml .github/workflows/test_build_snapshot.yml .github/workflows/whitesource.yml
  Added files: 
  Copied files: 
  Deleted files: 
  Modified files: .github/workflows/test_build.yml
  Renamed files: 
  Type Changed files: 
  Unmerged files: 
  Unknown files: 
  All changed and modified files: .github/workflows/test_build.yml
  All changed files: .github/workflows/test_build.yml
  All modified files: .github/workflows/test_build.yml

Anything else?

No response

Code of Conduct

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

Thanks for reporting this issue.

@jackton1 jackton1 changed the title [BUG] The only_modified is evaluated to true eventough other_modified_files is not empty. [BUG] The only_modified is evaluated to true even when other_modified_files is not empty. Dec 29, 2021
@jackton1
Copy link
Member

jackton1 commented Dec 29, 2021

@tk185060 Just to confirm that this is a bug with the output can you change

    - name: Run step when only files provided using the files input has been modified (ACMRD)
      if: steps.changed-files.outputs.only_modified == "true"  # <-- Change this if expression to include the expected string value as this doesn't return a boolean
      run: |
        echo "only_modified is true - only files provided using the files input have been modified."
        for file in ${{ steps.changed-files.outputs.other_modified_files }}; do
          echo "$file was modified"
        done

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

No branches or pull requests

2 participants