Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
585 stars 112 forks source link

Getting zero exit code on deploy failure #665

Open pstovik opened 1 year ago

pstovik commented 1 year ago

Describe the bug There is an upload failure, but CLI returns 0 exit code.

To Reproduce Steps to reproduce the behavior:

  1. Given issue with SWA Azure - like this one => https://github.com/Azure/static-web-apps/issues/1097
  2. When running the command 'swa deploy --env production'
  3. Then I can see error in log

    ✖ Deployment Failed :( ✖ Deployment Failure Reason: Failed to deploy the Azure Functions. and exit code is "0"

Expected behavior Have non-zero exit code, to get failures in pipelines

Screenshots 2023-03-08 non-zero

Desktop (please complete the following information):

flexwie commented 1 year ago

We are getting the same behaviour when trying to deploy a new env without any free slots available. Our workaround for pipelines is a shell script that greps the output for a keyword:

swa deploy -O build/your-app --env "full_env"  2>&1 | tee run.log
if grep -q BadRequest run.log; then exit 1; else exit 0; fi
dylan-smith commented 9 months ago

the always 0 exit code makes it really hard to use this in any CI/CD scenario. I want to fail my GitHub Actions workflow if deploy fails, but since the swa exit code is is 0, GitHub Actions assumes it succeeded (as will most/all CI systems).

hbroer commented 9 months ago

yea it is anoying. We run into this from first try because 1st we thought "nice that was easy" but then "oh no, it errors but it does not fail".

It needs to return an error code, else we need to look into the job everytime.