Skip to content

chore(x2a): change publish phase actions order#3551

Open
yray-pixel wants to merge 1 commit into
redhat-developer:mainfrom
yray-pixel:bugfix/aap-github-sync
Open

chore(x2a): change publish phase actions order#3551
yray-pixel wants to merge 1 commit into
redhat-developer:mainfrom
yray-pixel:bugfix/aap-github-sync

Conversation

@yray-pixel

Copy link
Copy Markdown
Contributor

Fix: Ensure AAP syncs after GitHub push completes (FLPATH-4398)

Problem

AAP was unable to discover migrated Ansible playbooks because it was syncing the Git repository before GitHub
finished processing the push..

Root Cause

The job script was calling publish-aap (which triggers AAP project sync) immediately after generating the Ansible
project files, but before committing and pushing to GitHub. This created a race condition where AAP's sync often
completed before the new playbooks were available on GitHub.

Solution

This PR refactors the job script to:

  1. Commit and push to GitHub first - Ensures the Ansible project is available on the remote repository
  2. Then call publish-aap - AAP now syncs against the latest commit with all playbooks present

Changes

New git_commit_and_push() helper function:

  • Encapsulates common git commit/push logic
  • Handles both new and existing branches

@rhdh-gh-app

rhdh-gh-app Bot commented Jun 23, 2026

Copy link
Copy Markdown

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-x2a-backend workspaces/x2a/plugins/x2a-backend patch v1.6.0

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.74%. Comparing base (94d1d9a) to head (15e6055).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3551   +/-   ##
=======================================
  Coverage   53.74%   53.74%           
=======================================
  Files        2268     2268           
  Lines       86468    86468           
  Branches    24246    24247    +1     
=======================================
  Hits        46468    46468           
  Misses      38441    38441           
  Partials     1559     1559           
Flag Coverage Δ *Carryforward flag
adoption-insights 83.70% <ø> (ø) Carriedforward from 94d1d9a
ai-integrations 67.95% <ø> (ø) Carriedforward from 94d1d9a
app-defaults 69.79% <ø> (ø) Carriedforward from 94d1d9a
augment 46.39% <ø> (ø) Carriedforward from 94d1d9a
boost 71.71% <ø> (ø) Carriedforward from 94d1d9a
bulk-import 72.46% <ø> (ø) Carriedforward from 94d1d9a
cost-management 14.10% <ø> (ø) Carriedforward from 94d1d9a
dcm 61.79% <ø> (ø) Carriedforward from 94d1d9a
extensions 61.53% <ø> (ø) Carriedforward from 94d1d9a
global-floating-action-button 71.18% <ø> (ø) Carriedforward from 94d1d9a
global-header 59.71% <ø> (ø) Carriedforward from 94d1d9a
homepage 49.84% <ø> (ø) Carriedforward from 94d1d9a
install-dynamic-plugins 56.23% <ø> (ø) Carriedforward from 94d1d9a
konflux 91.49% <ø> (ø) Carriedforward from 94d1d9a
lightspeed 68.57% <ø> (ø) Carriedforward from 94d1d9a
mcp-integrations 85.46% <ø> (ø) Carriedforward from 94d1d9a
orchestrator 38.02% <ø> (ø) Carriedforward from 94d1d9a
quickstart 63.76% <ø> (ø) Carriedforward from 94d1d9a
sandbox 79.56% <ø> (ø) Carriedforward from 94d1d9a
scorecard 83.96% <ø> (ø) Carriedforward from 94d1d9a
theme 61.26% <ø> (ø) Carriedforward from 94d1d9a
translations 7.25% <ø> (ø) Carriedforward from 94d1d9a
x2a 78.68% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94d1d9a...15e6055. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eloycoto eloycoto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the publish, it commits twice, no?

cleanup() {
  local exit_code=$?
  set +e

  # Always try to commit and push whatever is in the working directory
  if [ -d /workspace/target/.git ]; then
    local commit_msg="x2a: ${PHASE} phase for ${MODULE_NAME:-project}

Phase: ${PHASE}
Project: ${PROJECT_ID}
Module: ${MODULE_NAME:-N/A}
Job: ${JOB_ID}

Co-Authored-By: ${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>
"
    git_commit_and_push "${commit_msg}" false  # Don't exit on error in cleanup
  fi

  if [ "$TERMINATED" = true ]; then
    report_result "error" "Job was terminated"
  elif [ ${exit_code} -ne 0 ]; then
    report_result "error" "${ERROR_MESSAGE:-Script failed with exit code ${exit_code}}"
  elif [ -n "${PUSH_FAILED}" ]; then
    report_result "error" "${PUSH_FAILED}"
  else
    report_result "success" ""
  fi
}

so, should be a check that SKIP_COMMIT entry, no?

# This ensures AAP syncs the latest commit with the new playbooks
echo ""
echo "=== Committing and pushing Ansible project to git ==="
git_commit_and_push "x2a: ${PHASE} phase for ${MODULE_NAME}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we define the variable for the commit message? it's easy to read the function and the input-variable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like the cleanup: local commit_msg

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.

2 participants