Skip to content

feat(x2a): Copy all files created#3181

Open
eloycoto wants to merge 3 commits into
redhat-developer:mainfrom
eloycoto:TemplateChanges
Open

feat(x2a): Copy all files created#3181
eloycoto wants to merge 3 commits into
redhat-developer:mainfrom
eloycoto:TemplateChanges

Conversation

@eloycoto
Copy link
Copy Markdown
Contributor

When the export agent creates new files because of RULES, it will create files based on the rules, but was not copied on the phase:

Example:

-> tail -n 5 ../chef-examples/EXPORT-AGENTS.md
---

Every migrated Ansible project must include a GitHub Actions workflow at `.github/workflows/ansible-ci.yml` that runs `ansible-lint` on every pull request. The workflow runs on `ubuntu-latest`, checks out the code, installs `ansible-lint`, and executes `ansible-lint roles/ --strict`.%
$ -> ls ../chef-examples/.github/workflows
ansible-ci.yml

This change just go over the git files, and merged the files that are created, outside the ansible folder, and do all the files directly

Related to: FLPATH-3351

@rhdh-gh-app
Copy link
Copy Markdown

rhdh-gh-app Bot commented May 19, 2026

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.4.2

When the export agent creates new files because of RULES, it will create files based on the rules, but was not copied on the phase:

Example:
```
-> tail -n 5 ../chef-examples/EXPORT-AGENTS.md
---

Every migrated Ansible project must include a GitHub Actions workflow at `.github/workflows/ansible-ci.yml` that runs `ansible-lint` on every pull request. The workflow runs on `ubuntu-latest`, checks out the code, installs `ansible-lint`, and executes `ansible-lint roles/ --strict`.%
$ -> ls ../chef-examples/.github/workflows
ansible-ci.yml
```

This change just go over the git files, and merged the files that are created, outside the ansible folder, and do all the files directly

Related to: FLPATH-3351

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.00%. Comparing base (a4ff750) to head (db5ee85).
⚠️ Report is 11 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3181      +/-   ##
==========================================
+ Coverage   60.97%   61.00%   +0.02%     
==========================================
  Files        2098     2099       +1     
  Lines       65133    65165      +32     
  Branches    16908    16906       -2     
==========================================
+ Hits        39717    39756      +39     
+ Misses      25128    25116      -12     
- Partials      288      293       +5     
Flag Coverage Δ *Carryforward flag
adoption-insights 83.58% <ø> (ø) Carriedforward from 045107e
ai-integrations 70.03% <ø> (ø) Carriedforward from 045107e
app-defaults 69.60% <ø> (ø) Carriedforward from 045107e
augment 69.36% <ø> (ø) Carriedforward from 045107e
bulk-import 72.86% <ø> (ø) Carriedforward from 045107e
cost-management 16.49% <ø> (ø) Carriedforward from 045107e
dcm 32.85% <ø> (ø) Carriedforward from 045107e
extensions 61.79% <ø> (ø) Carriedforward from 045107e
global-floating-action-button 74.30% <ø> (ø) Carriedforward from 045107e
global-header 61.68% <ø> (ø) Carriedforward from 045107e
homepage 50.95% <ø> (ø) Carriedforward from 045107e
konflux 91.01% <ø> (ø) Carriedforward from 045107e
lightspeed 68.33% <ø> (ø) Carriedforward from 045107e
mcp-integrations 81.59% <ø> (ø) Carriedforward from 045107e
orchestrator 36.36% <ø> (ø) Carriedforward from 045107e
quickstart 62.88% <ø> (ø) Carriedforward from 045107e
sandbox 79.49% <ø> (ø) Carriedforward from 045107e
scorecard 83.72% <ø> (ø) Carriedforward from 045107e
theme 64.54% <ø> (ø) Carriedforward from 045107e
translations 8.49% <ø> (ø) Carriedforward from 045107e
x2a 78.59% <ø> (+0.30%) ⬆️

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


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4ff750...db5ee85. 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.

Copy link
Copy Markdown
Member

@mareklibra mareklibra left a comment

Choose a reason for hiding this comment

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

Original idea behind having all the filenames hardcoded was in having control over the target content to include what is really needed, having the artifacts.

