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

Action fails on empty repo or when the specific file pattern is not found #976

Closed
3 tasks done
DanielRejniak opened this issue Feb 9, 2023 · 4 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@DanielRejniak
Copy link

DanielRejniak commented Feb 9, 2023

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 found several issues with the tj-actions/changed-files action, those are especially predominant when the repository is empty. Bellow are two scenarios that I reproduced on my private dummy repo for the purpose of demonstration.

Actions : tj-actions/changed-files
Version : v35.5.1

name: test-changes
on: push
jobs:
  test-changes:
    runs-on: ubuntu-latest
    steps:     
      
      # Checkout the current branch
      - name: Checkout repository
        uses: actions/checkout@v3
        with: 
          fetch-depth: 0
      
      - name: Get changed yaml's
        uses: tj-actions/changed-files@v35.5.1
        with:
          json: "true"
          files: |
            test_dir/**/*.yaml

To Reproduce

Issue One

This appears to happen on brand new repo when there was no previous commits.

See job failures : https://github.com/DanielRejniak/tj-actions-bug-replication/actions/runs/4134902304/jobs/7146633425

Issue Two

After I made a dummy commit the repo now has previous commits. I then re-run the workflow and and I use a glob pattern of test_dir/**/*.yaml as Im only interested in those files. However the action fails saying that No paths found using the specified patterns.

See job failures : https://github.com/DanielRejniak/tj-actions-bug-replication/actions/runs/4134958441/jobs/7146768376

What OS are you seeing the problem on?

all

Expected behavior?

I would have expected the list of changes to be empty in both cases. In the first case the repo is blank there are no changes so I should recieve an empty list. In the second case the repo has commit's but no files that Im looking for so again I should recieve empty list of changed files.

Relevant log output

Issue One Log

Run tj-actions/changed-files@v35.5.1
Run # "Calculating the previous and current SHA..."
changed-files-diff-sha
  Verifying git version...
  Valid git version found: (2.39.1)
  Running on a push event...
  fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
  fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
  Error: Unable to locate a previous commit.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
  Error: Process completed with exit code 1.

Issue Two Log

Run tj-actions/changed-files@v35.5.1
Run # "Calculating the previous and current SHA..."
changed-files-diff-sha
Run tj-actions/glob@v16
/usr/bin/git rev-parse --show-toplevel
/home/runner/work/tj-actions-bug-replication/tj-actions-bug-replication
/usr/bin/git diff --diff-filter=D --name-only 91b75eba4f9c38e09c039d4920d3571b71786f72..00421671d4b77b8e9183928f7fc68bb652593592
Error: No paths found using the specified patterns

Anything else?

No response

Code of Conduct

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

github-actions bot commented Feb 9, 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 Feb 9, 2023

Hi @DanielRejniak I believe Issue 1 has been fixed, and Issue 2 is an expected outcome to prevent potential misconfigured patterns

@jackton1 jackton1 closed this as completed Feb 9, 2023
@s4nji
Copy link

s4nji commented Apr 21, 2023

We are using tj-actions/changed-files@v16 (which uses tj-actions/glob@v7) to detect if there are any .go files changed in a given pull-request:

    - id: golang-changed
      uses: tj-actions/changed-files@v16
      with:
        files: |
          **/*.go
        files_ignore: |
          **/vendor/**

    - if: steps.golang-changed.outputs.any_changed == 'true'
      ...

This is working, but now fails in the latest version with Error: No paths found using the specified patterns.
Looks like tj-actions/glob#625 and tj-actions/glob#626 are the exact point when this stopped working as you linked above.

I still think this is a valid use-case for the action. Could perhaps a toggle be added to not throw an error if there's no match or changed files?
At the moment looks like any_changed output is rendered unusable/useless, since files input must be defined to use it, therefore currently it either returns true, or the action fails.

Note: I think this relates to #992 as well

@jackton1
Copy link
Member

jackton1 commented Apr 21, 2023

This has been resolved and would be released momentarily. Going forward patterns not matching any files would result in a warning.

cc: @s4nji, @DanielRejniak

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

3 participants