diff --git a/action.yml b/action.yml index 50e3079..9cb0efa 100644 --- a/action.yml +++ b/action.yml @@ -170,7 +170,7 @@ runs: CODEX_HOME_OVERRIDE: ${{ inputs['codex-home'] }} SAFETY_STRATEGY: ${{ inputs['safety-strategy'] }} CODEX_USER: ${{ inputs['codex-user'] }} - CODEX_RUN_ID: ${{ github.run_id }} + CODEX_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }} run: | node "$ACTION_PATH/dist/main.js" resolve-codex-home \ --codex-home-override "$CODEX_HOME_OVERRIDE" \ @@ -183,7 +183,7 @@ runs: shell: bash env: CODEX_HOME: ${{ steps.resolve_home.outputs.codex-home }} - CODEX_RUN_ID: ${{ github.run_id }} + CODEX_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }} run: | server_info_file="$CODEX_HOME/$CODEX_RUN_ID.json" echo "server_info_file=$server_info_file" >> "$GITHUB_OUTPUT" diff --git a/test/runAttemptState.test.mjs b/test/runAttemptState.test.mjs new file mode 100644 index 0000000..b55e52d --- /dev/null +++ b/test/runAttemptState.test.mjs @@ -0,0 +1,19 @@ +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import { test } from "node:test"; +import { fileURLToPath } from "node:url"; + +const actionPath = fileURLToPath(new URL("../action.yml", import.meta.url)); + +test("server-info state includes the GitHub run attempt", async () => { + const source = await readFile(actionPath, "utf8"); + const expected = + "CODEX_RUN_ID: ${{ github.run_id }}-${{ github.run_attempt }}"; + + assert.equal(source.split(expected).length - 1, 2); + assert.doesNotMatch( + source, + /^\s*CODEX_RUN_ID: \$\{\{ github\.run_id \}\}\s*$/m + ); + assert.match(source, /server_info_file="\$CODEX_HOME\/\$CODEX_RUN_ID\.json"/); +});