Skip to content

Replace dyn_client with client to align with ocp wrapper change #6273

Replace dyn_client with client to align with ocp wrapper change

Replace dyn_client with client to align with ocp wrapper change #6273

# Smoke Tests Label Manager - Automatically adds/removes 'smoke-tests:pending-analysis' label based on CodeRabbit analysis
# Created with Claude Code assistance
#
# Summary:
# ┌──────────────────────────────────────────────────────────────┬───────────────────────────────┬────────────────────────────────────────┐
# │ CodeRabbit Comment Contains │ Current Label │ Action │
# ├──────────────────────────────────────────────────────────────┼───────────────────────────────┼────────────────────────────────────────┤
# │ "**Run smoke tests: True**" AND "## Test Execution Plan" │ None │ ✅ Add 'smoke-tests:pending-analysis' │
# │ "**Run smoke tests: True**" AND "## Test Execution Plan" │ Already has label │ ✅ No-op (safe) │
# │ "**Run smoke tests: False**" AND "## Test Execution Plan" │ Has label │ ✅ Remove label │
# │ "**Run smoke tests: False**" AND "## Test Execution Plan" │ None │ ✅ No action │
# │ New commit pushed (PR opened/sync/reopened) │ Has label │ ✅ Remove label │
# │ Missing "## Test Execution Plan" │ Any │ ⏭️ No action │
# │ Neither pattern │ Any │ ⏭️ No action │
# │ Comment not from CodeRabbit │ Any │ ⏭️ Does NOT run │
# └──────────────────────────────────────────────────────────────┴───────────────────────────────┴────────────────────────────────────────┘
#
# CodeRabbit comments trigger via: pull_request_review_comment (inline comments) or issue_comment (PR comments)
name: "Smoke Tests Label from CodeRabbit"
on:
# WARNING: pull_request_target runs with write permissions on base repo
# Safe here because we only manipulate labels without executing PR code
# NEVER add steps that checkout or execute code from the PR branch
# Event types: pull_request_target (reset), pull_request_review_comment/issue_comment (CodeRabbit)
pull_request_target:
types: [opened, synchronize, reopened]
pull_request_review_comment:
types: [created, edited]
issue_comment:
types: [created, edited]
permissions:
pull-requests: write
contents: read
jobs:
reset-on-push:
name: Reset label on push
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
steps:
- name: Remove label
uses: actions-ecosystem/action-remove-labels@v1
continue-on-error: true
with:
number: ${{ github.event.pull_request.number }}
labels: smoke-tests:pending-analysis
github_token: ${{ secrets.GITHUB_TOKEN }}
manage-smoke-tests-label:
name: Manage label from CodeRabbit
# Only run for CodeRabbit comments
if: |
github.event_name != 'pull_request_target' &&
(
(github.event_name == 'issue_comment' &&
(github.event.comment.user.login == 'coderabbitai' || github.event.comment.user.login == 'coderabbitai[bot]')) ||
(github.event_name == 'pull_request_review_comment' &&
(github.event.comment.user.login == 'coderabbitai' || github.event.comment.user.login == 'coderabbitai[bot]'))
)
runs-on: ubuntu-latest
steps:
- name: Determine label action
id: flow
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
[ -z "$COMMENT_BODY" ] && { echo "ERROR: Empty comment body"; exit 1; }
# Strip <details> and <summary> blocks to avoid matching patterns in analysis chain scripts
COMMENT_STRIPPED=$(sed -e '/<details>/,/<\/details>/d' -e '/<summary>/,/<\/summary>/d' <<< "$COMMENT_BODY")
# Use line-anchored patterns to avoid matching meta-discussions about the workflow
# These patterns require the text to appear at the start of a line, matching the actual
# Test Execution Plan format instead of matching when CodeRabbit explains how it works
HAS_TEST_PLAN=$(grep -qE '^## Test Execution Plan' <<< "$COMMENT_STRIPPED" && echo "true" || echo "false")
HAS_RUN_TRUE=$(grep -qE '^\*\*Run smoke tests: True\*\*' <<< "$COMMENT_STRIPPED" && echo "true" || echo "false")
HAS_RUN_FALSE=$(grep -qE '^\*\*Run smoke tests: False\*\*' <<< "$COMMENT_STRIPPED" && echo "true" || echo "false")
FLOW_ADD="false"
FLOW_REMOVE="false"
if [ "$HAS_TEST_PLAN" = "true" ] && [ "$HAS_RUN_TRUE" = "true" ]; then
FLOW_ADD="true"
elif [ "$HAS_TEST_PLAN" = "true" ] && [ "$HAS_RUN_FALSE" = "true" ]; then
FLOW_REMOVE="true"
# Note: If both TRUE and FALSE are present, no action is taken (edge case)
fi
echo "flow_add=$FLOW_ADD" >> $GITHUB_OUTPUT
echo "flow_remove=$FLOW_REMOVE" >> $GITHUB_OUTPUT
- name: Add label
if: steps.flow.outputs.flow_add == 'true'
uses: actions-ecosystem/action-add-labels@v1
continue-on-error: true
with:
number: ${{ github.event.issue.number || github.event.pull_request.number }}
labels: smoke-tests:pending-analysis
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Remove label
if: steps.flow.outputs.flow_remove == 'true'
uses: actions-ecosystem/action-remove-labels@v1
continue-on-error: true
with:
number: ${{ github.event.issue.number || github.event.pull_request.number }}
labels: smoke-tests:pending-analysis
github_token: ${{ secrets.GITHUB_TOKEN }}