oracle-actions / run-oci-cli-command

Run Oracle Cloud Infrastructure (OCI) CLI commands
Universal Permissive License v1.0
27 stars 7 forks source link

Running command with no output fails to parse #46

Closed dfoster-oracle closed 6 days ago

dfoster-oracle commented 1 week ago

I'm trying to delete an RMS stack, but the successful response from the CLI is empty, and the runner doesn't seem to like that.

Executing Oracle Cloud Infrastructure CLI command
| [command]/usr/local/bin/oci resource-manager stack delete --force --stack-id ocid1.ormstack.oc1.***.<real_stack_id>
| 
| /run/act/actions/oracle-actions-run-oci-cli-command@v1.3.1/src/main.ts:67
|       const stdout = JSON.parse(cliResult.stdout)
| ^
| SyntaxError: Unexpected end of JSON input
|     at JSON.parse (<anonymous>)
|     at runOciCliCommand (/run/act/actions/oracle-actions-run-oci-cli-command@v1.3.1/src/main.ts:67:1)
[Test/test]   ❌  Failure - Main Destroy RMS Stack
[Test/test] exitcode '1': failure
[Test/test] 🏁  Job failed

I've tried to force output by using the --wait-for-state flag, but the runner doesn't seem to like this output either.

| Executing Oracle Cloud Infrastructure CLI command
| [command]/usr/local/bin/oci resource-manager stack delete --force --wait-for-state DELETED --stack-id ocid1.ormstack.oc1.***.<real_stack_id>
| Action completed. Waiting until the resource has entered state: ('DELETED',)
| 
| /run/act/actions/oracle-actions-run-oci-cli-command@v1.3.1/src/main.ts:67
|       const stdout = JSON.parse(cliResult.stdout)
| ^
| SyntaxError: Unexpected end of JSON input
|     at JSON.parse (<anonymous>)
|     at runOciCliCommand (/run/act/actions/oracle-actions-run-oci-cli-command@v1.3.1/src/main.ts:67:1)
|     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[Test/test]   ❌  Failure - Main Destroy RMS Stack
[Test/test] exitcode '1': failure
[Test/test] 🏁  Job failed

The only way I've found to get the runner to not fail with this command is to set the --debug flag, which somehow the runner has no problem parsing. However, this is not an acceptable solution since it exposes some internals.

This seems similar to an old issue - https://github.com/oracle-actions/run-oci-cli-command/issues/18

Djelibeybi commented 1 week ago

Except I added a check to see if the output is JSON or not, which it seems to not be working for this command. I think the simplest option here is to provide an flag that indicates there is no expected response and to mark the action as successful based on exit code.

Djelibeybi commented 6 days ago

Can you please test with v1.3.2 and let me know if this works for you? Open a new issue if it doesn't. Thanks!