Skip to content

add deploy-test beforeSuite && pre-setting parameters in options.yaml#472

Closed
MMMsc wants to merge 1 commit into
stolostron:mainfrom
MMMsc:feature-e2e-deploy
Closed

add deploy-test beforeSuite && pre-setting parameters in options.yaml#472
MMMsc wants to merge 1 commit into
stolostron:mainfrom
MMMsc:feature-e2e-deploy

Conversation

@MMMsc
Copy link
Copy Markdown
Contributor

@MMMsc MMMsc commented Jun 7, 2023

No description provided.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 7, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: MMMsc
Once this PR has been reviewed and has the lgtm label, please assign yanmxa for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 7, 2023

@MMMsc: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/test-unit 566d4d5 link true /test test-unit

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@MMMsc MMMsc closed this Jun 7, 2023
@MMMsc MMMsc deleted the feature-e2e-deploy branch June 7, 2023 05:12
yanmxa added a commit to yanmxa/hub-of-hubs that referenced this pull request Nov 18, 2025
Critical fix for bundle PRs stolostron#470, stolostron#471, stolostron#472 and similar issues.

Root cause: Bundle was being modified after copying from multicluster-global-hub:
- createdAt preservation attempted to restore old timestamps
- This caused unwanted diffs even when bundle content was correct
- ANY modification to bundle breaks alignment with source repo

These modifications corrupted the bundle sync process, causing:
- PR stolostron#470: Only createdAt timestamp changed
- PR stolostron#471: Correct values (1.7, 2.16) changed back to old (1.6, 2.15)
- PR stolostron#472: Same regression despite previous "fix"

Solution: Bundle is now copied AS-IS with ZERO modifications.
multicluster-global-hub/operator/bundle is the single source of truth.

Changes:
- Removed createdAt preservation logic completely
- Removed backup/restore logic
- Bundle content copied directly without any modifications
- Step 4 already updated to verify only (no modifications)
- Step 4.5 already updated to verify only (no modifications)

This ensures bundle repo stays perfectly aligned with main repo.

Signed-off-by: myan <myan@redhat.com>
yanmxa added a commit to yanmxa/hub-of-hubs that referenced this pull request Nov 19, 2025
Critical fix for bundle PRs stolostron#470, stolostron#471, stolostron#472 and similar issues.

Root cause: Bundle was being modified after copying from multicluster-global-hub:
- createdAt preservation attempted to restore old timestamps
- This caused unwanted diffs even when bundle content was correct
- ANY modification to bundle breaks alignment with source repo

These modifications corrupted the bundle sync process, causing:
- PR stolostron#470: Only createdAt timestamp changed
- PR stolostron#471: Correct values (1.7, 2.16) changed back to old (1.6, 2.15)
- PR stolostron#472: Same regression despite previous "fix"

Solution: Bundle is now copied AS-IS with ZERO modifications.
multicluster-global-hub/operator/bundle is the single source of truth.

Changes:
- Removed createdAt preservation logic completely
- Removed backup/restore logic
- Bundle content copied directly without any modifications
- Step 4 already updated to verify only (no modifications)
- Step 4.5 already updated to verify only (no modifications)

This ensures bundle repo stays perfectly aligned with main repo.

Signed-off-by: myan <myan@redhat.com>
openshift-merge-bot Bot pushed a commit that referenced this pull request Nov 20, 2025
* docs: add CLAUDE.md configuration file for Claude Code

Add comprehensive CLAUDE.md documentation to guide Claude Code instances
when working with the multicluster-global-hub codebase.

The file includes:
- Architecture overview of operator, manager, and agent components
- Component responsibilities and package structure
- Build and deployment commands
- Testing workflows (unit, integration, E2E)
- Code formatting rules and dependency constraints
- Key dependencies and environment variables

This will help future Claude Code instances quickly understand the
codebase structure and be productive with common development tasks.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* commit skill

Signed-off-by: Meng Yan <myan@redhat.com>

* feat: enhance globalhub-release skill with container validation and cross-platform support

- Add Docker/Podman availability verification before make update
- Add clear error messages when container engine is not available
- Add cross-platform sed syntax support (macOS and Linux)
- Remove container engine installation/initialization from script
- Update documentation with platform compatibility notes
- Improve error handling and user guidance

