Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
status_sha: ${{ github.sha }}
status_name: text-bench-result
status_on_degraded: neutral
job_summary: true
benchdiff_args: |
--packages ./unicode/...
--cpu=1
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ Status to report for degraded results.
Options are "success", "failure" and "neutral"


### fail_on_degraded

default: `false`

Fail the action if any benchmarks degrade.

This is a boolean value. Any value other than "true" is interpreted as false.


### job_summary

default: `false`

Whether to add results to the workflow job summary.

This is a boolean value. Any value other than "true" is interpreted as false.


### github_token

default: `${{ github.token }}`
Expand Down
49 changes: 49 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ inputs:
Options are "success", "failure" and "neutral"
default: "failure"
required: false
fail_on_degraded:
description: |
Fail the action if any benchmarks degrade.

This is a boolean value. Any value other than "true" is interpreted as false.
default: "false"
required: false
job_summary:
description: |
Whether to add results to the workflow job summary.

This is a boolean value. Any value other than "true" is interpreted as false.
default: "false"
required: false
github_token:
description: |
Authentication token to use for reporting status.
Expand Down Expand Up @@ -107,7 +121,12 @@ runs:
fi
- id: install
shell: bash
env:
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
run: |
if [ "${{ inputs.job_summary }}" == "true" ]; then
echo "::notice ::See summary at $WORKFLOW_URL"
fi
export ACTION_PATH='${{ github.action_path }}'
export BENCHDIFF_DIR='${{ runner.temp }}/benchdiff'
export BENCHDIFF_VERSION='${{ inputs.benchdiff_version }}'
Expand All @@ -134,3 +153,33 @@ runs:
export STATUS_NAME='${{ inputs.status_name }}'
export STATUS_ON_DEGRADED='${{ inputs.status_on_degraded }}'
"$ACTION_PATH/src/report-status.sh"
- id: summary
if: inputs.job_summary == 'true'
shell: bash
run: |
export BENCHSTAT_OUTPUT='${{ steps.run-benchdiff.outputs.benchstat_output }}'
export DEGRADED_RESULT='${{ steps.run-benchdiff.outputs.degraded_result }}'
export HEAD_SHA='${{ steps.run-benchdiff.outputs.head_sha }}'
export BASE_SHA='${{ steps.run-benchdiff.outputs.base_sha }}'
export BENCH_COMMAND='${{ steps.run-benchdiff.outputs.bench_command }}'
export ACTION_PATH='${{ github.action_path }}'
"$ACTION_PATH/src/job-summary.sh"
- id: degraded
if: steps.run-benchdiff.outputs.degraded_result == 'true'
shell: bash
env:
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
run: |
if [ "${{ inputs.fail_on_degraded }}" == "true" ]; then
if [ "${{ inputs.job_summary }}" == "true" ]; then
echo "::error ::Benchmarks degraded. See summary at $WORKFLOW_URL"
else
echo "::error ::Benchmarks degraded."
fi
exit 1
fi
if [ "${{ inputs.job_summary }}" == "true" ]; then
echo "::warning ::Benchmarks degraded. See summary at $WORKFLOW_URL"
else
echo "::warning ::Benchmarks degraded."
fi
35 changes: 35 additions & 0 deletions src/job-summary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e

# Expected global environment variables
#
# $BENCHSTAT_OUTPUT
# $DEGRADED_RESULT
# $HEAD_SHA
# $BASE_SHA
# $BENCH_COMMAND

if [ "$(uname -s)" != "Linux" ]; then
echo This action only runs on Linux
exit 1
fi

output_summary="$(cat <<EOF
## Benchdiff Results

**Benchmark Command:** \`$BENCH_COMMAND\`
**Head:** \`$HEAD_SHA\`
**Base:** \`$BASE_SHA\`
**Degraded**: $DEGRADED_RESULT

<details>
<summary>benchstat output</summary>

$BENCHSTAT_OUTPUT

</details>
EOF
)"

echo "$output_summary" >> "$GITHUB_STEP_SUMMARY"