Closed bodo-hugo-barwich closed 1 year ago
To avoid the abrupt exit without any activity information and build a shortcut for:
cpan-upload ${{ steps.build_release.outputs.file }} 2>cpan-upload_error.log > cpan-upload.log || echo "Exit Code: '$?'" >> cpan-upload.log
publish_res=`cat cpan-upload.log | grep -i "exit code:" | cut -d"'" -f2`
if [ -z "$publish_res" ]; then publish_res=0; echo "Exit Code: '0'" >> cpan-upload.log; fi;
duplicated=`cat cpan-upload_error.log | grep -i "Conflict" | wc -l`
echo "CPAN Upload Report:"
cat cpan-upload.log
echo "CPAN Upload Error:"
cat cpan-upload_error.log
if [ $duplicated -ne 1 ]; then exit $publish_res ; fi;
a script is needed which enables the postprocessing and alternative existing without ignoring all errors but selectively discard certain errors or recover from them.
For the sake of easy automated processing there will be different output formats of the command execution results:
Data::Dump
$ bin/run_subprocess.pl -n "test-script" -c "t/test_script.pl 4 5"
>>>>SUMMARY:
command: t/test_script.pl 4 5
name: test-script
pid: 7140
exit code: 5
error code: 1
>>>>STDOUT:
Start - Time Now: '1688629571.94443' s
script 'test_script.pl' START 0
script 'test_script.pl' PAUSE '4' ...
script 'test_script.pl' END 1
End - Time Now: '1688629575.94459' s
script 'test_script.pl' done in '4000.15807151794' ms
script 'test_script.pl' EXIT '5'
>>>>STDERR:
script 'test_script.pl' START 0 ERROR
script 'test_script.pl' END 1 ERROR
>>>>END>>>>
$ bin/run_subprocess.pl -n "test-script" -c "t/test_script.pl 2 0" -f json
:
{"stdout":"Start - Time Now: '1688630015.5626' s\nscript 'test_script.pl' START 0\nscript 'test_script.pl' PAUSE '2' ...\nscript 'test_script.pl' END 1\nEnd - Time Now: '1688630017.56275' s\nscript 'test_script.pl' done in '2000.15211105347' ms\nscript 'test_script.pl' EXIT '0'\n","command":"t/test_script.pl 2 0","exit_code":0,"error_code":0,"pid":"7233","name":"test-script","stderr":"script 'test_script.pl' START 0 ERROR\nscript 'test_script.pl' END 1 ERROR\n"}
$ bin/run_subprocess.pl -n "test-script" -c "t/test_script.pl 2 0" -f yaml
:
---
command: t/test_script.pl 2 0
error_code: 0
exit_code: 0
name: test-script
pid: 7235
stderr: |
script 'test_script.pl' START 0 ERROR
script 'test_script.pl' END 1 ERROR
stdout: |
Start - Time Now: '1688630028.54734' s
script 'test_script.pl' START 0
script 'test_script.pl' PAUSE '2' ...
script 'test_script.pl' END 1
End - Time Now: '1688630030.54752' s
script 'test_script.pl' done in '2000.17905235291' ms
script 'test_script.pl' EXIT '0'
Also different Plain Text multiline boundaries can be specified:
$ bin/run_subprocess.pl -n "test-script fails" -c "t/test_script.pl 3 6" -b ':====' -t 2
script 'run_subprocess.pl' - Command Result:
:====SUMMARY:
command: t/test_script.pl 3 6
name: test-script fails
pid: 7387
exit code: -1
error code: 4
:====STDOUT:
:====STDERR:
script 'test_script.pl' START 0 ERROR
Sub Process (7387) 'test-script fails': Execution timed out!
Execution Time '2 / 2'
Process will be terminated.
Sub Process (7387) 'test-script fails': Process terminating ...
:====END:====
the Runner Script bin/run_subprocess.pl
will accept different Options to be passed to the Process::SubProcess
obejct as parameters:
Mandatory parameter 'command' missing in call to "eval"
run_subprocess.pl [-bcdfhnrtx] [long options...]
-c STR --command STR the COMMAND to be run
-n STR --name STR the NAME for the COMMAND
-r INT --readtimeout INT the TIMEOUT for reading of the output from
COMMAND
-t INT --timeout INT the TIMEOUT for execution the COMMAND
-x --exit execution returns exit code
-f STR --format STR the format for the output
-b STR --boundary STR boundary string for the plain text output
-d --debug execution debug output
-h --help print usage message and exit
Runner Result:
''
Runner EXIT CODE: '255'
This behaviour is thoroughly tested with the new t/test_runner.t
test.
This feature becomes available with the Process::SubProcess
version v2.1.0
For automation purposes a script is needed which captures the outputs and separates them correctly which enables advanced processing in automations