The skill now validates container engines upfront and provides clear
guidance without attempting automatic installation. The script automatically
detects the OS and uses appropriate sed syntax for both macOS and Linux.

Signed-off-by: Meng Yan <myan@redhat.com>

* fix: quote shell variables to resolve SonarCloud warnings

Fixed shellcheck issues in create-release.sh script:
- Quote all variable expansions to prevent word splitting
- Quote command substitutions properly
- Quote git refs and branch names
- Quote GitHub URLs in gh commands

This resolves the 5 SonarCloud issues reported in PR #2082.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* shell

Signed-off-by: Meng Yan <myan@redhat.com>

* update

Signed-off-by: Meng Yan <myan@redhat.com>

* fix global hub

Signed-off-by: myan <myan@redhat.com>

* fix claude 01

Signed-off-by: myan <myan@redhat.com>

* update bundle

Signed-off-by: myan <myan@redhat.com>

* update bundle

Signed-off-by: myan <myan@redhat.com>

* update catalog

Signed-off-by: myan <myan@redhat.com>

* update obs and postgres

Signed-off-by: myan <myan@redhat.com>

* Fix shellcheck issues in cut-release scripts

Fixed 18 shellcheck warnings and style issues:
- SC2001: Use parameter expansion instead of sed for simple substitutions
- SC2034: Remove unused variables or mark them as intentionally unused
- SC2035: Use -- or ./* to prevent glob patterns from being interpreted as options
- SC2086: Add proper quoting to prevent word splitting
- SC2155: Declare and assign variables separately to avoid masking return values

All scripts now pass shellcheck validation without errors or warnings.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* refactor: replace single brackets with double brackets in shell scripts

Improved shell script quality by converting [ ] to [[ ]] for all
conditional tests in the cut-release scripts, following shellcheck
SC2292 recommendations.

Changes:
- Converted all simple conditional tests from [ ] to [[ ]]
- Merged multi-condition tests (with || and &&) into single [[ ]] blocks
- Ensures safer and more feature-rich conditional expressions

Benefits:
- [[ ]] is safer and handles word splitting/globbing better
- No need to quote variables in most cases within [[ ]]
- More consistent with modern bash best practices
- Reduces potential for subtle bugs in conditional logic

All scripts have been validated with bash -n and pass syntax checks.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* refactor: complete shell script quality improvements

This commit addresses all remaining SonarCloud issues in the
cut-release scripts, improving code quality and following bash
best practices.

Changes:
1. Converted ALL remaining [ ] to [[ ]] (~200+ instances)
   - Simple conditions: if [ x ]; then → if [[ x ]]; then
   - Combined conditions: [ x ] && [ y ] → [[ x && y ]]
   - More robust and safer conditional testing

2. Redirected all error messages to stderr (~30 instances)
   - All echo statements with ❌ or "Error:" now use >&2
   - Proper error stream handling for better script composability

Benefits:
- [[ ]] handles edge cases better (no word splitting/globbing)
- Error messages properly separated from normal output
- Follows ShellCheck SC2292 recommendations
- Improves script reliability and maintainability

Total changes: ~458 line modifications across 7 scripts
All scripts verified with bash -n syntax checking

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* fix: remove duplicate stderr redirection (>&2 >&2 -> >&2)

Fixed 16 instances where >&2 was duplicated due to multiple sed passes.
All error messages now correctly redirect to stderr with single >&2.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* Fix SonarCloud issues in cut-release scripts

This commit addresses remaining SonarCloud code quality issues:

1. Convert [ to [[ in command substitution contexts (5 instances)
   - Safer conditional test syntax in $() expressions
   - Files: 01-multicluster-global-hub.sh, 03-bundle.sh, 04-catalog.sh,
     06-postgres-exporter.sh, cut-release.sh

2. Define constants for repeated string literals
   - TARGET_BRANCH_PATTERN='target_branch =='
   - TARGET_BRANCH_EXTRACT_PATTERN (sed extraction pattern)
   - NULL_PR_VALUE='null|null'
   - SEPARATOR_LINE='================================================'
   - Reduces magic strings and improves maintainability

3. Redirect warning messages to stderr
   - All ⚠️ warning messages now use >&2
   - Proper separation of informational vs error output

4. Add explicit return statements to functions
   - get_repo_info() and show_repos() now have explicit return 0
   - Improves code clarity and error handling

5. Remove unused local variables
   - Replaced unused 'script' variable with '_' in show_repos()

All scripts pass bash -n syntax validation.

Related: PR #2082
SonarCloud: https://sonarcloud.io/project/issues?id=open-cluster-management_hub-of-hubs&pullRequest=2082
Signed-off-by: Meng Yan <myan@redhat.com>

* Remove unused constants from 01-multicluster-global-hub.sh

- Remove unused TARGET_BRANCH_PATTERN constant
- Remove unused TARGET_BRANCH_EXTRACT_PATTERN constant
- Fix grep pattern that was incorrectly replaced ('""' -> 'target_branch ==')

These constants were defined but never used in the script.
ShellCheck SC2034 warnings are now resolved.

Signed-off-by: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* Define constants for repeated target_branch patterns

- Add TARGET_BRANCH_GREP_PATTERN='target_branch ==' constant
- Add TARGET_BRANCH_EXTRACT_SED='s/.*target_branch == "([^"]+)".*/\1/' constant
- Replace 4 occurrences of 'target_branch ==' literal with constant
- Replace 4 occurrences of sed extraction pattern with constant

