From c0f884ca8d25fd0c889e39c105d0715d2664a012 Mon Sep 17 00:00:00 2001 From: Prucek Date: Wed, 26 Nov 2025 15:32:08 +0100 Subject: [PATCH] .claude: add pre-branching plugin --- .claude/.claude-plugin/plugin.json | 121 ++++++++++++ .../skills/bump-analysis-jobs.sh | 114 +++++++++++ .../copy-handcrafted-release-gating-jobs.sh | 110 +++++++++++ .../skills/copy-release-controller-configs.sh | 45 +++++ .../skills/create-pre-branching-branch.sh | 48 +++++ .../skills/create-pre-branching-commits.sh | 94 +++++++++ .../skills/download-sippy-config.sh | 31 +++ .../skills/regenerate-prow-jobs.sh | 30 +++ .../skills/update-release-gating-jobs.sh | 42 ++++ .../validate-release-controller-config.sh | 40 ++++ .claude/commands/pre-branching.md | 185 ++++++++++++++++++ 11 files changed, 860 insertions(+) create mode 100644 .claude/.claude-plugin/plugin.json create mode 100755 .claude/.claude-plugin/skills/bump-analysis-jobs.sh create mode 100755 .claude/.claude-plugin/skills/copy-handcrafted-release-gating-jobs.sh create mode 100755 .claude/.claude-plugin/skills/copy-release-controller-configs.sh create mode 100755 .claude/.claude-plugin/skills/create-pre-branching-branch.sh create mode 100755 .claude/.claude-plugin/skills/create-pre-branching-commits.sh create mode 100755 .claude/.claude-plugin/skills/download-sippy-config.sh create mode 100755 .claude/.claude-plugin/skills/regenerate-prow-jobs.sh create mode 100755 .claude/.claude-plugin/skills/update-release-gating-jobs.sh create mode 100755 .claude/.claude-plugin/skills/validate-release-controller-config.sh create mode 100644 .claude/commands/pre-branching.md diff --git a/.claude/.claude-plugin/plugin.json b/.claude/.claude-plugin/plugin.json new file mode 100644 index 0000000000..619c054bc8 --- /dev/null +++ b/.claude/.claude-plugin/plugin.json @@ -0,0 +1,121 @@ +{ + "name": "openshift-branching", + "version": "1.0.0", + "description": "Automates OpenShift release pre-branching tasks", + "author": "TestPlatform Team", + "commands": [ + { + "name": "pre-branching", + "description": "Execute pre-branching tasks for OpenShift release X.Y", + "usage": "/pre-branching ", + "settingsFile": "settings.pre-branching.json", + "examples": [ + "/pre-branching 4.21", + "/pre-branching 4.22" + ] + } + ], + "skills": [ + { + "name": "create-pre-branching-branch", + "description": "Create and checkout pre-branching branch in release repository", + "script": "skills/create-pre-branching-branch.sh", + "permissions": [ + "Bash(git fetch:*)", + "Bash(git pull:*)", + "Bash(git checkout:*)", + "Bash(git show-ref:*)" + ] + }, + { + "name": "download-sippy-config", + "description": "Download latest Sippy configuration from GitHub", + "script": "skills/download-sippy-config.sh", + "permissions": [ + "Bash(curl :*)", + "Write(/tmp/**)" + ] + }, + { + "name": "copy-release-controller-configs", + "description": "Copy and update release-controller configurations from old version to new version", + "script": "skills/copy-release-controller-configs.sh", + "permissions": [ + "Read(../release/**)", + "Edit(../release/**)", + "Bash(cp :*)", + "Bash(sed :*)", + "Bash(find :*)" + ] + }, + { + "name": "update-release-gating-jobs", + "description": "Run generated-release-gating-jobs bumper with Sippy config", + "script": "skills/update-release-gating-jobs.sh", + "permissions": [ + "Bash(go build:*)", + "Bash(./generated-release-gating-jobs :*)", + "Read(../release/**)", + "Edit(../release/**)" + ] + }, + { + "name": "copy-handcrafted-release-gating-jobs", + "description": "Populate handcrafted X.Y+1 release-gating jobs from X.Y release", + "script": "skills/copy-handcrafted-release-gating-jobs.sh", + "permissions": [ + "Bash(cp :*)", + "Bash(sed :*)", + "Bash(make release-controllers)", + "Bash(make jobs)", + "Read(../release/**)", + "Edit(../release/**)" + ] + }, + { + "name": "regenerate-prow-jobs", + "description": "Regenerate Prow job configurations from CI operator configs", + "script": "skills/regenerate-prow-jobs.sh", + "permissions": [ + "Bash(make jobs)", + "Read(../release/**)", + "Write(../release/**)" + ] + }, + { + "name": "validate-release-controller-config", + "description": "Validate release-controller configurations", + "script": "skills/validate-release-controller-config.sh", + "permissions": [ + "Bash(hack/validate-release-controller-config.sh :*)", + "Read(../release/**)" + ] + }, + { + "name": "bump-analysis-jobs", + "description": "Bump analysis jobs (install, upgrade, overall) from old version to new version", + "script": "skills/bump-analysis-jobs.sh", + "permissions": [ + "Bash(python3:*)", + "Read(../release/**)", + "Edit(../release/**)" + ] + }, + { + "name": "create-pre-branching-commits", + "description": "Create the three standard pre-branching commits", + "script": "skills/create-pre-branching-commits.sh", + "permissions": [ + "Bash(git add:*)", + "Bash(git commit:*)", + "Bash(git diff:*)", + "Bash(git log:*)", + "Bash(git ls-files:*)" + ] + } + ], + "config": { + "RELEASE_REPO": "/home/prucek/work/release", + "CI_TOOLS_REPO": "/home/prucek/work/ci-tools" + } +} diff --git a/.claude/.claude-plugin/skills/bump-analysis-jobs.sh b/.claude/.claude-plugin/skills/bump-analysis-jobs.sh new file mode 100755 index 0000000000..257543cb01 --- /dev/null +++ b/.claude/.claude-plugin/skills/bump-analysis-jobs.sh @@ -0,0 +1,114 @@ +#!/bin/bash +set -euo pipefail + +OLD_VERSION="${1:-}" +NEW_VERSION="${2:-}" +RELEASE_REPO="${3:-}" + +if [ -z "$OLD_VERSION" ] || [ -z "$NEW_VERSION" ] || [ -z "$RELEASE_REPO" ]; then + echo "Usage: $0 " + echo "Example: $0 4.21 4.22 /path/to/release" + exit 1 +fi + +echo "==========================================" +echo "Bumping Analysis Jobs" +echo "==========================================" +echo "" +echo "Old version: $OLD_VERSION" +echo "New version: $NEW_VERSION" +echo "Release repo: $RELEASE_REPO" +echo "" + +cd "$RELEASE_REPO" + +# Export variables for Python script +export OLD_VERSION +export NEW_VERSION + +# Python script to extract and bump jobs +python3 << 'PYTHON_EOF' +import re +import sys +import os + +old_version = os.environ['OLD_VERSION'] +new_version = os.environ['NEW_VERSION'] + +def bump_analysis_job(job_text, old_ver, new_ver): + """Replace version numbers in a job definition""" + return job_text.replace(old_ver, new_ver) + +def extract_jobs(file_path, job_names): + """Extract complete job definitions for given job names from a YAML file""" + with open(file_path, 'r') as f: + content = f.read() + + jobs = [] + for job_name in job_names: + # Find the job by name - match from "- " to the next "- " or end of file + pattern = rf'(\n- .*?\n name: {re.escape(job_name)}\n.*?)(?=\n- |\Z)' + match = re.search(pattern, content, re.DOTALL) + if match: + jobs.append(match.group(1)) + print(f" ✓ Found job: {job_name}", file=sys.stderr) + else: + print(f" ✗ Could not find job: {job_name}", file=sys.stderr) + + return jobs + +def append_bumped_jobs(file_path, job_names, old_ver, new_ver): + """Extract jobs, bump versions, and append to the file""" + print(f"\nProcessing {file_path}...", file=sys.stderr) + jobs = extract_jobs(file_path, job_names) + + if not jobs: + print(f" No jobs found in {file_path}", file=sys.stderr) + return False + + # Read the current file + with open(file_path, 'r') as f: + content = f.read() + + # Bump versions in the extracted jobs + bumped_jobs = [bump_analysis_job(job, old_ver, new_ver) for job in jobs] + + # Append the bumped jobs to the file + new_content = content.rstrip() + '\n' + '\n'.join(bumped_jobs) + '\n' + + with open(file_path, 'w') as f: + f.write(new_content) + + print(f" ✓ Added {len(bumped_jobs)} bumped jobs", file=sys.stderr) + return True + +# Bump multiarch jobs +multiarch_file = 'ci-operator/jobs/openshift/multiarch/openshift-multiarch-master-periodics.yaml' +multiarch_jobs = [ + f'periodic-ci-openshift-multiarch-master-nightly-{old_version}-install-analysis-all-multi-p-p', + f'periodic-ci-openshift-multiarch-master-nightly-{old_version}-install-analysis-all-ppc64le', + f'periodic-ci-openshift-multiarch-master-nightly-{old_version}-install-analysis-all-s390x', +] + +print("\n=== Multiarch Analysis Jobs ===", file=sys.stderr) +append_bumped_jobs(multiarch_file, multiarch_jobs, old_version, new_version) + +# Bump release jobs +release_file = 'ci-operator/jobs/openshift/release/openshift-release-master-periodics.yaml' +release_jobs = [ + f'periodic-ci-openshift-release-master-nightly-{old_version}-install-analysis-all', + f'periodic-ci-openshift-release-master-nightly-{old_version}-upgrade-analysis-all', + f'periodic-ci-openshift-release-master-nightly-{old_version}-overall-analysis-all', +] + +print("\n=== Release Analysis Jobs ===", file=sys.stderr) +append_bumped_jobs(release_file, release_jobs, old_version, new_version) + +print("\n✓ All analysis jobs bumped successfully", file=sys.stderr) + +PYTHON_EOF + +echo "" +echo "==========================================" +echo "✓ Analysis jobs bumped!" +echo "==========================================" diff --git a/.claude/.claude-plugin/skills/copy-handcrafted-release-gating-jobs.sh b/.claude/.claude-plugin/skills/copy-handcrafted-release-gating-jobs.sh new file mode 100755 index 0000000000..dc32a69f98 --- /dev/null +++ b/.claude/.claude-plugin/skills/copy-handcrafted-release-gating-jobs.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# Skill: copy-handcrafted-release-gating-jobs +# Description: Populate handcrafted X.Y+1 release-gating jobs from X.Y release +# Usage: copy-handcrafted-release-gating-jobs.sh + +set -euo pipefail + +if [ $# -ne 3 ]; then + echo "Usage: $0 " + echo "Example: $0 4.21 4.22 /home/prucek/work/release" + exit 1 +fi + +OLD_VERSION="$1" +NEW_VERSION="$2" +RELEASE_REPO="$3" +JOBS_DIR="${RELEASE_REPO}/ci-operator/jobs/openshift/release" +REPOS_DIR="${RELEASE_REPO}/core-services/release-controller/_repos" + +echo "==========================================" +echo "Copying handcrafted release-gating jobs" +echo "Version: ${OLD_VERSION} → ${NEW_VERSION}" +echo "==========================================" +echo "" + +# Check prerequisites +echo "Checking prerequisites..." + +# Check if release-controller repo files exist for new version +REPO_FILES=$(find "${REPOS_DIR}" -type f -name "ocp-${NEW_VERSION}*.repo" 2>/dev/null | wc -l) + +if [ "$REPO_FILES" -eq 0 ]; then + echo "" + echo "ERROR: No ocp-${NEW_VERSION}*.repo files found in ${REPOS_DIR}" + echo "" + echo "You must first execute Step 3 (Release-Controller Configurations):" + echo " 1. Run the 'copy-release-controller-configs' skill" + echo " 2. Ensure core-services/release-controller/_repos/ocp-${NEW_VERSION}*.repo files exist" + echo "" + exit 1 +fi + +echo "✓ Found ${REPO_FILES} ocp-${NEW_VERSION}*.repo file(s)" +echo "" + +# Source and destination file paths +SRC_FILE="${JOBS_DIR}/openshift-release-release-${OLD_VERSION}-periodics.yaml" +DST_FILE="${JOBS_DIR}/openshift-release-release-${NEW_VERSION}-periodics.yaml" + +# Check if source file exists +if [ ! -f "$SRC_FILE" ]; then + echo "ERROR: Source file not found: $SRC_FILE" + exit 1 +fi + +# Check if destination already exists +if [ -f "$DST_FILE" ]; then + echo "WARNING: Destination file already exists: $DST_FILE" + echo "Skipping copy operation." +else + echo "Copying: $(basename "$SRC_FILE") → $(basename "$DST_FILE")" + cp "$SRC_FILE" "$DST_FILE" + echo "✓ File copied successfully" + echo "" +fi + +# Bump ALL version strings inside the file +echo "Bumping all version strings in $(basename "$DST_FILE")..." + +# Extract the major version (e.g., "4" from "4.21") +MAJOR_VERSION="${OLD_VERSION%%.*}" + +# Find all unique version numbers in the file and sort them in descending order +# This ensures we replace from highest to lowest to avoid double-replacement +VERSIONS=$(grep -oE "${MAJOR_VERSION}\.[0-9]+" "$DST_FILE" | sort -t. -k2 -nr | uniq) + +# Bump each version found in the file +for VERSION in $VERSIONS; do + # Extract minor version + MINOR="${VERSION##*.}" + # Calculate new minor version + NEW_MINOR=$((MINOR + 1)) + NEW_VER="${MAJOR_VERSION}.${NEW_MINOR}" + + # Escape dots for sed + VERSION_ESCAPED="${VERSION//./\\.}" + + echo " Bumping ${VERSION} → ${NEW_VER}" + sed -i "s/${VERSION_ESCAPED}/${NEW_VER}/g" "$DST_FILE" +done + +echo "✓ All version strings updated" +echo "" + +# Run make release-controllers +echo "Running 'make release-controllers'..." +cd "${RELEASE_REPO}" +make release-controllers +echo "✓ Release controllers generated" +echo "" + +# Run make jobs +echo "Running 'make jobs'..." +make jobs +echo "✓ Prow jobs regenerated" +echo "" + +echo "==========================================" +echo "✓ Handcrafted release-gating jobs ready!" +echo "==========================================" diff --git a/.claude/.claude-plugin/skills/copy-release-controller-configs.sh b/.claude/.claude-plugin/skills/copy-release-controller-configs.sh new file mode 100755 index 0000000000..c19507b60c --- /dev/null +++ b/.claude/.claude-plugin/skills/copy-release-controller-configs.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Skill: copy-release-controller-configs +# Description: Copy and update release-controller configurations from old version to new version +# Usage: copy-release-controller-configs.sh + +set -euo pipefail + +if [ $# -ne 3 ]; then + echo "Usage: $0 " + echo "Example: $0 4.21 4.22 /home/prucek/work/release" + exit 1 +fi + +OLD_VERSION="$1" +NEW_VERSION="$2" +RELEASE_REPO="$3" +RELEASES_DIR="${RELEASE_REPO}/core-services/release-controller/_releases" + +echo "Bumping release controller configs: ${OLD_VERSION} → ${NEW_VERSION}" + +# Escape dots for sed patterns +OLD_ESCAPED="${OLD_VERSION//./\\.}" + +# Calculate previous version for nested references +PREV_MINOR=$((${OLD_VERSION##*.} - 1)) +PREV_VERSION="${OLD_VERSION%.*}.${PREV_MINOR}" +PREV_ESCAPED="${PREV_VERSION//./\\.}" +CURR_MINOR=$((${NEW_VERSION##*.} - 1)) +CURR_VERSION="${NEW_VERSION%.*}.${CURR_MINOR}" + +# Find all files with old_version in their name and bump them +find "$RELEASES_DIR" -type f -name "*${OLD_VERSION}*.json" 2>/dev/null | while read -r src_file; do + # Skip if already processed/destination exists + dst_file="${src_file//${OLD_VERSION}/${NEW_VERSION}}" + [ -f "$dst_file" ] && continue + + echo " $(basename "$src_file") → $(basename "$dst_file")" + cp "$src_file" "$dst_file" + + # Bump version strings inside the file + sed -i "s/${OLD_ESCAPED}/${NEW_VERSION}/g" "$dst_file" + sed -i "s/${PREV_ESCAPED}/${CURR_VERSION}/g" "$dst_file" +done + +echo "Done!" diff --git a/.claude/.claude-plugin/skills/create-pre-branching-branch.sh b/.claude/.claude-plugin/skills/create-pre-branching-branch.sh new file mode 100755 index 0000000000..e18d89d15f --- /dev/null +++ b/.claude/.claude-plugin/skills/create-pre-branching-branch.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Skill: create-pre-branching-branch +# Description: Create and checkout pre-branching branch in release repository +# Usage: create-pre-branching-branch.sh + +set -euo pipefail + +if [ $# -ne 3 ]; then + echo "Usage: $0 " + echo "Example: $0 4.21 4.22 /home/prucek/work/release" + exit 1 +fi + +OLD_VERSION="$1" +NEW_VERSION="$2" +RELEASE_REPO="$3" + +echo "==========================================" +echo "Creating Pre-Branching Branch" +echo "==========================================" +echo "" + +cd "${RELEASE_REPO}" + +# Fetch latest changes +echo "Fetching latest changes from origin..." +git fetch origin +git pull origin master + +# Create branch name +BRANCH_NAME="pre-branching-${OLD_VERSION}-to-${NEW_VERSION}" + +# Check if branch already exists +if git show-ref --verify --quiet "refs/heads/${BRANCH_NAME}"; then + echo "" + echo "Branch '${BRANCH_NAME}' already exists locally." + echo "Switching to existing branch..." + git checkout "${BRANCH_NAME}" +else + echo "" + echo "Creating new branch: ${BRANCH_NAME}" + git checkout -b "${BRANCH_NAME}" origin/master +fi + +echo "" +echo "==========================================" +echo "✓ On branch: ${BRANCH_NAME}" +echo "==========================================" diff --git a/.claude/.claude-plugin/skills/create-pre-branching-commits.sh b/.claude/.claude-plugin/skills/create-pre-branching-commits.sh new file mode 100755 index 0000000000..bc99ef6f22 --- /dev/null +++ b/.claude/.claude-plugin/skills/create-pre-branching-commits.sh @@ -0,0 +1,94 @@ +#!/bin/bash +set -euo pipefail + +OLD_VERSION="${1:-}" +NEW_VERSION="${2:-}" +RELEASE_REPO="${3:-}" + +if [ -z "$OLD_VERSION" ] || [ -z "$NEW_VERSION" ] || [ -z "$RELEASE_REPO" ]; then + echo "Usage: $0 " + echo "Example: $0 4.21 4.22 /path/to/release" + exit 1 +fi + +echo "==========================================" +echo "Creating Pre-Branching Commits" +echo "==========================================" +echo "" +echo "Old version: $OLD_VERSION" +echo "New version: $NEW_VERSION" +echo "Release repo: $RELEASE_REPO" +echo "" + +cd "$RELEASE_REPO" + +# Check if there are changes to commit +if git diff --quiet && git diff --cached --quiet && [ -z "$(git ls-files --others --exclude-standard)" ]; then + echo "No changes to commit!" + exit 1 +fi + +echo "=== Commit 1: Bump release gating jobs from Sippy ===" +echo "" + +# Stage only CI operator config changes +git add ci-operator/config/ + +# Check if there are staged changes +if git diff --cached --quiet; then + echo "No CI operator config changes to commit" +else + git commit -m "bump release gating jobs from Sippy + +Generated by: +./generated-release-gating-jobs --current-release=${OLD_VERSION} --release-repo=${RELEASE_REPO} --sippy-config=/tmp/sippy-openshift.yaml --interval=168" + echo "✓ Commit 1 created" +fi + +echo "" +echo "=== Commit 2: Release-controller configurations ===" +echo "" + +# Stage release-controller configuration files +git add core-services/release-controller/_releases/ + +# Check if there are staged changes +if git diff --cached --quiet; then + echo "No release-controller config changes to commit" +else + git commit -m "release-controller ${NEW_VERSION} configuration + +Created new release-controller configurations for ${NEW_VERSION} by copying from ${OLD_VERSION}." + echo "✓ Commit 2 created" +fi + +echo "" +echo "=== Commit 3: Add manual jobs and regenerate ===" +echo "" + +# Stage all Prow job changes +git add ci-operator/jobs/ + +# Check if there are staged changes +if git diff --cached --quiet; then + echo "No Prow job changes to commit" +else + git commit -m "add manual jobs + make jobs + +- Added standalone job definitions for ${NEW_VERSION} (install-analysis, upgrade-analysis, overall-analysis) +- Regenerated Prow jobs with 'make jobs'" + echo "✓ Commit 3 created" +fi + +echo "" +echo "==========================================" +echo "✓ All commits created!" +echo "==========================================" +echo "" +echo "Recent commits:" +git log --oneline -3 +echo "" +echo "Next steps:" +echo "1. Review commits: git log -3 -p" +echo "2. Push to your fork: git push --set-upstream origin " +echo "3. Create a pull request" diff --git a/.claude/.claude-plugin/skills/download-sippy-config.sh b/.claude/.claude-plugin/skills/download-sippy-config.sh new file mode 100755 index 0000000000..e1145cd84b --- /dev/null +++ b/.claude/.claude-plugin/skills/download-sippy-config.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Skill: download-sippy-config +# Description: Download latest Sippy configuration from GitHub +# Usage: download-sippy-config.sh [output_path] + +set -euo pipefail + +OUTPUT_PATH="${1:-/tmp/sippy-openshift.yaml}" + +echo "==========================================" +echo "Downloading Sippy Configuration" +echo "==========================================" +echo "" + +echo "Downloading from: https://raw.githubusercontent.com/openshift/sippy/master/config/openshift.yaml" +echo "Output path: ${OUTPUT_PATH}" + +curl -sSL -o "${OUTPUT_PATH}" https://raw.githubusercontent.com/openshift/sippy/master/config/openshift.yaml + +if [ -f "${OUTPUT_PATH}" ]; then + echo "" + echo "==========================================" + echo "✓ Downloaded successfully to ${OUTPUT_PATH}" + echo "==========================================" +else + echo "" + echo "==========================================" + echo "✗ Download failed!" + echo "==========================================" + exit 1 +fi diff --git a/.claude/.claude-plugin/skills/regenerate-prow-jobs.sh b/.claude/.claude-plugin/skills/regenerate-prow-jobs.sh new file mode 100755 index 0000000000..3b3cd94d62 --- /dev/null +++ b/.claude/.claude-plugin/skills/regenerate-prow-jobs.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Skill: regenerate-prow-jobs +# Description: Regenerate Prow job configurations from CI operator configs +# Usage: regenerate-prow-jobs.sh + +set -euo pipefail + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + echo "Example: $0 /home/prucek/work/release" + exit 1 +fi + +RELEASE_REPO="$1" + +echo "==========================================" +echo "Regenerating Prow Jobs" +echo "==========================================" +echo "" + +cd "${RELEASE_REPO}" + +# Run make jobs +echo "Running 'make jobs'..." +make jobs + +echo "" +echo "==========================================" +echo "✓ Prow jobs regenerated successfully!" +echo "==========================================" diff --git a/.claude/.claude-plugin/skills/update-release-gating-jobs.sh b/.claude/.claude-plugin/skills/update-release-gating-jobs.sh new file mode 100755 index 0000000000..e4620ee19d --- /dev/null +++ b/.claude/.claude-plugin/skills/update-release-gating-jobs.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Skill: update-release-gating-jobs +# Description: Run generated-release-gating-jobs bumper with Sippy config +# Usage: update-release-gating-jobs.sh + +set -euo pipefail + +if [ $# -ne 4 ]; then + echo "Usage: $0 " + echo "Example: $0 4.21 /home/prucek/work/release /home/prucek/work/ci-tools /tmp/sippy-openshift.yaml" + exit 1 +fi + +OLD_VERSION="$1" +RELEASE_REPO="$2" +CI_TOOLS_REPO="$3" +SIPPY_CONFIG="$4" + +echo "==========================================" +echo "Updating Release Gating Jobs for ${OLD_VERSION}" +echo "==========================================" +echo "" + +cd "${CI_TOOLS_REPO}" + +# Build the tool if not already built +echo "Building generated-release-gating-jobs..." +go build ./cmd/branchingconfigmanagers/generated-release-gating-jobs + +# Run the bumper using Sippy config +echo "" +echo "Running generated-release-gating-jobs bumper..." +./generated-release-gating-jobs \ + --current-release="${OLD_VERSION}" \ + --release-repo="${RELEASE_REPO}" \ + --sippy-config="${SIPPY_CONFIG}" \ + --interval=168 + +echo "" +echo "==========================================" +echo "✓ Release gating jobs updated!" +echo "==========================================" diff --git a/.claude/.claude-plugin/skills/validate-release-controller-config.sh b/.claude/.claude-plugin/skills/validate-release-controller-config.sh new file mode 100755 index 0000000000..215f45c825 --- /dev/null +++ b/.claude/.claude-plugin/skills/validate-release-controller-config.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Skill: validate-release-controller-config +# Description: Validate release-controller configurations +# Usage: validate-release-controller-config.sh + +set -euo pipefail + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + echo "Example: $0 /home/prucek/work/release" + exit 1 +fi + +RELEASE_REPO="$1" + +echo "==========================================" +echo "Validating Release Controller Configuration" +echo "==========================================" +echo "" + +cd "${RELEASE_REPO}" + +# Run validation script +echo "Running hack/validate-release-controller-config.sh..." +hack/validate-release-controller-config.sh . + +EXIT_CODE=$? + +echo "" +if [ $EXIT_CODE -eq 0 ]; then + echo "==========================================" + echo "✓ Validation passed!" + echo "==========================================" +else + echo "==========================================" + echo "⚠ Validation failed - manual job copying may be required" + echo "==========================================" +fi + +exit $EXIT_CODE diff --git a/.claude/commands/pre-branching.md b/.claude/commands/pre-branching.md new file mode 100644 index 0000000000..533d7ef0ee --- /dev/null +++ b/.claude/commands/pre-branching.md @@ -0,0 +1,185 @@ +# OpenShift Pre-Branching Automation + +You are executing the pre-branching tasks for OpenShift release {{VERSION}}. + +## Task Overview + +Execute the following steps in order: + +### 1. Update Release Repository and Create Branch + +**Use the `create-pre-branching-branch` skill:** + +```bash +.claude/.claude-plugin/skills/create-pre-branching-branch.sh {{OLD_VERSION}} {{NEW_VERSION}} {{RELEASE_REPO}} +``` + +This creates a branch named like `pre-branching-4.21-to-4.22` for your pre-branching changes. + +### 2. Download Latest Sippy Config + +**Use the `download-sippy-config` skill:** + +```bash +.claude/.claude-plugin/skills/download-sippy-config.sh /tmp/sippy-openshift.yaml +``` + +### 3. Release-Controller Configurations + +**Use the `copy-release-controller-configs` skill:** + +```bash +.claude/.claude-plugin/skills/copy-release-controller-configs.sh {{OLD_VERSION}} {{NEW_VERSION}} {{RELEASE_REPO}} +``` + +This will copy and update release-controller configurations from {{OLD_VERSION}} to {{NEW_VERSION}}. + +### 4. Update Generated Release Gating Jobs + +**Use the `update-release-gating-jobs` skill:** + +```bash +.claude/.claude-plugin/skills/update-release-gating-jobs.sh {{OLD_VERSION}} {{RELEASE_REPO}} {{CI_TOOLS_REPO}} /tmp/sippy-openshift.yaml +``` + +This tool will: +- Read Sippy config to get informing and blocking jobs for {{OLD_VERSION}} +- Process related releases (e.g., "{{OLD_VERSION}}", "{{OLD_VERSION}}-okd") +- Map job names to CI operator config files via Prow job metadata +- Bump configs from {{OLD_VERSION}} to {{NEW_VERSION}} +- Update filenames, content, and zz_generated_metadata + +Expected output: +- Processes ~400+ jobs from Sippy +- Maps to ~20-25 unique config files +- Creates new {{NEW_VERSION}} config files +- Updates branch references in metadata + +### 5. Copy Handcrafted Release-Gating Jobs + +**Use the `copy-handcrafted-release-gating-jobs` skill:** + +```bash +.claude/.claude-plugin/skills/copy-handcrafted-release-gating-jobs.sh {{OLD_VERSION}} {{NEW_VERSION}} {{RELEASE_REPO}} +``` + +**Prerequisites:** +- Step 3 (Release-Controller Configurations) must be completed +- The `core-services/release-controller/_repos/ocp-{{NEW_VERSION}}*.repo` files must exist + +This will: +- Check that required `.repo` files exist for {{NEW_VERSION}} +- Copy `ci-operator/jobs/openshift/release/openshift-release-release-{{OLD_VERSION}}-periodics.yaml` to {{NEW_VERSION}} +- Bump ALL version strings in the file (handles chains like `4.19-to-4.20-to-4.21` → `4.20-to-4.21-to-4.22`) +- Run `make release-controllers` to generate release controller configurations +- Run `make jobs` to regenerate Prow job configurations + +**Note:** This step is required even though these are handcrafted jobs, as one of the generators checks for the presence of this file. + +### 6. Regenerate Prow Jobs + +**Use the `regenerate-prow-jobs` skill:** + +```bash +.claude/.claude-plugin/skills/regenerate-prow-jobs.sh {{RELEASE_REPO}} +``` + +This will: +- Read all CI operator config files (including new {{NEW_VERSION}} configs) +- Generate corresponding Prow job YAML files +- Create/update periodic job definitions for {{NEW_VERSION}} +- Update job configurations in `ci-operator/jobs/` + +Expected output: +- New Prow job files for {{NEW_VERSION}} release configs +- Updated job definitions matching the CI operator configs + +### 7. Validate Release Controller Configurations + +**Use the `validate-release-controller-config` skill:** + +```bash +.claude/.claude-plugin/skills/validate-release-controller-config.sh {{RELEASE_REPO}} +``` + +This will validate that all jobs referenced in the release-controller configurations exist. + +**If you see errors**, these are standalone Prow job definitions (analysis jobs) that need to be copied: + +**Use the `bump-analysis-jobs` skill to fix validation errors:** + +```bash +.claude/.claude-plugin/skills/bump-analysis-jobs.sh {{OLD_VERSION}} {{NEW_VERSION}} {{RELEASE_REPO}} +``` + +This will automatically: +- Extract install/upgrade/overall analysis jobs for {{OLD_VERSION}} +- Create {{NEW_VERSION}} versions of these jobs +- Append them to the appropriate Prow job files + +**After bumping analysis jobs, regenerate Prow jobs:** + +```bash +.claude/.claude-plugin/skills/regenerate-prow-jobs.sh {{RELEASE_REPO}} +``` + +**Then re-run validation to confirm all jobs exist:** + +```bash +.claude/.claude-plugin/skills/validate-release-controller-config.sh {{RELEASE_REPO}} +``` + +### 8. Create Commits + +**Use the `create-pre-branching-commits` skill:** + +```bash +.claude/.claude-plugin/skills/create-pre-branching-commits.sh {{OLD_VERSION}} {{NEW_VERSION}} {{RELEASE_REPO}} +``` + +This will automatically create three commits: +- **Commit 1**: CI operator configs (bump release gating jobs from Sippy) +- **Commit 2**: Release-controller configurations +- **Commit 3**: Prow jobs (add manual jobs + make jobs) + +**Review and push:** +```bash +cd {{RELEASE_REPO}} +git log -3 +git push --set-upstream origin pre-branching-{{OLD_VERSION}}-to-{{NEW_VERSION}} +``` + +### 9. Summary Report + +Provide a summary including: + +1. **Files created:** + - Release-controller configurations (14 files) + - CI operator configs (~22 files) + - Prow job files (~4 new files + 8 modified) + +2. **Jobs processed:** + - Number of Sippy jobs processed + - Number of analysis jobs added + +3. **Validation:** + - Confirm all validations passed + +4. **Next steps:** + - Review commits and create pull request + - Continue with additional branching tasks per BRANCHING.md + +## Important Notes + +- All changes are made in the release repository only +- Sippy config is downloaded fresh from GitHub +- The `create-pre-branching-commits` skill handles all git operations +- Always review commits before pushing + +## Variable Substitutions + +- `{{VERSION}}` - The version provided by user (e.g., "4.22") +- `{{OLD_VERSION}}` - Previous version (e.g., "4.21") +- `{{NEW_VERSION}}` - Next version (e.g., "4.22") +- `{{RELEASE_REPO}}` - Path to release repository +- `{{CI_TOOLS_REPO}}` - Path to ci-tools repository