nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
55.76k stars 1.39k forks source link

Better reporting when the action.yml does not exist #1718

Open dekimsey opened 1 year ago

dekimsey commented 1 year ago

Act version

0.2.43

Feature description

If the user's test workflow tries to use the repository root as an action, it can fail with an opaque error message, 'file not found'. The root cause is a user error and not an application one, it'd just be nice to make that more clear to the user if possible.

Given a workflow like such:

name: test action
on: [push]

jobs:
  test--handling:
    runs-on: ubuntu-latest
    steps:
     - uses: ./
        with:
          hello: world

The following output is emitted

$ act
[test action/test--handling] 🚀  Start image=catthehacker/ubuntu:act-latest
[test action/test--handling]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[test action/test--handling]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[test action/test--handling]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[test action/test--handling] ⭐ Run Main ./
[test action/test--handling]   ❌  Failure - Main ./
[test action/test--handling] file does not exist
[test action/test--handling] 🏁  Job failed
Error: Job 'test--handling' failed

The same action when uploaded to GitHub returns a more actionable error message:

Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/action-test/action-test'. Did you forget to run actions/checkout before running your local action?

This is a user error, as the local action must first be checked out to do the test.

keithmgould commented 1 year ago

I'm receiving this error, prob for the reason mentioned above, but I don't know what the fix is. I also have the action.yml in the root of the repo, and the line uses: ./, but my understanding is that is the correct path. I get that it is user error but I can't tell what my error is?

dekimsey commented 1 year ago

D'oh, sorry about that @keithmgould. Add a local checkout like this:

jobs:
  test--handling:
    runs-on: ubuntu-latest
    steps:
     - uses: actions/checkout@v3
     - uses: ./
        # ... remainder of test
keithmgould commented 1 year ago

That solved!! Thank you!