This improves code maintainability and resolves SonarCloud warnings
about repeated string literals.

Signed-off-by: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* refactor: rename CUT_MODE to CREATE_BRANCHES for better clarity

Replace CUT_MODE variable with CREATE_BRANCHES throughout the cut-release skill:
- Updated SKILL.md and README.md documentation
- Modified cut-release.sh orchestration script
- Updated all individual release scripts (01-06)

The new name CREATE_BRANCHES more clearly indicates the variable's purpose:
creating new release branches vs updating existing ones via PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Meng Yan <myan@redhat.com>

* correct prow

Signed-off-by: myan <myan@redhat.com>

* feat: add comprehensive PR status tracking for all release scripts

Enhance catalog, grafana, and postgres-exporter scripts with detailed
PR status tracking (created/updated/exists/skipped/pushed) similar to
the main branch PR tracking in catalog script.

Changes:
- Replace old PR_CREATED/PR_URL variables with status-based tracking
- Use fixed branch names for PR deduplication (avoid timestamp suffixes)
- Search PRs by title instead of branch name to catch existing PRs
- Distinguish between "exists" (PR exists, no changes) and "updated"
  (PR exists and was updated with new changes)
- Display status for ALL PRs in summary (main, catalog, cleanup)
- Use case statements for clearer status-based output

This ensures users get clear visibility into PR status across all
repositories and prevents duplicate PR creation.

Signed-off-by: myan <myan@redhat.com>

* fix: correct tekton pipeline version replacements in catalog script

Fix sed replacements to properly update all version references in
tekton pipeline YAML files when creating or updating catalog releases.

Changes:
- Add explicit replacement for catalog-4XX- pattern (e.g., catalog-420-
  -> catalog-421-) which appears in labels and application names
- Remove buggy composite replacement that used PREV_OCP_MAX%100 without
  the '4' prefix (would replace catalog-20- instead of catalog-420-)
- Add clear comments explaining each replacement step

This ensures all fields are correctly updated:
1. on-cel-expression: target_branch, v4.XX/ paths, .tekton file names
2. labels: appstudio.openshift.io/application, component, name
3. spec params: output-image, dockerfile, opm-output-path, konflux-application-name
4. taskRunTemplate: serviceAccountName

Example: When updating from release-1.6 (OCP 4.16-4.20) to release-1.7
(OCP 4.17-4.21), properly updates:
- v420 -> v421, v416 -> v416 (unchanged)
- catalog-420-globalhub-1-6 -> catalog-421-globalhub-1-7
- catalog-416-globalhub-1-6 -> catalog-416-globalhub-1-7
- release-1.6 -> release-1.7

Signed-off-by: myan <myan@redhat.com>

* fix: enable automatic PR updates and fix version replacements

