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

Raise error on command failure #72

Open
animetosho opened this issue Aug 29, 2023 · 2 comments
Open

Raise error on command failure #72

animetosho opened this issue Aug 29, 2023 · 2 comments

Comments

@animetosho
Copy link

Firstly, thanks for building this action!

Is there any way to cause the action to fail if a command in run fails?
This would be useful for identifying test failures; currently everything seems to pass, even if something actually failed.

@xakod
Copy link

xakod commented Sep 9, 2023

Hi @Neilpang, sorry for ping. Is there any solution for this issue?

@daniel-mohr
Copy link

I'm not a developer here. But I can share my solution:

...
  freebsd_test:
    runs-on: ubuntu-22.04
    name: run tests on FreeBSD
    steps:
    - uses: actions/checkout@v4
    - name: Test in FreeBSD
      id: test
      uses: vmactions/freebsd-vm@v1
      with:
        usesh: true
        run: |
          set -e -x
...

The flag usesh: true is documented in the README.md as The default shell in FreeBSD is csh, if you want to use sh to execute the run script, please set usesh to true.. This way you can use the posix set command or a similar command (I believe set from sh -- see section Argument List Processing). With the flag -e you get your desired behavior 'exit immediately on fail'. The -x flag is not necessary, but it will cause an echo of each command immediately before execution -- this helps to find out at which command an error occurred.

junghans added a commit to junghans/xz that referenced this issue Apr 25, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72
thesamesam pushed a commit to thesamesam/xz that referenced this issue Jun 3, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72
thesamesam pushed a commit to thesamesam/xz that referenced this issue Jun 3, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72
thesamesam pushed a commit to thesamesam/xz that referenced this issue Jun 3, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72
thesamesam pushed a commit to thesamesam/xz that referenced this issue Jun 3, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72
thesamesam pushed a commit to thesamesam/xz that referenced this issue Jun 3, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72
Larhzu pushed a commit to tukaani-project/xz that referenced this issue Jun 3, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72
Larhzu pushed a commit to tukaani-project/xz that referenced this issue Sep 6, 2024
Without "set -e" the job will always be successful.

See vmactions/freebsd-vm#72

(cherry picked from commit 8641f0c)
pippocao added a commit to Tencent/BqLog that referenced this issue Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants