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 when add or remove only contain a space #154

Closed
xenoterracide opened this issue Mar 30, 2021 · 11 comments
Closed

Action fails when add or remove only contain a space #154

xenoterracide opened this issue Mar 30, 2021 · 11 comments
Assignees
Labels
good first issue Good for newcomers type: bug Verified problems that need to be worked on
Projects

Comments

@xenoterracide
Copy link

I suppose what I could do here is simply have 2 steps with conditionals, but that would end up with 2 commits which seems less elegant. Might be nice if it checked for empty and then did nothing on empty (except maybe log a warning).

    - uses: EndBug/add-and-commit@v7
      with:
        message: Generate SVG images for PlantUML diagrams
        add: ${{ steps.puml-diff.outputs.changed-light }} ${{ steps.puml-diff.outputs.changed-dark }}
        remove: ${{ steps.puml-files.outputs.removed-light }} ${{ steps.puml-files.outputs.removed-dark }}
Run EndBug/add-and-commit@v7
  with:
    message: Generate SVG images for PlantUML diagrams
    add:  docs/domain-model/.svg/user-light.svg  docs/domain-model/.svg/user-dark.svg
    remove:  
    author_name: xenoterracide
    author_email: xenoterracide@users.noreply.github.com
    cwd: .
    pull_strategy: --no-rebase
    push: true
Running in /home/runner/work/iw-ppm-backend/iw-ppm-backend
Add input parsed as single string, running 1 git add command.
> Using 'xenoterracide <xenoterracide@users.noreply.github.com>' as author.
> Using "Generate SVG images for PlantUML diagrams" as commit message.
Internal logs
  > Staging files...
  > Adding files...
  Error: Error: fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths
@xenoterracide xenoterracide added the status: pending More info is needed before deciding what to do label Mar 30, 2021
@EndBug EndBug self-assigned this Mar 30, 2021
@EndBug EndBug added type: bug Verified problems that need to be worked on good first issue Good for newcomers and removed status: pending More info is needed before deciding what to do labels Mar 30, 2021
@EndBug EndBug added this to To do in Main board via automation Mar 30, 2021
@xenoterracide
Copy link
Author

seems like this would be a problem for me with add as well if I had only deleted files

@EndBug
Copy link
Owner

EndBug commented Mar 30, 2021

Hi, thanks for the report! You're right, you could do separate steps with checks, but it's really counter-intuitive that an empty string causes the action to fail, also because the default value for remove is actually an empty string.
The problem comes from the fact that that string technically isn't empty, but it contains a space character ' '. I'll solve this by trimming the add and remove strings, so that strings like that will become empty.

@EndBug EndBug changed the title empty rm Action fails when add or remove only contain a space Mar 30, 2021
@xenoterracide
Copy link
Author

xenoterracide commented Mar 30, 2021

hmm, strange... it's not just that maybe, I split it into 2 actions, and add still blows up, trim might still fix it though.

  with:
    message: Generate SVG images for PlantUML diagrams
    add:  docs/domain-model/.svg/user-light.svg  docs/domain-model/.svg/user-dark.svg
    author_name: xenoterracide
    author_email: xenoterracide@users.noreply.github.com
    cwd: .
    pull_strategy: --no-rebase
    push: true
Running in /home/runner/work/iw-ppm-backend/iw-ppm-backend
Add input parsed as single string, running 1 git add command.
> Using 'xenoterracide <xenoterracide@users.noreply.github.com>' as author.
> Using "Generate SVG images for PlantUML diagrams" as commit message.
Internal logs
Outputs
Error: Error: fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths

@xenoterracide
Copy link
Author

I'm going to bed, too tired to know what I'm talking about, but in the event it helps, this is my current full source code (in this branch) https://github.com/xenoterracide/iw-ppm-backend/tree/ccushing/plantuml . this comment will of course eventually be stale.

@EndBug
Copy link
Owner

EndBug commented Mar 30, 2021

I think I fixed the issue.
The problem was not with the empty string, but with the one that was not: looking at your run logs I saw that the input string contained multiple spaces, and that was causing the action to parse some elements as empty strings. When the package that handles git commands saw one of these, it would complain about it being empty, even though your input was not.
I solved it by replacing the current parsing system (which only used split(' ') with a proper regex to parse paths and arguments.

The fix is currently on the master branch, and works with the test workflow I used to reproduce the issue. Can you try to see if that solves your problem too? Just use the action from that branch with

- uses: EndBug/add-and-commit@master
  with: ...

@xenoterracide
Copy link
Author

sorry I haven't tested this yet (sort of) I've been tracking down other bugs whilst trying to ensure this is working... and found many in my code. Not certain if this is part of this though, but it's kind of frustrating that something is being passed, but the build is not failing when it's missing.

Internal logs
  > Staging files...
  > Adding files...
  ##[debug]Input parsed as single string
  Error: Error: fatal: pathspec 'docs/domain-model/.svg/light/user.svg' did not match any files

@EndBug
Copy link
Owner

EndBug commented Apr 3, 2021

The action will not stop if git commands fail because they don't match any file, this is intended behavior.
If you want the workflow run to fail in this situation you'll have to either run a custom command or use an action like [this].(https://github.com/marketplace/actions/file-existence)

Please test EndBug/add-and-commit@master as soon as you can, thank you.

@xenoterracide
Copy link
Author

xenoterracide commented Apr 3, 2021 via email

@EndBug
Copy link
Owner

EndBug commented Apr 4, 2021

@all-contributors please add @xenoterracide for their bug report

@allcontributors
Copy link
Contributor

@EndBug

I've put up a pull request to add @xenoterracide! 🎉

@EndBug
Copy link
Owner

EndBug commented Apr 4, 2021

I've published the fix in v7.1.1 (also via v7 and `latest')
Thank you again for the bug report!

@EndBug EndBug closed this as completed Apr 4, 2021
Main board automation moved this from To do to Done Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: bug Verified problems that need to be worked on
Projects
No open projects
Main board
  
Done
Development

No branches or pull requests

2 participants