1. Fix tekton pipeline version replacements in catalog script:
   - Add sed replacement for dotted version format (v4.20 -> v4.21)
   - Ensures all version references are updated in on-cel-expression,
     dockerfile paths, and opm-output-path parameters

2. Enable automatic PR updates for existing PRs:
   - Detect existing PR's actual branch name from GitHub
   - Force push updates directly to existing PR branch
   - Works even when branch names differ (e.g., old timestamp branches)
   - Applied to all PR types: main branch, catalog branch, cleanup

This allows scripts to automatically update existing PRs instead of
requiring manual intervention or PR closure/recreation.

Changes applied to:
- 04-catalog.sh: tekton pipeline fixes + PR update logic
- 05-grafana.sh: PR update logic
- 06-postgres-exporter.sh: PR update logic

Signed-off-by: myan <myan@redhat.com>

* feat: add Containerfile.catalog management in catalog script

Add automatic management of Containerfile.catalog files when OCP
version range changes:

1. Remove old OCP version directory (e.g., v4.16/)
   - Deletes entire directory including Containerfile.catalog

2. Create new OCP version Containerfile (e.g., v4.21/)
   - Copies from previous version (v4.20)
   - Updates bundle reference: globalhub-1-6 -> globalhub-1-7
   - Updates configs path: configs/v4.20/ -> configs/v4.21/
   - Updates base image tag: ose-operator-registry-rhel9:v4.20 -> v4.21

3. Update commit message and summary
   - Show Containerfile additions/removals in commit message
   - Display in workflow summary

This ensures Containerfile.catalog files are properly maintained
alongside tekton pipelines when OCP version range changes.

Signed-off-by: myan <myan@redhat.com>

* fix: correctly update both FROM instructions in Containerfile.catalog

Containerfile.catalog has two FROM instructions:
- First FROM (builder stage): uses previous OCP version (N-1)
- Second FROM (runtime): uses current OCP version (N)

When creating new version (e.g., v4.21 from v4.20):
- Builder FROM: v4.19 -> v4.20
- Runtime FROM: v4.20 -> v4.21

Fixed sed replacements to update both base images correctly:
1. Update builder base image first (N-2 -> N-1)
2. Then update runtime base image (N-1 -> N)

This ensures both stages use the correct registry image versions.

Signed-off-by: myan <myan@redhat.com>

* fix: do not update builder stage OCP version in Containerfile.catalog

The builder stage FROM instruction should keep the version from the
previous Containerfile (not updated). Only the runtime stage FROM
instruction needs to be updated to the new OCP version.

Example: When creating v4.21 from v4.20:
- Builder FROM: v4.19 (unchanged)
- Runtime FROM: v4.20 -> v4.21 (updated)

Signed-off-by: myan <myan@redhat.com>

* feat: add catalog-template-current.json update logic

Update catalog-template-current.json with new release information:
- defaultChannel: update to new release branch
- operator version: update to new Global Hub version
- skipRange: update to new version range
- channel name: update to new release branch
- bundle image: update to new catalog tag

Signed-off-by: myan <myan@redhat.com>

* release update

Signed-off-by: Meng Yan <myan@redhat.com>

* refactor: optimize script 01 for release workflow

Implement two key optimizations for script 01:

1. Remove previous release pipeline files
   - After creating new tekton files, automatically remove previous
     version's pipeline files to keep .tekton/ directory clean
   - Removes files like multicluster-global-hub-*-globalhub-1-6-*.yaml

2. Conditional bundle generation
   - Only run 'make generate && make fmt && make bundle' when
     operator/Makefile or CSV file is actually updated
   - Track changes via MAKEFILE_UPDATED and CSV_UPDATED flags
   - Skip bundle generation when no configuration changes detected
   - Reduces unnecessary processing time on re-runs

These optimizations improve script efficiency and repository cleanliness.

Signed-off-by: myan <myan@redhat.com>

* update

Signed-off-by: myan <myan@redhat.com>

* feat: add GitHub workflow bundle branch update in script 01

When creating a PR to the main branch, script 01 now also updates
.github/workflows/go.yml to reference the new bundle branch.

Changes:
- Add new Step 5.5: Update GitHub workflow files
  - Updates bundle branch from previous version (e.g., release-1.6)
    to current version (e.g., release-1.7)
  - Handles edge cases like unexpected versions
  - Provides clear status messages

