@@ -48,7 +48,9 @@ async function run() {
4848 // Get inputs
4949 const actionRef = core . getInput ( "action-ref" ) ;
5050 const extraArgs = core . getInput ( "extra-args" ) || "" ;
51- const straceOptions = core . getInput ( "strace-options" ) || "-f -e trace=network,write,open" ;
51+ // Improved default strace options for better insights
52+ const defaultStraceOptions = "-f -v -s 256 -e trace=file,process,network,signal,ipc,desc,memory" ;
53+ const straceOptions = core . getInput ( "strace-options" ) || defaultStraceOptions ;
5254 const enableStrace = core . getInput ( "enable-strace" ) . toLowerCase ( ) === "true" ;
5355
5456 // Parse action-ref (expects format: owner/repo@ref)
@@ -223,8 +225,13 @@ async function processAction(actionDir, extraArgs) {
223225 // Parse strace options into an array
224226 const straceOptionsList = straceOptions . split ( / \s + / ) . filter ( Boolean ) ;
225227
226- // Create output file for strace results
227- const stracelLogFile = path . join ( process . env . GITHUB_WORKSPACE || '.' , 'strace-output.log' ) ;
228+ // Create output file for strace results with timestamp and action name
229+ const repoName = repo . split ( "/" ) [ 1 ] ;
230+ const timestamp = new Date ( ) . toISOString ( ) . replace ( / : / g, '-' ) ;
231+ const stracelLogFile = path . join (
232+ process . env . GITHUB_WORKSPACE || '.' ,
233+ `strace-${ repoName } -${ timestamp } .log`
234+ ) ;
228235
229236 // Add output file option if not already specified
230237 if ( ! straceOptionsList . includes ( '-o' ) && ! straceOptionsList . includes ( '--output' ) ) {
@@ -259,6 +266,36 @@ async function processAction(actionDir, extraArgs) {
259266 const cp = await exec . getExecOutput ( "strace" , [ ...straceOptionsList , "node" , entryFile , ...args ] , options ) ;
260267 core . debug ( `Strace process completed with exit code: ${ cp . exitCode } ` ) ;
261268
269+ // Add helpful headers to the strace log file
270+ if ( fs . existsSync ( stracelLogFile ) ) {
271+ // Create a temporary file for the header
272+ const headerFile = `${ stracelLogFile } .header` ;
273+ const header = `
274+ #=============================================================================
275+ # Strace log for GitHub Action: ${ actionRef }
276+ # Date: ${ new Date ( ) . toISOString ( ) }
277+ # Command: node ${ entryFile } ${ args . join ( " " ) }
278+ # Options: ${ straceOptions }
279+ #=============================================================================
280+
281+ ` ;
282+ fs . writeFileSync ( headerFile , header ) ;
283+
284+ // Concatenate the header and the original strace output
285+ const originalContent = fs . readFileSync ( stracelLogFile ) ;
286+ fs . writeFileSync ( stracelLogFile , Buffer . concat ( [
287+ Buffer . from ( header ) ,
288+ originalContent
289+ ] ) ) ;
290+
291+ try {
292+ // Delete the temporary header file
293+ fs . unlinkSync ( headerFile ) ;
294+ } catch ( error ) {
295+ // Ignore any errors while deleting the temporary file
296+ }
297+ }
298+
262299 // Export the strace log path as an output
263300 core . setOutput ( "strace-log" , stracelLogFile ) ;
264301
0 commit comments