Skip to content

Commit 860dfd4

Browse files
committed
Add error tracing to execution failures and log to specified trace file
1 parent e1167c0 commit 860dfd4

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/workflow.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,14 @@ jobs:
9797
uses: actionforge/action@6635019c96dcd6b3e018df654473a547471338a5 # v0.14.5
9898
env:
9999
LICENSE: ${{ matrix.license }}
100+
ACT_TRACE_FILE: /tmp/actrun-trace.log
100101
with:
101102
runner-path: ${{ github.workspace }}/actrun
102103
graph-file: build-test-publish.act
103104
inputs: ${{ toJson(inputs) }}
104105
secrets: ${{ toJson(secrets) }}
105-
matrix: ${{ toJson(matrix) }}
106+
matrix: ${{ toJson(matrix) }}
107+
108+
- name: Dump error trace
109+
if: failure()
110+
run: cat /tmp/actrun-trace.log 2>/dev/null || echo "No trace file"

core/executions.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package core
22

33
import (
4+
"fmt"
5+
"os"
46
"sync"
57

68
"github.com/actionforge/actrun-cli/utils"
@@ -112,6 +114,12 @@ func (n *Executions) Execute(outputPort OutputId, ec *ExecutionState, err error)
112114
}
113115

114116
if err != nil {
117+
if traceFile := os.Getenv("ACT_TRACE_FILE"); traceFile != "" {
118+
if f, ferr := os.OpenFile(traceFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); ferr == nil {
119+
fmt.Fprintf(f, "TRACE: node '%s' (%s) port '%s' error: %v\n", nodeID, nodeName, dest.Port, err)
120+
f.Close()
121+
}
122+
}
115123
return err
116124
}
117125

0 commit comments

Comments
 (0)