This patch changes the logic - we will need to explicitly exclude whatever is meant to be temporal.

I agree it makes more sense when the input agents evolved from the single Chef.

It's not an issue, just noting.

cp -v "${SOURCE_BASE}/Policyfile.lock.json" "${PROJECT_PATH}/" 2>/dev/null || true
# Copy all files the x2a tool created/modified to the module output directory
# Exclude files we copied into source before running x2a
copy_changed_files "${SOURCE_BASE}" "${OUTPUT_DIR}" \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does that properly handle the Policyfile.lock.json? The OUTPUT_DIR is a module path, not the project root as it used to be.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could INPUT-AGENTS.md be leaked into the module's directory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That files are to be copy, always


echo "=== Copying changed files to ${dest_dir}/ ==="

cd "${source_dir}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing revert - sort of pushd/popd clean-up would be safer for the future.

So far absolute paths are used, however leaving the working directory unchanged by the copy_changed_files would be a better practice.

@eloycoto eloycoto marked this pull request as draft May 21, 2026 13:17
Before the migration-dependencies were not copied, so the AI allucinated a bit without me noticing it. With this change, the files are copied correctly, and AI it's correct:

From logs:

```
Copying migration-dependencies from target to source directory...
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies' -> '/workspace/source/migration-dependencies'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/.chef' -> '/workspace/source/migration-dependencies/.chef'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/.chef/config.rb' -> '/workspace/source/migration-dependencies/.chef/config.rb'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/Policyfile.lock.json' -> '/workspace/source/migration-dependencies/Policyfile.lock.json'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/README.md' -> '/workspace/source/migration-dependencies/README.md'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts' -> '/workspace/source/migration-dependencies/cookbook_artifacts'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f' -> '/workspace/source/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f/metadata.json' -> '/workspace/source/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f/metadata.json'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f/recipes' -> '/workspace/source/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f/recipes'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f/recipes/default.rb' -> '/workspace/source/migration-dependencies/cookbook_artifacts/cache-8af253a1652c2d2161cc3e72a8b3048c6ebcf62f/recipes/default.rb'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b' -> '/workspace/source/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b/metadata.json' -> '/workspace/source/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b/metadata.json'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b/recipes' -> '/workspace/source/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b/recipes'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b/recipes/default.rb' -> '/workspace/source/migration-dependencies/cookbook_artifacts/fastapi-tutorial-dd2f622316b9a9e4b9bf50d492ffa2551017405b/recipes/default.rb'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/memcached-7992788f1a376defb902059063f5295e37d281cb' -> '/workspace/source/migration-dependencies/cookbook_artifacts/memcached-7992788f1a376defb902059063f5295e37d281cb'
'/workspace/target/llasd21312-c74d4e/modules/cache/migration-dependencies/cookbook_artifacts/memcached-7992788f1a376defb902059063f5295e37d281cb/.editorconfig' -> '/workspace/source/migration-dependencies/cookbook_artifacts/memcached-7992788f1a376defb902059063f5295e37d281cb/.editorconfig'
```

From the migration plan:

~~~

```
cookbooks/cache/recipes/default.rb
/workspace/source/migration-dependencies/cookbook_artifacts/memcached-7992788f1a376defb902059063f5295e37d281cb/recipes/default.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/recipes/default.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/recipes/_install_prereqs.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/recipes/install.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/recipes/ulimit.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/recipes/disable_os_default.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/recipes/configure.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/recipes/enable.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/providers/configure.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/providers/install.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/templates/default/redis.conf.erb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/templates/default/redis.init.erb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/templates/default/redis.upstart.conf.erb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/templates/default/redis@.service.erb
/workspace/source/migration-dependencies/cookbook_artifacts/memcached-7992788f1a376defb902059063f5295e37d281cb/attributes/default.rb
/workspace/source/migration-dependencies/cookbook_artifacts/redisio-cac70a2ec9102cac4f5391358c8565d244f5d4db/attributes/default.rb
```
~~~

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@sonarqubecloud
Copy link
Copy Markdown

@eloycoto eloycoto marked this pull request as ready for review May 21, 2026 15:43
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