Skip to content

Ci/apptainer on release #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 17, 2025
Merged

Ci/apptainer on release #423

merged 5 commits into from
Jul 17, 2025

Conversation

CMonnin
Copy link
Member

@CMonnin CMonnin commented May 20, 2025

Summary by CodeRabbit

  • New Features

    • Added automated workflow to build and attach Apptainer images to releases.
  • Bug Fixes

    • Improved DSURQE template installation script with a fallback download mechanism and enhanced error handling.
  • Other Changes

    • Updated default value for an analysis argument to use a CSV file instead of a NIfTI file.

Copy link
Contributor

coderabbitai bot commented May 20, 2025

Walkthrough

A new GitHub Actions workflow was introduced to build and attach an Apptainer image to releases. The rabies parser script updated the default for an analysis argument from a NIfTI to a CSV file. The DSURQE installation script improved its download logic with a fallback mechanism and enhanced error handling.

Changes

File(s) Change Summary
.github/workflows/apptainer-attach-on-release.yml Added workflow to build and upload Apptainer image on release creation.
rabies/parser.py Reordered imports; changed default for --ROI_csv argument from NIfTI to CSV file.
scripts/install_DSURQE.sh Added fallback download mechanism, improved error handling, and quoted paths for robustness in the DSURQE template script.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Release Event
    participant GitHub Actions Runner
    participant Apptainer
    participant GitHub Container Registry
    participant GitHub Release Assets

    GitHub Release Event->>GitHub Actions Runner: Trigger workflow on release
    GitHub Actions Runner->>GitHub Actions Runner: Checkout code
    GitHub Actions Runner->>GitHub Actions Runner: Install Apptainer
    GitHub Actions Runner->>GitHub Actions Runner: Extract version info
    GitHub Actions Runner->>Apptainer: Build image from Docker (via GHCR)
    Apptainer-->>GitHub Actions Runner: Return .sif image
    GitHub Actions Runner->>GitHub Release Assets: Upload .sif as release asset
Loading

Suggested reviewers

  • gdevenyi

Poem

A workflow hops in, so spry and neat,
Building Apptainer treats for each release to eat.
The parser now prefers CSV for its quest,
While DSURQE downloads are put to the test—
With fallback and quotes, all errors are beat!
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cd177c5 and c2efc8b.

📒 Files selected for processing (2)
  • .github/workflows/apptainer-attach-on-release.yml (1 hunks)
  • scripts/install_DSURQE.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/apptainer-attach-on-release.yml
  • scripts/install_DSURQE.sh
⏰ 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). (2)
  • GitHub Check: build
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

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

@CMonnin CMonnin requested review from Gab-D-G and gdevenyi May 20, 2025 20:37
@CMonnin
Copy link
Member Author

CMonnin commented May 20, 2025

this will be patch release when merged (0.5.2)

@gdevenyi
Copy link
Member

This looks good, but I wonder is it worthwhile to append this to the end of the docker build, so it can pull directly from the local docker daemon with an already built image?

- name: Build Apptainer image from Docker URL
run: |
REPO_LOWERCASE=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
sudo apptainer build app-${{ steps.get_version.outputs.VERSION }}.sif docker://ghcr.io/${REPO_LOWERCASE}:latest
Copy link
Member

Choose a reason for hiding this comment

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

can we use a tag here instead of :latest?

Copy link
Member Author

Choose a reason for hiding this comment

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

done ce92458

@CMonnin
Copy link
Member Author

CMonnin commented May 21, 2025

@gdevenyi i have it separate right now as it only triggers on a manual release. i don't think we want it on every build, right?

@CMonnin CMonnin force-pushed the ci/apptainer-on-release branch from 21c0e09 to ce92458 Compare May 21, 2025 16:53
@gdevenyi
Copy link
Member

@gdevenyi i have it separate right now as it only triggers on a manual release. i don't think we want it on every build, right?

Right. This is over optimization anyways.

@gdevenyi
Copy link
Member

We have a new release, is this ready for merge and use @CMonnin

@CMonnin CMonnin force-pushed the ci/apptainer-on-release branch from 06e7df2 to cd177c5 Compare July 17, 2025 15:10
@CMonnin CMonnin marked this pull request as ready for review July 17, 2025 15:23
@CMonnin
Copy link
Member Author

CMonnin commented Jul 17, 2025

rabased, should be good to go. moved from draft to PR

@gdevenyi
Copy link
Member

The build here throws an error, any idea why? The last tagged build succeeded.

Copy link
Contributor

@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: 5

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7495973 and cd177c5.

