Skip to content

Conversation

@noga-magen
Copy link
Contributor

@noga-magen noga-magen commented Aug 19, 2025

I noticed when I try to upload the collection to automation-hub that the name of the file was flightctl-core.
Also I removed redundant part.

Summary by CodeRabbit

  • Chores
    • Build pipeline now uses an isolated temporary workspace to avoid mutating the repository during packaging.
    • Improved reproducibility with explicit versioning and configurable collection root for builds.
    • Consolidated and simplified build steps to reduce failures.
    • Added a preflight check and clear error if the required packaging tool is missing.
    • No functional or API changes for end users.

Signed-off-by: noga-magen <nmagen@redhat.com>
@coderabbitai
Copy link

coderabbitai bot commented Aug 19, 2025

Walkthrough

Build process for the Ansible collection was moved out of the repository tree into a temporary workspace. The script now defines VERSION and COLLECTION_ROOT, generates a transient galaxy.yml with overridden fields, performs a non-mutating rsync copy into a temp dir, verifies ansible-galaxy presence, and builds the collection into a temp OUTPUT_DIR.

Changes

Cohort / File(s) Summary
Downstream packaging script
ci/downstream.sh
Reworked build flow to be non-mutating: added VERSION (default 1.2.0) and COLLECTION_ROOT (default repo root); create and cleanup a temporary workspace (_tmp_dir); rsync source into temp excluding VCS/build artifacts; generate a transient galaxy.yml with overridden version, namespace: redhat, and name: edge_manager written to _tmp_dir/galaxy.yml; set OUTPUT_DIR to _tmp_dir/ansible_collections; check for ansible-galaxy in PATH and abort if missing; build via ansible-galaxy collection build "$_tmp_dir" --output-path "$OUTPUT_DIR"; remove prior in-place edits and reliance on absolute collection dir.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Runner as CI Runner
  participant Script as ci/downstream.sh
  participant Rsync as rsync (copy)
  participant Tmp as Temp Dir (_tmp_dir)
  participant Galaxy as ansible-galaxy
  participant Artifacts as OUTPUT_DIR

  Runner->>Script: invoke (VERSION, COLLECTION_ROOT)
  Script->>Script: check ansible-galaxy in PATH
  Script->>Tmp: mktemp & setup cleanup trap
  Script->>Rsync: copy COLLECTION_ROOT -> Tmp (exclude .git, build, venv, etc.)
  Script->>Tmp: write generated galaxy.yml (version/ns/name)
  Script->>Galaxy: build collection from Tmp --output-path Artifacts
  Galaxy-->>Artifacts: place built artifact
  Script-->>Runner: exit (status)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch NO-ISSUE

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
ci/downstream.sh (2)

11-11: Sed-based YAML mutation is brittle and unescaped; consider yq or at least parameterize namespace/name

Direct sed replacements on YAML are fragile and will misbehave if VERSION contains special characters (e.g., “/” or “&”). Also, you’re hardcoding namespace/name, which makes forks harder.

Two options:

  • Preferred: use yq to set keys safely (if available in the CI image):
- sed "s/^version: .*/version: $VERSION/; s/^namespace: .*/namespace: redhat/; s/^name: .*/name: edge_manager/" "$COLLECTION_ROOT/galaxy.yml" > "$_tmp_dir/galaxy.yml"
+ yq -y \
+   ".version = strenv(VERSION) |
+    .namespace = env(NAMESPACE) |
+    .name = env(NAME)" \
+   "$COLLECTION_ROOT/galaxy.yml" > "$_tmp_dir/galaxy.yml"
  • Or, minimally, parameterize namespace/name for forks and keep sed:
+ NAMESPACE="${NAMESPACE:-redhat}"
+ NAME="${NAME:-edge_manager}"
- sed "s/^version: .*/version: $VERSION/; s/^namespace: .*/namespace: redhat/; s/^name: .*/name: edge_manager/" "$COLLECTION_ROOT/galaxy.yml" > "$_tmp_dir/galaxy.yml"
+ sed "s/^version: .*/version: $VERSION/; s/^namespace: .*/namespace: ${NAMESPACE}/; s/^name: .*/name: ${NAME}/" "$COLLECTION_ROOT/galaxy.yml" > "$_tmp_dir/galaxy.yml"

