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
62 changes: 62 additions & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

permissions:
contents: read
pull-requests: read

jobs:
compute-baseline:
Expand Down Expand Up @@ -87,6 +88,60 @@ jobs:
- name: Checkout code
uses: actions/checkout@v5

- name: Check for skip-performance-check label
id: check-label
env:
GH_TOKEN: ${{ github.token }}
run: |
SKIP_EVAL="false"

if [ "${{ github.event_name }}" == "pull_request" ]; then
# For pull_request events, check labels directly
# Convert labels array to JSON and extract names
LABELS='${{ toJSON(github.event.pull_request.labels) }}'
if echo "$LABELS" | jq -r '.[].name' | grep -q "skip-performance-check"; then
echo "Label 'skip-performance-check' found on PR"
SKIP_EVAL="true"
fi
elif [ "${{ github.event_name }}" == "merge_group" ]; then
# For merge_group events, extract PR number from head_ref and check its labels
# head_ref format is typically: refs/heads/gh-readonly-queue/{base_branch}/pr-{number}-{sha}
HEAD_REF="${{ github.event.merge_group.head_ref }}"
echo "Merge group head_ref: $HEAD_REF"

# Extract PR number from the head_ref
if [[ "$HEAD_REF" =~ pr-([0-9]+)- ]]; then
PR_NUMBER="${BASH_REMATCH[1]}"
echo "Extracted PR number: $PR_NUMBER"

# Use GitHub CLI to fetch PR labels
set +e # Don't exit on error
PR_LABELS=$(gh pr view "$PR_NUMBER" --repo ${{ github.repository }} --json labels --jq '.labels[].name' 2>/tmp/gh_error.log)
GH_EXIT_CODE=$?
set -e # Re-enable exit on error

if [ $GH_EXIT_CODE -eq 0 ]; then
if echo "$PR_LABELS" | grep -q "skip-performance-check"; then
echo "Label 'skip-performance-check' found on PR #$PR_NUMBER (from merge group)"
SKIP_EVAL="true"
else
echo "Label 'skip-performance-check' not found on PR #$PR_NUMBER"
fi
else
echo "Warning: Could not fetch PR labels for PR #$PR_NUMBER (exit code: $GH_EXIT_CODE)"
if [ -s /tmp/gh_error.log ]; then
echo "Error details:"
cat /tmp/gh_error.log
fi
fi
else
echo "Could not extract PR number from head_ref: $HEAD_REF"
fi
fi

echo "skip_eval=$SKIP_EVAL" >> $GITHUB_OUTPUT
echo "Skip evaluation: $SKIP_EVAL"

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -110,4 +165,11 @@ jobs:
path: ./baseline

- name: Evaluate performance
if: steps.check-label.outputs.skip_eval != 'true'
run: evaluate ./baseline/performance_result.json ./candidate/performance_result.json

- name: Skip evaluation (label present)
if: steps.check-label.outputs.skip_eval == 'true'
run: |
echo "⚠️ Performance evaluation skipped due to 'skip-performance-check' label"
echo "The evaluation step was bypassed and will not block merging"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ The repository includes a GitHub Actions workflow (`.github/workflows/performanc
- Runs `compute` on the PR branch (candidate)
- Runs `compute` on the main branch (baseline)
- Runs `evaluate` to compare candidate vs baseline
3. **On Merge Queue**: Runs the same evaluation as pull requests

#### Skipping Performance Evaluation

You can skip the performance evaluation for a specific PR by adding the `skip-performance-check` label to the PR. This is useful when:
- You know the performance regression is expected and acceptable
- You're making changes that don't affect performance (e.g., documentation)
- The performance test is flaky or not relevant for the change

**How it works:**
- **For Pull Requests**: Add the `skip-performance-check` label to the PR. The evaluation step will be skipped and will not block merging.
- **For Merge Queue**: The label must be present on the PR before it enters the merge queue. The workflow will check the PR's labels even when running in the merge group context.

When the label is present, the evaluation job still runs but skips the actual performance comparison, allowing the PR to merge even if performance has regressed.

### Installation

Expand Down