From 8e12489d8e08c34de7bf235e5c607a998c20b077 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 14 Dec 2020 15:48:58 +0000 Subject: [PATCH 1/2] Make the TRACE_ID unique across repos and re-runs This change adds the repo name and a random suffix to TRACE_ID. Otherwise this ID would not be unique across repositories and re-runs (which preserve the RUN_ID, see https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables). --- dist/index.js | 4 +++- src/index.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index c7ebf14..585c2c4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2175,10 +2175,12 @@ function run() { } const buildStart = util.getTimestamp(); const traceComponents = [ + util.getEnv('GITHUB_REPOSITORY'), util.getEnv('GITHUB_WORKFLOW'), util.getEnv('GITHUB_JOB'), util.getEnv('GITHUB_RUN_NUMBER'), - core.getInput('matrix-key') + core.getInput('matrix-key'), + util.randomInt(Math.pow(2, 32)).toString() ]; const traceId = util.replaceSpaces(traceComponents.filter(value => value).join('-')); // save buildStart to be used in the post section diff --git a/src/index.ts b/src/index.ts index 617f717..5ea159b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,10 +11,12 @@ async function run(): Promise { const buildStart = util.getTimestamp() const traceComponents = [ + util.getEnv('GITHUB_REPOSITORY'), util.getEnv('GITHUB_WORKFLOW'), util.getEnv('GITHUB_JOB'), util.getEnv('GITHUB_RUN_NUMBER'), - core.getInput('matrix-key') + core.getInput('matrix-key'), + util.randomInt(2 ** 32).toString() ] const traceId = util.replaceSpaces(traceComponents.filter(value => value).join('-')) From 3db32e142420b5c872a8c9f558da55b927373ffe Mon Sep 17 00:00:00 2001 From: Koenraad Verheyden Date: Wed, 16 Dec 2020 00:11:46 +0100 Subject: [PATCH 2/2] Document why a random number is added to traceId --- dist/index.js | 1 + src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/index.js b/dist/index.js index 585c2c4..58fd555 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2180,6 +2180,7 @@ function run() { util.getEnv('GITHUB_JOB'), util.getEnv('GITHUB_RUN_NUMBER'), core.getInput('matrix-key'), + // append a random number to ensure traceId is unique when the workflow is re-run util.randomInt(Math.pow(2, 32)).toString() ]; const traceId = util.replaceSpaces(traceComponents.filter(value => value).join('-')); diff --git a/src/index.ts b/src/index.ts index 5ea159b..ccfa912 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,7 @@ async function run(): Promise { util.getEnv('GITHUB_JOB'), util.getEnv('GITHUB_RUN_NUMBER'), core.getInput('matrix-key'), + // append a random number to ensure traceId is unique when the workflow is re-run util.randomInt(2 ** 32).toString() ] const traceId = util.replaceSpaces(traceComponents.filter(value => value).join('-'))