If you stick with sed, consider escaping replacements to handle “/” and “&”.


4-5: Make VERSION, NAMESPACE, NAME env-overridable for CI flexibility

Allowing env overrides makes the script usable across forks and release jobs without positional args.

Apply:

-VERSION="${1:-1.2.0}"
+VERSION="${VERSION:-${1:-1.2.0}}"
 COLLECTION_ROOT="${2:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
+NAMESPACE="${NAMESPACE:-redhat}"
+NAME="${NAME:-edge_manager}"

You can then reference $NAMESPACE/$NAME in the metadata mutation step (see prior comment).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 21f08ed and 96e80d7.

📒 Files selected for processing (1)
  • ci/downstream.sh (1 hunks)

Signed-off-by: noga-magen <nmagen@redhat.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
ci/downstream.sh (4)

12-20: rsync is a hard dependency here — add fallback or preflight

If rsync isn’t available in the CI image, the script will fail. Either check for rsync and fall back to cp -a, or preflight and exit with a clear message.

Apply this diff to add a simple fallback:

-rsync -a --delete \
-  --exclude '.git' \
-  --exclude '.github' \
-  --exclude 'build' \
-  --exclude '.tox' \
-  --exclude 'venv' \
-  --exclude '.venv' \
-  "${COLLECTION_ROOT}/" "${_tmp_dir}/"
+if command -v rsync >/dev/null 2>&1; then
+  rsync -a --delete \
+    --exclude '.git' \
+    --exclude '.github' \
+    --exclude 'build' \
+    --exclude '.tox' \
+    --exclude 'venv' \
+    --exclude '.venv' \
+    "${COLLECTION_ROOT}/" "${_tmp_dir}/"
+else
+  # Fallback without excludes; acceptable for builds, but consider adding a .galaxyignore if needed.
+  cp -a "${COLLECTION_ROOT}/." "${_tmp_dir}/"
+fi

22-23: Hard-coding name/namespace — confirm intent; consider only bumping version

Given the PR’s goal (fixing a redundant part that led to a wrong artifact name), overwriting name and namespace here may reintroduce drift from galaxy.yml. If galaxy.yml already holds the correct values, limit the override to version.

Apply this diff if you intend to rely on galaxy.yml for name/namespace:

-sed "s/^version: .*/version: $VERSION/; s/^namespace: .*/namespace: redhat/; s/^name: .*/name: edge_manager/" "$COLLECTION_ROOT/galaxy.yml" > "$_tmp_dir/galaxy.yml"
+sed -E "s/^version:\s*.*/version: ${VERSION}/" "$COLLECTION_ROOT/galaxy.yml" > "$_tmp_dir/galaxy.yml"

If you do need overrides, consider parameterizing them (e.g., NAME/NAMESPACE env vars) instead of hard-coding.


25-28: Minor: make builds idempotent and surface conflicts

Adding --force prevents build failures on re-runs when the artifact already exists in OUTPUT_DIR. Also, consider printing the produced filename for CI logs.

Apply this diff:

-ansible-galaxy collection build "$_tmp_dir" --output-path "$OUTPUT_DIR"
+ansible-galaxy collection build "$_tmp_dir" --output-path "$OUTPUT_DIR" --force

4-5: VERSION/COLLECTION_ROOT defaults look fine; consider single-source-of-truth for version

Optional: if $1 isn’t provided, you could default VERSION from galaxy.yml to avoid drift, and bail early if galaxy.yml is missing under COLLECTION_ROOT.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 96e80d7 and 2b5f9be.

📒 Files selected for processing (1)
  • ci/downstream.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test-unit-downstream
  • GitHub Check: test-sanity-downstream
  • GitHub Check: integration-tests (stable-2.16, 3.12)

@noga-magen noga-magen requested a review from SiddarthR56 August 21, 2025 13:41
@noga-magen

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants