Introduce the shared shell template
Intent: Create a single source-of-truth shell fragment that writes the terminal result JSON, parameterized with placeholder tokens so it can be reused by different execution backends.
Affected files: nix/pikaci/local-terminal-result-fragment.sh.in
@@ -0,0 +1,16 @@
+status="completed"
+message="test passed"
+if [ "$code" -ne 0 ]; then
+ status="failed"
+ message="test command exited with $code"
+fi
+
+cat > __PIKACI_RESULT_PATH__ <<EOF
+{
+ "schema_version": __PIKACI_SCHEMA_VERSION__,
+ "status": "$status",
+ "exit_code": $code,
+ "finished_at": "$(__PIKACI_FINISHED_AT_COMMAND__)",
+ "message": "$message"
+}
+EOF
A new file nix/pikaci/local-terminal-result-fragment.sh.in is added. It contains the shell logic that was previously duplicated in both the Rust executor and the Nix guest module:
- Set
statusandmessagebased on exit code ($code). - Write a JSON object to a file via a heredoc.
Three placeholder tokens make the template generic:
| Token | Purpose |
|---|---|
__PIKACI_RESULT_PATH__ | Destination file path for the JSON result |
__PIKACI_SCHEMA_VERSION__ | Integer schema version of the lifecycle contract |
__PIKACI_FINISHED_AT_COMMAND__ | Shell command that produces an ISO-8601 timestamp |
Each consumer replaces these tokens with values appropriate to its platform (e.g., date -Iseconds on Linux vs date -u +"%Y-%m-%dT%H:%M:%SZ" on macOS).