- Update subsequent step numbers (5.5→5.6, 5.6→5.7, 5.7→5.8)

- Update commit message and PR description
  - Include workflow update in git commit message
  - Add workflow update to PR body
  - Stage .github/workflows/ directory

Example:
For ACM release-2.17 (Global Hub 1.7), the workflow will update:
  git clone ... -b release-1.6
→ git clone ... -b release-1.7

This ensures CI/CD workflows use the correct bundle version for
the new release.

Signed-off-by: myan <myan@redhat.com>

* feat: update ACM version in CSV documentation URL

Enhance Step 5.7 to also update ACM version reference in CSV file
documentation URL when creating PR to main branch.

Changes:
- Update CSV file ACM version in documentation URL
  - Example: red_hat_advanced_cluster_management_for_kubernetes/2.15
         → red_hat_advanced_cluster_management_for_kubernetes/2.16

- Calculate previous ACM version from current release
  - Uses CURRENT_ACM_MAJOR and PREV_ACM_MINOR already calculated
    in Step 2
  - PREV_ACM_VERSION = "${CURRENT_ACM_MAJOR}.${PREV_ACM_MINOR}"

- Handle edge cases:
  - Detect if already at current version
  - Detect unexpected versions and update anyway
  - Provide clear status messages

- Update Step 5.7 title and commit/PR descriptions
  - "Update CSV skipRange and ACM version"
  - Include ACM version update in commit message and PR body

Example:
For release-2.16:
- Previous ACM: 2.15
- Current ACM: 2.16
- Updates documentation URL to point to ACM 2.16 docs

This ensures the CSV references the correct ACM documentation
version for each release.

Signed-off-by: myan <myan@redhat.com>

* feat: update CSV maturity and renovate.json baseBranches in script 01

Add two important updates to script 01 when creating PR to main:

1. Update CSV maturity field (Step 5.8)
   - Update maturity from previous to current Global Hub version
   - Example: maturity: release-1.6 → release-1.7
   - Handles edge cases (unexpected versions, already current)
   - Part of CSV file updates

2. Update renovate.json baseBranches (New Step 5.6)
   - Maintain main branch plus last 3 release branches
   - Example for release-2.16:
     ["main", "release-2.14", "release-2.13", "release-2.12"]
     → ["main", "release-2.15", "release-2.14", "release-2.13"]
   - Automatically calculates:
     * PREV_RELEASE_BRANCH (previous release)
     * PREV_MINUS_1_BRANCH (previous - 1)
     * PREV_MINUS_2_BRANCH (previous - 2)
   - Removes oldest release branch, adds newest previous release

Changes:
- Add Step 5.6: Update renovate.json baseBranches
- Update Step 5.7 → 5.7 (Makefile)
- Update Step 5.7 → 5.8 (CSV - now includes maturity)
- Update Step 5.8 → 5.9 (Generate bundle)
- Add maturity field update logic in CSV step
- Stage renovate.json in git commit
- Update commit message and PR description with both updates

This ensures renovate bot monitors the correct release branches
and CSV maturity field reflects the current Global Hub version.

Signed-off-by: myan <myan@redhat.com>

* feat: update all Containerfile.catalog files with new bundle reference

When updating the catalog for a new release, the script now updates
ALL OCP versions' Containerfile.catalog files with the new bundle
reference, not just the newly created OCP version.

Changes:
- Add loop to update all existing OCP versions' Containerfile.catalog
  - Iterate through all OCP versions in range (OCP_MIN to OCP_MAX)
  - Check if file contains previous catalog tag
  - Replace bundle reference: globalhub-1-6 → globalhub-1-7
  - Example: multicluster-global-hub-operator-bundle-globalhub-1-6
         → multicluster-global-hub-operator-bundle-globalhub-1-7

- Update commit message to mention Containerfile.catalog updates
- Update PR description to include bundle reference update

Example for release-2.16 (Global Hub 1.7):
- Updates v4.17/Containerfile.catalog
- Updates v4.18/Containerfile.catalog
- Updates v4.19/Containerfile.catalog
- Updates v4.20/Containerfile.catalog
- Updates v4.21/Containerfile.catalog (newly created)

