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] Specfic File Bug in v33 / v34 - grep: : No such file or directory #795

Closed
3 tasks done
TurtIeSocks opened this issue Nov 9, 2022 · 17 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@TurtIeSocks
Copy link

TurtIeSocks commented Nov 9, 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?

With the workflow below, I'm able to successfully run it on V32 and below of this action, but V33 and V34 are failing when I have a single file in the files to check list.

To Reproduce

jobs:
  sync:
    name: Check for config changes
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        id: checkout-code
        uses: actions/checkout@v3
        with:
          fetch-depth: 2
      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v34
        with:
          files: |
            server/src/configs/default.json
      - name: Setup Node.js environment
        if: steps.changed-files.outputs.any_changed == 'true'
        uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: 'yarn'
      - name: Run script
        if: steps.changed-files.outputs.any_changed == 'true'
        run: |
          yarn config-check
      - name: Commit and push changes
        if: steps.changed-files.outputs.any_changed == 'true'
        uses: devops-infra/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          commit_message: Sync character count for config ref file

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-20.04

Expected behavior?

I'm expecting it to not fail and report if the single file has changed.

Relevant log output

Run tj-actions/changed-files@v34
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/RepoName/RepoName
/usr/bin/git diff --diff-filter=D --name-only 847b2faabaed1776a0b45c98861a1d3b0490709c..8d3a2959f97f5fbfef7d523c4f40531d60eedf41
Run bash $GITHUB_ACTION_PATH/get-changed-paths.sh
changed-files
  Resolving repository path: /home/runner/work/RepoName/RepoName/.
  Retrieving changes between 847b2faabaed1776a0b45c98861a1d3b0490709c (branch-name) → 8d3a2959f97f5fbfef7d523c4f40531d60eedf41 (branch-name)
  grep: : No such file or directory
  grep: : No such file or directory
  grep: : No such file or directory
  grep: : No such file or directory
  /home/runner/work/_actions/tj-actions/changed-files/v34/get-changed-paths.sh: line 66: echo: write error: Broken pipe
  Error: Process completed with exit code 1.

Anything else?

No response

Code of Conduct

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

github-actions bot commented Nov 9, 2022

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
Contributor

jackton1 commented Nov 10, 2022

@TurtIeSocks can you please provide the full log output using the download button as this output is missing a number of valuable information.

@jackton1 jackton1 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2022
@mark-jordanovic-lewis
Copy link

mark-jordanovic-lewis commented Nov 10, 2022

+1
Same result. One file, one directory.

@staticaland
Copy link

Same here.

@staticaland
Copy link

          files: |
            dev/**

Works.

          files: |
            dev/**.tf

Does not work.

@jackton1
Copy link
Contributor

@staticaland See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-file-paths

I believe dev/*.tf is what you want or an alternative to match subdirectories dev/**/*.tf

@dlopeza
Copy link

dlopeza commented Nov 18, 2022

Same problem here with files: tests/**.js

As a workaround I used version v32

@jackton1
Copy link
Contributor

jackton1 commented Nov 18, 2022

Have you tried using tests/**/*.js ?

@staticaland
Copy link

Reading the docs, I don't really see how dev/**.tf is wrong. I believe it was working fine for on.push.paths.

The ** wildcard matches any character including slash (/). This is the default behavior when you don't use a path filter.

**.js Matches all .js files in the repository.

@jackton1
Copy link
Contributor

jackton1 commented Nov 18, 2022

@staticaland @dlopeza After reaching out to the support team I discovered that there are differences in Implementation of the native workflow globstar matching and the https://github.com/isaacs/minimatch library used by this action an example of such differences can be seen below

Again I’ll suggest you use dev/**/*.tf instead

@gladykov
Copy link

I see same issue when using **/*.json but when there is no JSON file in repo yet. Not sure what is expected behavior in such use case?

@roflcoopter
Copy link

roflcoopter commented Dec 9, 2022

I am having the same issue when specifying two absolute paths.
Problem appeared when upgrading from a pretty old version of changed-files
How is this not working?

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v34
        with:
          files: |
            requirements.txt
            docker/Dockerfile.wheels

This does not work either

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v34
        with:
          files: |
            **/requirements.txt
            **/docker/Dockerfile.wheels

Edit: Downgrading to v32 is working

@kenji-miyake
Copy link
Contributor

@jackton1 I encountered the same problem.
https://github.com/tier4/autoware_launch/actions/runs/3672177618/jobs/6208132030#step:6:116

changed-files
  Resolving repository path: /__w/autoware_launch/autoware_launch/.
  Retrieving changes between c896f3f1aa80f822756ff0838a9f967522433441 (awf-latest) → e6d48f92311d87d7a7ff973342bc6d3b3f4afd09 (use-xml-for-system-monitor)
  grep: : No such file or directory

I guess this occurs when $INPUT_FILES_PATTERN_FILE or something else is empty, due to the target files don't exist as said in #795 (comment).

ADDED=$(get_diff "$INPUT_PREVIOUS_SHA" "$INPUT_CURRENT_SHA" A | { grep -x -E -f "$INPUT_FILES_PATTERN_FILE" || true; } | awk -v d="|" '{s=(NR==1?s:s d)$0}END{print s}')

$ grep -x -E -f ""
grep: : No such file or directory

How about adding an empty check in get-changed-paths.sh or action.yml?
For example, add if: ${{ steps.glob.outputs.paths-output-file != '' }} to the job below.

changed-files/action.yml

Lines 208 to 209 in ba5abef

- run: |
bash $GITHUB_ACTION_PATH/get-changed-paths.sh

Thank you.

@jackton1
Copy link
Contributor

jackton1 commented Dec 13, 2022

@kenji-miyake Looking at your workflow file I believe the issue is using a custom container.

  clang-tidy-differential:
    runs-on: ubuntu-latest
    container: ros:humble

It looks like the temp file that should be created here wasn't created which seems like a different issue. I can add a check to verify the existence of the file and mark the step as failed when missing.

@roflcoopter
Copy link

The files that are in my pattern do exist so it seems to be something else going on as well

@jackton1
Copy link
Contributor

jackton1 commented Dec 13, 2022

@roflcoopter without the logs there’s no way to find a resolution in this case.

@kenji-miyake
Copy link
Contributor

@jackton1 Thank you for your quick reply!

I guess using a custom container is okay. For example, in the workflow run below, changed-files has succeeded.
https://github.com/autowarefoundation/autoware.universe/actions/runs/3681614685/jobs/6228836994#step:6:114

Though the image name is different, the workflow structure is almost the same.

  clang-tidy-differential:
    runs-on: ubuntu-latest
    container: ghcr.io/autowarefoundation/autoware-universe:humble-latest-cuda

What do you think?

I can add a check to verify the existence of the file and mark the step as failed when missing.

Oh, will you mark it as failed? I personally think it's okay to mark it as success when there is no target file found.

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

8 participants