RetroDECK/functions/post_build_check.sh
MonkeyX 921567e7fc
Some checks failed
Build RetroDECK / Build_RetroDECK (push) Has been cancelled
Build RetroDECK / GitHub-publish (push) Has been cancelled
Build RetroDECK / Automated_Tests (push) Has been cancelled
Cooker (#1012)
* Fix features.json, add srm launcher

* Logging

* Set correct logging levels

* Bob makes it nexy year already!

* full splash screen dates

* Alpha version of post build check

* Bob makes a comeback, by adding a cli argument

* test build

* json update?

* Stop multi press of SRM button

* If error then just carry on :)

* Allow ES-DE to overwrite files

* Fixed debug cp -rnL issues and moved post check sh file

* Don't supress messages for cp -rnL

* Make post_build_check executable
2024-12-24 15:19:24 +00:00

55 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
# todo create launch test commands ie mame -help, ruffle --version
# Log file
LOG_FILE="$HOME/check.log"
# Clear previous log
> "$LOG_FILE"
# Extract launch commands and CLI arguments using jq
mapfile -t commands < <(jq -r '.emulator | to_entries[] | [.value.launch, .value."cli-arg"] | @tsv' /app/retrodeck/config/retrodeck/reference_lists//features.json)
# Timeout duration in seconds
TIMEOUT=3
# Function to run command with timeout
run_and_check() {
local cmd="$1"
local cli_arg="${2:-}"
local full_cmd="${cmd}${cli_arg:+ $cli_arg}"
# Verify command exists
if ! command -v "$cmd" &> /dev/null; then
echo "✗ Command not found: $cmd (Exit Code: 127)" | tee -a "$LOG_FILE"
return 127
fi
# Run command with timeout
timeout -s TERM $TIMEOUT $full_cmd
local exit_code=$?
# Log the results
echo "Command: $full_cmd, Exit Code: $exit_code" | tee -a "$LOG_FILE"
case $exit_code in
0)
echo "$full_cmd completed successfully" | tee -a "$LOG_FILE"
;;
124)
echo "$full_cmd terminated after $TIMEOUT seconds" | tee -a "$LOG_FILE"
;;
137)
echo "$full_cmd killed" | tee -a "$LOG_FILE"
;;
*)
echo "$full_cmd failed" | tee -a "$LOG_FILE"
;;
esac
return $exit_code
}
# Execute commands
for entry in "${commands[@]}"; do
# Split the TSV entry into command and CLI arg
IFS=$'\t' read -r cmd cli_arg <<< "$entry"
# Run the command with optional CLI argument
run_and_check "$cmd" "$cli_arg"
done