From b48ce325ad059c4f6b64a0fc8e39b5fe3fd51091 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 3 Sep 2026 19:30:53 +0300 Subject: [PATCH] feat: add allow-upload-failure input Requires a runner with https://github.com/CodSpeedHQ/codspeed/pull/527 --- README.md | 7 +++++++ action.yml | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/README.md b/README.md index 2ded776..87b4e3c 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,13 @@ GitHub Actions for running [CodSpeed](https://codspeed.io) in your CI. # Set to "true" to disable. Enabled by default on supported runners. # Requires runner v5.4.0 or later. disable-memory-capture-stack: "" + + # [OPTIONAL] + # Allow the action to complete successfully even if the benchmark results could not be + # uploaded to CodSpeed, for instance because a workflow triggered from a fork cannot + # access the CodSpeed token. Failures of the benchmarks themselves still fail the + # action. Set to "true" to enable. Defaults to "false". + allow-upload-failure: "false" ``` # Outputs diff --git a/action.yml b/action.yml index 0864e9e..c8f9749 100644 --- a/action.yml +++ b/action.yml @@ -74,6 +74,16 @@ inputs: required: false default: "false" + allow-upload-failure: + description: | + Allow the action to complete successfully even if the benchmark results could not be uploaded to + CodSpeed, because of an authentication or an upload error. + This is useful for workflows triggered from forks. Failures of the benchmarks themselves still fail the action. + Requires a runner version that reports dedicated exit codes for these failures; with older runners, + the action fails as usual. Defaults to 'false'. + required: false + default: "false" + go-runner-version: description: "The version of the go-runner to use (e.g., 1.0.0, 1.0.0-beta.1). If not specified, the latest version will be installed" required: false @@ -334,4 +344,23 @@ runs: fi # Run the benchmarks + set +e codspeed run "${RUNNER_ARGS[@]}" + EXIT_CODE=$? + set -e + + # The runner exits with 4 for auth errors and 5 for other upload errors. + if [ "${{ inputs.allow-upload-failure }}" = "true" ]; then + case "$EXIT_CODE" in + 4) + echo "::warning title=CodSpeed results not uploaded::Could not authenticate against CodSpeed, so the benchmark results were not uploaded. Continuing because 'allow-upload-failure' is enabled." + exit 0 + ;; + 5) + echo "::warning title=CodSpeed results not uploaded::The benchmarks ran, but their results could not be uploaded to CodSpeed. Continuing because 'allow-upload-failure' is enabled." + exit 0 + ;; + esac + fi + + exit $EXIT_CODE