📒 Files selected for processing (3)
  • .github/workflows/apptainer-attach-on-release.yml (1 hunks)
  • rabies/parser.py (3 hunks)
  • scripts/install_DSURQE.sh (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/apptainer-attach-on-release.yml

14-14: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


25-25: shellcheck reported issue in this script: SC2086:info:1:44: Double quote to prevent globbing and word splitting

(shellcheck)


28-28: shellcheck reported issue in this script: SC2086:info:3:58: Double quote to prevent globbing and word splitting

(shellcheck)


34-34: the runner of "softprops/action-gh-release@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (7)
.github/workflows/apptainer-attach-on-release.yml (1)

1-39: Well-structured workflow implementation.

The workflow correctly implements the automated Apptainer image building and attachment process as described in the PR objectives. The logic flow is sound and the separation from the main Docker build process is appropriate for manual releases only.

scripts/install_DSURQE.sh (3)

8-44: Excellent implementation of fallback download strategy.

The two-tiered download approach with primary (mouseimaging.ca) and fallback (GitHub) sources is well-designed. The logic correctly attempts primary downloads first, detects failures, and falls back to compressed versions when needed.


40-40: Good error handling with curl options.

The curl commands now include proper flags for robust downloading: --fail for HTTP error detection, --silent --show-error for clean output, and --retry 5 for resilience.

Also applies to: 53-53


62-72: Good implementation of proper quoting.

All curl commands now properly quote URLs and output paths, addressing the previous shellcheck recommendations. This prevents issues with filenames containing spaces or special characters.

rabies/parser.py (3)

2-4: Minor import organization improvement.

The reordering of imports is a good practice for code organization and readability.


959-959: Good alignment with install script changes.

The default value change from NIfTI labels to CSV mapping file correctly aligns with the updated install_DSURQE.sh script that now prioritizes downloading the CSV mapping file. This ensures consistency between the expected input format and what the installation process provides.


1201-1201: Minor formatting improvement.

The blank line addition before the import improves code readability.

Comment on lines 46 to 48
if [ "$primary_success" = true ]; then
gzip -f ${out_dir}/DSURQE_40micron_*.nii
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify gzip compression behavior.

The script compresses .nii files only after successful primary downloads, but the compression command lacks proper quoting and may fail with certain filenames.

Run the following script to verify the gzip command handles filenames correctly:


🏁 Script executed:

#!/bin/bash
# Description: Check if gzip command properly handles filenames with spaces or special characters
# Expected: The command should be quoted to handle edge cases

# Search for gzip usage in the script
rg -A 2 -B 2 "gzip.*DSURQE" scripts/install_DSURQE.sh

Length of output: 142


Quote variable expansions in the gzip command

Unquoted expansions can break on filenames containing spaces or special characters. Update the invocation in scripts/install_DSURQE.sh (around lines 46–48) to properly quote the directory and handle each file safely. For example:

 if [ "$primary_success" = true ]; then
-  gzip -f ${out_dir}/DSURQE_40micron_*.nii
+  # Quote the directory and iterate to handle spaces/special chars
+  for f in "${out_dir}"/DSURQE_40micron_*.nii; do
+    gzip -f "$f"
+  done
 fi
  • Location: scripts/install_DSURQE.sh lines 46–48
  • Change: wrap ${out_dir} in quotes and gzip each file in a loop to avoid word-splitting issues.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "$primary_success" = true ]; then
gzip -f ${out_dir}/DSURQE_40micron_*.nii
fi
if [ "$primary_success" = true ]; then
# Quote the directory and iterate to handle spaces/special chars
for f in "${out_dir}"/DSURQE_40micron_*.nii; do
gzip -f "$f"
done
fi
🤖 Prompt for AI Agents
In scripts/install_DSURQE.sh around lines 46 to 48, the gzip command uses an
unquoted variable expansion which can break if filenames contain spaces or
special characters. To fix this, wrap the ${out_dir} variable in double quotes
and iterate over each matching file in a loop, applying gzip individually to
safely handle each filename without word-splitting issues.

@CMonnin
Copy link
Member Author

CMonnin commented Jul 17, 2025

The build here throws an error, any idea why? The last tagged build succeeded.

SSL cert issues with https://www.mouseimaging.ca
curl aborts instead of using fallback urls

@CMonnin
Copy link
Member Author

CMonnin commented Jul 17, 2025

ok the SSL cert error is there but the fallback was actually working as intended (just silently). Re-running the build worked. Not sure why it failed now . . .

@gdevenyi
Copy link
Member

Can you address the bot requests

@CMonnin
Copy link
Member Author

CMonnin commented Jul 17, 2025

bot addressed, builds successful on 1st attempt

@gdevenyi gdevenyi merged commit ad9b15c into master Jul 17, 2025
3 checks passed
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.

3 participants