All files now reference globalhub-1-7 instead of globalhub-1-6.

This ensures all Containerfile.catalog files reference the correct
bundle version for the current release.

Signed-off-by: myan <myan@redhat.com>

* docs: add concise release update checklist to README

Add a comprehensive but concise checklist documenting all files
updated during a release across all 6 repositories.

Features:
- Quick Summary table with key info for all repos
- Detailed file changes in collapsible sections
- Example using release-2.17 (Global Hub 1.8)
- Clear indication of Created/Removed/Updated files

This helps developers:
- Understand what changes during a release
- Verify all necessary files are updated
- Review PR changes more effectively

Signed-off-by: myan <myan@redhat.com>

* refactor: rename skill from cut-release to new-release

Rename the skill to better reflect its purpose of creating new releases.

Changes:
- Rename directory: .claude/skills/cut-release → .claude/skills/new-release
- Update skill name in SKILL.md: cut-release → new-release
- Update title in SKILL.md: Global Hub New Release Workflow
- Update title in README.md: Global Hub New Release Workflow

The skill functionality remains unchanged, only the naming is updated
for better clarity and consistency.

Signed-off-by: myan <myan@redhat.com>

* improve: optimize release scripts to avoid unnecessary changes

- bundle: preserve createdAt timestamps to avoid timestamp-only PRs
- openshift/release: skip make update when config has no substantive changes
- reduce unnecessary PR creation and CI runs

Related improvements requested for release-2.16 workflow

Signed-off-by: myan <myan@redhat.com>

* improve: only show PR review info when actual PRs are created

- Capture PR URLs from script output instead of using generic /pulls links
- Only display review checklist for repos with actual PRs created
- Show 'No PRs created' message when repos are already up to date
- Adjust step numbering dynamically based on whether PRs exist

This avoids confusing output like showing generic PR list URLs when
no PRs were actually created or updated.

Signed-off-by: myan <myan@redhat.com>

* fix: improve PR URL extraction to avoid wrong repo PRs

The previous logic would extract any PR URL from script output, which
caused issues when a script (like bundle) references PRs from other
repos (like multicluster-global-hub).

New strategy:
1. Extract from NEXT STEPS section (most reliable)
2. Extract from COMPLETED TASKS section
3. Fallback: use last PR creation/update message (not first)

This ensures we capture the PR actually created by each script, not
PRs mentioned in the output for context.

Signed-off-by: myan <myan@redhat.com>

* fix: skip PR creation when branch is identical to upstream/main

Before pushing and creating/updating PR, now check if the PR branch
has any actual differences compared to upstream/main.

If git diff shows no changes:
- Skip push operation
- Skip PR creation/update
- Set MAIN_PR_CREATED=false
- Output: 'No changes to push - branch is up to date with main'

This prevents creating/updating PRs when the content is already
identical to the target branch (e.g., PR #2112 when main already
has the same content).

Signed-off-by: myan <myan@redhat.com>

* fix: correctly preserve createdAt timestamp in bundle CSV

Previous implementation had bugs:
1. Extracted entire line including spaces instead of just timestamp value
2. sed replacement pattern was too complex and didn't work correctly

New implementation:
1. Extract only timestamp value: sed -E 's/.*createdAt: "(.*)".*/\1/'
2. Simple sed replacement: s|createdAt: "[^"]*"|createdAt: "$timestamp"|

This preserves indentation and format while replacing only the timestamp
value, avoiding PRs with only createdAt changes (like PR #470).

Test result: createdAt: "2025-11-18..." → createdAt: "2025-11-13..."

Signed-off-by: myan <myan@redhat.com>

* fix: always create PR branch from latest upstream/main

Root cause of PR #2113 issue:
- PR branch was created from outdated upstream/main reference
- Script didn't fetch upstream/main before creating PR branch
- If PR branch already existed remotely, script would base on old PR branch

Fixes:
1. Fetch upstream/main in Step 3 before any operations
2. Always create PR branch from latest upstream/main (not from old PR branch)
3. Remove duplicate fetch in diff check (already fetched in Step 3)

Flow:
- Step 3: Fetch latest upstream/main → Reset local main → Create PR branch
- Steps 4-6: Make changes and commit
- Step 8: Check diff with upstream/main (ref already fresh from Step 3)
- If diff exists: push and create PR
- If identical: skip (no PR needed)

This prevents creating PRs when main already has the changes.

Signed-off-by: myan <myan@redhat.com>

* fix: prevent bundle PR when content is already correct

Root cause of PR #470 and #471:
- Bundle was copied from multicluster-global-hub (correct source)
- Step 4 did version replacement (1.6→1.7) which corrupted content:
  * Changed ACM doc version incorrectly
  * Changed channel incorrectly
- No diff check before creating PR

Fixes:
1. Step 4: Remove version replacement logic
   - Bundle from multicluster-global-hub already has correct version
   - Just verify, don't modify

2. Step 4.5: Remove skipRange replacement
   - skipRange from source is already correct
   - Just verify, don't modify

3. Step 6: Add diff check before commit
   - Compare with origin/$BUNDLE_BRANCH
   - Skip if no changes (branch already up to date)

Result:
- When bundle repo is aligned with multicluster-global-hub: no PR
- Only create PR when there are real changes needed
- Prevents PRs like #470 (timestamp only) and #471 (wrong changes)

Signed-off-by: myan <myan@redhat.com>

* fix: copy bundle AS-IS without any modifications

Critical fix for bundle PRs #470, #471, #472 and similar issues.

Root cause: Bundle was being modified after copying from multicluster-global-hub:
- createdAt preservation attempted to restore old timestamps
- This caused unwanted diffs even when bundle content was correct
- ANY modification to bundle breaks alignment with source repo

These modifications corrupted the bundle sync process, causing:
- PR #470: Only createdAt timestamp changed
- PR #471: Correct values (1.7, 2.16) changed back to old (1.6, 2.15)
- PR #472: Same regression despite previous "fix"

Solution: Bundle is now copied AS-IS with ZERO modifications.
multicluster-global-hub/operator/bundle is the single source of truth.

Changes:
- Removed createdAt preservation logic completely
- Removed backup/restore logic
- Bundle content copied directly without any modifications
- Step 4 already updated to verify only (no modifications)
- Step 4.5 already updated to verify only (no modifications)

This ensures bundle repo stays perfectly aligned with main repo.

Signed-off-by: myan <myan@redhat.com>

* fix: use exact title match for PR search in bundle script

Critical fix for bundle source detection issue.

Problem: The bundle script was using gh pr list --search which matches
PR content broadly, not just titles. This caused it to find unrelated
PRs (like PR #2082 CLAUDE.md documentation) instead of the actual
release PR (PR #2086).

This led to copying bundle from wrong source branch, creating PRs
with incorrect changes (1.7 -> 1.6 regression in PR #473).

Solution: Filter PRs by exact title match using jq instead of relying
on --search parameter. Use startswith() to match PR titles precisely.

Changes:
- Add title to JSON fields fetched from gh pr list
- Use jq filter: select(.title | startswith("Add release-X.XX "))
- Remove --search parameter (unreliable)
- Added comment explaining the fix

This ensures the script only matches PRs with exact title pattern like:
"Add release-2.16 pipeline configurations"
"Add release-2.16 tekton pipelines and update configurations"

And ignores unrelated PRs that might mention the release in their content.

Signed-off-by: myan <myan@redhat.com>

* fix: always use main branch as bundle source

Simplify bundle source logic to avoid PR search issues.

Problem: Previous attempts to find release PR using gh pr list were
unreliable due to:
1. --search parameter matches PR content broadly, not just titles
2. jq filter with shell variable substitution has quoting issues
3. Release PRs are typically already merged to main by the time
   bundle script runs

Solution: Since release PR #2086 is already MERGED to main, always
use main branch as the bundle source. This is the correct approach
because:
- Main branch has the latest merged release configurations
- No complex PR search logic needed
- Avoids false positives from unrelated PRs
- Simpler and more reliable

The PR search logic was causing the script to find wrong PRs
(#2082, #2107) and copy bundle from incorrect sources, resulting
in wrong PRs (#473, #474) that changed 1.7 -> 1.6 (regression).

This fix ensures bundle is always copied from the authoritative
main branch with correct release configurations.

Signed-off-by: myan <myan@redhat.com>

* fix: fetch bundle from upstream/main instead of origin/main

CRITICAL FIX for bundle source issue.

Root cause of PRs #473, #474, #475 having wrong changes (1.7->1.6):
The script was fetching from origin/main (user's fork) instead of
upstream/main (stolostron repository).

User forks are often outdated and don't have the latest release changes.
Script 01 sets up remotes as:
- origin = user's fork (yanmxa/hub-of-hubs)
- upstream = stolostron repository

Script 03 was incorrectly using origin/main, which had outdated bundle
with 1.6 content. The correct release-2.16 bundle with 1.7 content is
in upstream/main (PR #2086 merged).

Changes:
- Change git fetch from 'origin main' to 'upstream main'
- Change git checkout from 'origin/main' to 'upstream/main'
- Update description to clarify using 'upstream/main branch'
- Added comment explaining the fix

This ensures the bundle is always copied from the authoritative
stolostron repository with the latest merged release configurations.

Signed-off-by: myan <myan@redhat.com>

* fix: ignore createdAt timestamp-only changes in bundle

Add logic to detect and skip createdAt-only changes.

Problem: Bundle script was creating PRs when only the createdAt
timestamp changed (e.g., PR #476 with only timestamp update).
These PRs should not be created as createdAt changes are not
meaningful.

Solution: Before committing changes, check if the only diff is in
createdAt lines. If so, reset to origin branch and skip commit/PR.

Implementation:
1. Get diff output comparing staged changes with origin branch
2. Filter diff to only lines with +/- changes
3. Exclude createdAt lines and diff markers (---, +++)
4. If no other changes remain, it's createdAt-only
5. Reset to origin branch and set CHANGES_COMMITTED=false

Example:
  diff: only '- createdAt: "2025-11-13T09:03:15Z"'
        and '+ createdAt: "2025-11-13T14:06:51Z"'
  Result: "ℹ️  Only createdAt timestamp changes detected - ignoring"
  No commit, no PR created.

This ensures bundle repo only gets PRs for substantive changes.

Signed-off-by: myan <myan@redhat.com>

* fix: correct grep pattern for createdAt detection

Fix regex pattern escaping in createdAt-only change detection.

Problem: The grep pattern '^[-+]{3}' was being misinterpreted by bash
due to brace expansion, causing the createdAt detection logic to fail.

Solution: Use separate grep patterns for each marker:
- grep -v '^---'  (removes --- diff markers)
- grep -v '^\+\+\+'  (removes +++ diff markers)

This avoids brace expansion issues and correctly filters out diff
markers along with createdAt lines.

Tested manually:
  git diff origin/release-1.7 | grep -E '^[-+]' | grep -v 'createdAt:' | grep -v '^---' | grep -v '^\+\+\+'
  Result: (empty) - correctly detects createdAt-only changes

Signed-off-by: myan <myan@redhat.com>

* refactor: improve code quality and performance in release scripts

### Code Quality Improvements

- Define PR status constants (PR_STATUS_*) across all scripts to replace literal strings
- Add default (*) cases to all case statements for safety
- Add explicit return statements to all functions
- Redirect all error messages to stderr (>&2)
- Resolve all SonarCloud issues in scripts 04, 05, 06, and cut-release.sh

### Performance Optimizations

- Implement repository reuse pattern in all scripts (01, 03, 04, 05, 06)
- Use git fetch + reset instead of full clone on subsequent runs
- 10-20x faster execution and ~90% less bandwidth usage after first run

### Documentation

- Update README with performance optimization details
- Add code quality standards section
- Document repository reuse behavior

### Scripts Updated

- 01-multicluster-global-hub.sh: Repository reuse
- 03-bundle.sh: Repository reuse
- 04-catalog.sh: Constants, default cases, repository reuse
- 05-grafana.sh: Constants, default cases, repository reuse
- 06-postgres-exporter.sh: Constants, default cases, repository reuse
- cut-release.sh: Default cases, return statements, stderr redirection

Fixes SonarCloud issues in PR #2082

Signed-off-by: myan <myan@redhat.com>

---------

Signed-off-by: Meng Yan <myan@redhat.com>
Signed-off-by: myan <myan@redhat.com>
Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant