Skip to content
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

feat!: Use composite action with conda instead of docker action #39

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

tedil
Copy link

@tedil tedil commented Dec 9, 2024

Summary by CodeRabbit

  • New Features

    • Added input parameters for specifying Snakemake version and controlling Apptainer installation in the action configuration.
    • Introduced a validation step for task input with error handling.
    • Conditional execution for running or containerizing Snakemake based on user input.
  • Bug Fixes

    • Corrected input description for disk usage error handling.
  • Chores

    • Removed the Dockerfile and entrypoint.sh script as part of the transition to a composite action model.

Copy link

coderabbitai bot commented Dec 9, 2024

📝 Walkthrough

Walkthrough

The changes involve the removal of the Dockerfile and entrypoint.sh, which were previously used to define a containerized environment for Snakemake workflows. The action.yml file has been updated to include new input parameters for specifying the Snakemake version and controlling the installation of Apptainer. The execution model has transitioned from a Docker-based approach to a composite action with multiple steps for input validation, environment setup, and Snakemake execution, including error handling and conditional logic based on user inputs.

Changes

File Change Summary
Dockerfile Deleted. Previously defined a container image based on snakemake/snakemake:stable, copied entrypoint.sh, set CONDA_ENVS_PATH, and configured ENTRYPOINT.
action.yml Modified to add new inputs: snakemake-version (default '*') and install-apptainer (default false). Updated description for show-disk-usage-on-error from "descriptions" to "description" and added required field. Changed execution model to a composite action with steps for input validation, environment setup, and conditional Snakemake execution. Error handling added for various scenarios.
entrypoint.sh Deleted. Previously managed Snakemake execution with parameters for 'containerize' and 'run', included error handling, and output disk usage information based on conditions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant Snakemake

    User->>Action: Trigger action with parameters
    Action->>Action: Validate inputs
    alt Valid inputs
        Action->>Action: Setup environment
        Action->>Snakemake: Execute Snakemake with parameters
        alt Execution successful
            Snakemake-->>Action: Return success
        else Execution failed
            Snakemake-->>Action: Return error
            Action->>User: Show error message
            alt Show disk usage
                Action->>Action: Display disk usage information
            end
        end
    else Invalid inputs
        Action-->>User: Show error message
    end
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Experiment)
  • @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.

@tedil tedil marked this pull request as ready for review December 9, 2024 10:49
@tedil tedil requested a review from johanneskoester December 9, 2024 10:49
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: 3

🧹 Outside diff range and nitpick comments (3)
environment.yaml.template (1)

5-6: Consider pinning Python version for reproducibility.

While snakemake version is specified, the Python version is not pinned. This could lead to inconsistent environments across different systems.

 dependencies:
   - snakemake =={{ snakemake_version }}
+  - python >=3.8,<3.12
action.yml (2)

33-36: Consider version constraint validation.

While the default version is specified, there's no validation for user-provided versions. Consider adding a pattern check to ensure valid semver format.

   snakemake-version:
    description: Which snakemake version to use
    required: false
    default: 8.25.5
+   pattern: '^[0-9]+\.[0-9]+\.[0-9]+$'

49-55: Consider caching conda environment.

To improve action performance, consider using GitHub's cache action for the conda environment.

+    - name: Cache conda env
+      uses: actions/cache@v3
+      with:
+        path: /usr/share/miniconda3/envs/
+        key: conda-${{ hashFiles('environment.yaml') }}
     - name: Setup conda
       uses: conda-incubator/setup-miniconda@v3
       with:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8fe6e99 and 786074d.

📒 Files selected for processing (4)
  • Dockerfile (0 hunks)
  • action.yml (1 hunks)
  • entrypoint.sh (0 hunks)
  • environment.yaml.template (1 hunks)
💤 Files with no reviewable changes (2)
  • Dockerfile
  • entrypoint.sh
🔇 Additional comments (2)
environment.yaml.template (1)

1-4: LGTM! Channel configuration follows best practices.

The channel configuration is well-structured:

  • Using conda-forge and bioconda is appropriate for bioinformatics workflows
  • Including nodefaults prevents package conflicts
action.yml (1)

41-46: LGTM! Input validation is well implemented.

The validation step properly checks for valid task values and provides a clear error message.

action.yml Outdated Show resolved Hide resolved
action.yml Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
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: 0

🧹 Outside diff range and nitpick comments (3)
action.yml (3)

33-36: Consider using a more flexible version strategy

While version pinning provides stability, it requires regular maintenance to stay up-to-date with new Snakemake releases. Consider using a major version range (e.g., "^8.0.0") to automatically get compatible updates.

   snakemake-version:
    description: Which snakemake version to use
    required: false
-   default: 8.25.5
+   default: ^8.0.0

41-46: Improve error message formatting

The error message could be more user-friendly and avoid potential escaping issues.

     - name: Validate inputs
       if: ${{ ! (inputs.task == 'containerize' || inputs.task == 'run' )}}
       shell: bash -el {0}
       run: |
-        echo 'Invalid value for "task": "${{ inputs.task }}". Options: "containerize", "run".'
+        echo "Error: Invalid value for 'task': '${{ inputs.task }}'"
+        echo "Available options: 'containerize', 'run'"
         exit 1

39-39: Consider documenting the implications of switching to composite actions

While composite actions typically offer faster execution compared to Docker actions, they rely on the runner's environment. Consider:

  1. Documenting any specific runner requirements
  2. Adding environment validation steps
  3. Testing the action across different runner types (Ubuntu, Windows, macOS)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 786074d and d84999b.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🔇 Additional comments (3)
action.yml (3)

47-48: Add error handling for template processing.

The sed command should check if the template file exists and handle potential errors.


60-69: Fix disk usage error handling.

There are several issues in the error handling block:

  1. $1 is not defined - should be ${{ inputs.directory }}

70-73: Add error handling for containerization step.

The containerization step should check the exit status and provide appropriate error messages.

@tedil
Copy link
Author

tedil commented Dec 9, 2024

Things that could be improved:

  • use an explicit environment name, e.g. 'snakemake' (instead of the default 'test')
  • enable caching?
  • expose python version as an additional configurable input?

@tedil
Copy link
Author

tedil commented Dec 9, 2024

Also fixes #21 and resolves the issue in #9

@tedil tedil changed the title feat: Use composite action instead of docker action feat: Use composite action with conda instead of docker action Dec 9, 2024
@johanneskoester
Copy link
Contributor

Things that could be improved:

* use an explicit environment name, e.g. 'snakemake' (instead of the [default 'test'](https://github.com/marketplace/actions/setup-miniconda#environment-activation))

* enable [caching](https://github.com/marketplace/actions/setup-miniconda#environment-activation)?

* expose python version as an additional configurable input?

All three ideas are good. I would say the first one would be great still in this PR. The other ones can be postponed to follow up PRs.

Copy link
Contributor

@johanneskoester johanneskoester left a comment

Choose a reason for hiding this comment

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

What about apptainer? Am I right that it is now not installed? Maybe one should at least provide a way to install it as well?

action.yml Outdated Show resolved Hide resolved
@johanneskoester
Copy link
Contributor

What about apptainer? Am I right that it is now not installed? Maybe one should at least provide a way to install it as well?

Or maybe it is always available in github CI?

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: 2

🧹 Outside diff range and nitpick comments (1)
action.yml (1)

61-70: Simplify error handling.

The error handling can be simplified by removing the redundant exit status check.

-        snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}
-        if [[ "$?" -ne 0 ]]; then
+        if ! snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}; then
           if [[ ${{ inputs.show-disk-usage-on-error }} = true ]]; then
               # return disk usage and space on failing
               df -h
               printf "disk usage working directory"
               du -h -d3 ${{ inputs.directory }}
           fi
           exit 1
         fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d84999b and 68b501b.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
📓 Learnings (1)
action.yml (2)
Learnt from: johanneskoester
PR: snakemake/snakemake-github-action#39
File: action.yml:70-73
Timestamp: 2024-12-09T16:41:37.740Z
Learning: In Snakemake workflows, Snakemake itself provides proper error messages during the containerization step, so additional error handling in the GitHub Action script is unnecessary.
Learnt from: tedil
PR: snakemake/snakemake-github-action#39
File: action.yml:47-48
Timestamp: 2024-12-09T10:52:48.855Z
Learning: In the `action.yml` file for `snakemake-github-action`, since `environment.yaml.template` is part of the repository and is expected to exist, adding error handling to check for its presence is unnecessary.
🔇 Additional comments (2)
action.yml (2)

56-56: LGTM: Environment name set to 'snakemake'.

Good implementation of the suggested change to use an explicit environment name instead of the default 'test'.


71-74: LGTM: Clean containerization implementation.

The implementation is correct and appropriately relies on Snakemake's built-in error handling.

action.yml Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.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: 0

🧹 Outside diff range and nitpick comments (3)
action.yml (3)

40-45: Enhance input validation robustness.

While the validation logic is correct, consider these improvements:

  1. Use double quotes for string interpolation
  2. Add input trimming to handle whitespace
-        echo 'Invalid value for "task": "${{ inputs.task }}". Options: "containerize", "run".'
+        task="${{ inputs.task }}"
+        task="${task// /}"  # trim whitespace
+        echo "Invalid value for \"task\": \"$task\". Options: \"containerize\", \"run\"."

48-56: Consider adding Apptainer installation support.

As discussed in the PR comments, Apptainer installation needs to be addressed. Consider adding:

  1. A new input parameter to control Apptainer installation
  2. A conditional step to install Apptainer when needed

Example implementation:

inputs:
  install-apptainer:
    description: Whether to install Apptainer for container support
    required: false
    default: false

# Add after conda setup
steps:
  - name: Install Apptainer
    if: ${{ inputs.install-apptainer == 'true' }}
    shell: bash -el {0}
    run: |
      sudo add-apt-repository -y ppa:apptainer/ppa
      sudo apt update
      sudo apt install -y apptainer

57-69: Improve error handling readability.

Consider these improvements:

  1. Add newline before disk usage message
  2. Simplify error handling using command chaining
-        snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}
-        if [[ "$?" -ne 0 ]]; then
+        if ! snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}; then
           if [[ ${{ inputs.show-disk-usage-on-error }} = true ]]; then
               # return disk usage and space on failing
               df -h
-              printf "disk usage working directory"
+              printf "\nDisk usage working directory:\n"
               du -h -d3 ${{ inputs.directory }}
           fi
           exit 1
         fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 68b501b and 8ae8997.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
📓 Learnings (1)
action.yml (2)
Learnt from: johanneskoester
PR: snakemake/snakemake-github-action#39
File: action.yml:70-73
Timestamp: 2024-12-09T16:41:37.740Z
Learning: In Snakemake workflows, Snakemake itself provides proper error messages during the containerization step, so additional error handling in the GitHub Action script is unnecessary.
Learnt from: tedil
PR: snakemake/snakemake-github-action#39
File: action.yml:47-48
Timestamp: 2024-12-09T10:52:48.855Z
Learning: In the `action.yml` file for `snakemake-github-action`, since `environment.yaml.template` is part of the repository and is expected to exist, adding error handling to check for its presence is unnecessary.
🔇 Additional comments (3)
action.yml (3)

30-35: LGTM! Input parameters are well-defined.

The description fix and the new snakemake-version input are well-documented. The absence of a default value for snakemake-version aligns with the discussion about using the latest version by default.


38-39: LGTM! Composite action setup is correct.

The transition from Docker to composite action is implemented correctly and aligns with the PR objectives.


70-73: LGTM! Containerization step is correctly implemented.

The containerization step is properly implemented and relies on Snakemake's built-in error handling as discussed.

@tedil
Copy link
Author

tedil commented Dec 9, 2024

What about apptainer? Am I right that it is now not installed? Maybe one should at least provide a way to install it as well?

Or maybe it is always available in github CI?

not sure, but I've included an (optional) installation via apt as proposed by the 🐰

@johanneskoester johanneskoester changed the title feat: Use composite action with conda instead of docker action feat!: Use composite action with conda instead of docker action Dec 10, 2024
@johanneskoester
Copy link
Contributor

Nice! Testing this now here: snakemake-workflows/dna-seq-varlociraptor#345

@johanneskoester
Copy link
Contributor

@johanneskoester
Copy link
Contributor

Not sure if it is my fault or a bug though.

@tedil
Copy link
Author

tedil commented Dec 10, 2024

Not sure if it is my fault or a bug though.

Probably a bug, not sure what the template is relative to (upon invocation of the action).
We can avoid the template either

  • by just including its contents in the action.yml as a regular string, or
  • by having an additional step which installs snakemake into the environment, i.e. conda install snakemake==${{ snakemake_version }}.

Take your pick ;)

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: 2

🧹 Outside diff range and nitpick comments (3)
action.yml (3)

33-36: Consider implications of using '*' as default version

While using '*' allows for automatic updates to the latest version, it might impact workflow reproducibility. Consider:

  1. Using an empty default to clearly indicate latest version behavior
  2. Adding a warning in the description about reproducibility implications
   snakemake-version:
-    description: Snakemake version to use. If not specified, uses latest version. Pin a specific version (e.g., '8.25.5') for reproducibility.
-    required: false
-    default: '*'
+    description: |
+      Snakemake version to use. 
+      - If not specified or empty: Uses latest version (recommended for development)
+      - For production/reproducible workflows: Pin a specific version (e.g., '8.25.5')
+    required: false

45-51: Enhance error message clarity

The error message could be more user-friendly and informative.

     - name: Validate inputs
       if: ${{ ! (inputs.task == 'containerize' || inputs.task == 'run' )}}
       shell: bash -el {0}
       run: |
-        echo 'Invalid value for "task": "${{ inputs.task }}". Options: "containerize", "run".'
+        echo "Error: Invalid value for input parameter 'task'"
+        echo "Provided: '${{ inputs.task }}'"
+        echo "Expected: 'containerize' or 'run'"
         exit 1

99-103: Fix file formatting

Remove extra blank lines at the end of the file to comply with YAML style guidelines.

     - name: Containerize snakemake
       if: ${{ inputs.task == 'containerize' }}
       shell: bash -el {0}
       run: snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }} --containerize > Dockerfile
-
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 103-103: too many blank lines

(1 > 0) (empty-lines)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae8997 and 8c55e2b.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
📓 Learnings (1)
action.yml (2)
Learnt from: johanneskoester
PR: snakemake/snakemake-github-action#39
File: action.yml:70-73
Timestamp: 2024-12-09T16:41:37.740Z
Learning: In Snakemake workflows, Snakemake itself provides proper error messages during the containerization step, so additional error handling in the GitHub Action script is unnecessary.
Learnt from: tedil
PR: snakemake/snakemake-github-action#39
File: action.yml:47-48
Timestamp: 2024-12-09T10:52:48.855Z
Learning: In the `action.yml` file for `snakemake-github-action`, since `environment.yaml.template` is part of the repository and is expected to exist, adding error handling to check for its presence is unnecessary.
🪛 yamllint (1.35.1)
action.yml

[warning] 103-103: too many blank lines

(1 > 0) (empty-lines)


[error] 62-62: syntax error: expected , but found ''

(syntax)

🔇 Additional comments (2)
action.yml (2)

43-44: LGTM: Good transition to composite action

The switch from Docker to composite action provides better flexibility and control over the execution environment.


80-98: LGTM: Good error handling and version display

The implementation includes helpful debugging information with version display and proper error handling with disk usage reporting.

action.yml Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
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: 0

🧹 Outside diff range and nitpick comments (1)
action.yml (1)

45-51: Enhance error message with valid options

The error message could be more helpful by explicitly listing the valid options.

     - name: Validate inputs
       if: ${{ ! (inputs.task == 'containerize' || inputs.task == 'run' )}}
       shell: bash -el {0}
       run: |
-        echo 'Invalid value for "task": "${{ inputs.task }}". Options: "containerize", "run".'
+        echo 'Error: Invalid value for "task": "${{ inputs.task }}"'
+        echo 'Valid options are:'
+        echo '  - "containerize": Generate a container image specification'
+        echo '  - "run": Execute the Snakemake workflow'
         exit 1
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8c55e2b and 8d6dd04.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
📓 Learnings (1)
action.yml (2)
Learnt from: johanneskoester
PR: snakemake/snakemake-github-action#39
File: action.yml:70-73
Timestamp: 2024-12-09T16:41:37.740Z
Learning: In Snakemake workflows, Snakemake itself provides proper error messages during the containerization step, so additional error handling in the GitHub Action script is unnecessary.
Learnt from: tedil
PR: snakemake/snakemake-github-action#39
File: action.yml:47-48
Timestamp: 2024-12-09T10:52:48.855Z
Learning: In the `action.yml` file for `snakemake-github-action`, since `environment.yaml.template` is part of the repository and is expected to exist, adding error handling to check for its presence is unnecessary.
🔇 Additional comments (5)
action.yml (5)

84-98: LGTM: Run step with error handling looks good

The implementation correctly handles errors and provides disk usage information when requested.


99-102: LGTM: Containerization step looks good

As per the learnings from @johanneskoester, Snakemake itself provides proper error messages during containerization, so additional error handling is not needed.


33-36: Consider adding version constraint validation

While using '*' as default allows using the latest version, it might be worth adding validation to ensure that when a specific version is provided, it follows semantic versioning format (e.g., '8.25.5').

   snakemake-version:
     description: Snakemake version to use. If not specified, uses latest version. Pin a specific version (e.g., '8.25.5') for reproducibility.
     required: false
-    default: '*'
+    default: 'latest'
✅ Verification successful

Let me check how the version is actually used in the action to determine if validation is really necessary.


Using '*' as default version is safe, no validation needed

The version parameter is used directly with pip's version specifier syntax (==) which safely handles both specific versions and wildcards. When '*' is used, it will install the latest version, and when a specific version is provided (e.g., '8.25.5'), pip's built-in version parsing will validate and enforce it. The current implementation aligns well with pip's version specification format and Snakemake's semantic versioning releases.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if Snakemake follows semantic versioning in its releases
gh api graphql -f query='
{
  repository(owner: "snakemake", name: "snakemake") {
    releases(first: 5, orderBy: {field: CREATED_AT, direction: DESC}) {
      nodes {
        tagName
      }
    }
  }
}'

Length of output: 365


Script:

#!/bin/bash
# Check how the version parameter is used in the action
rg "snakemake-version" -A 5

Length of output: 584


52-58: ⚠️ Potential issue

Add runner compatibility check and error handling

The current implementation assumes an Ubuntu-based runner and doesn't handle potential apt-get failures.

     - name: Install Apptainer
       if: ${{ inputs.install-apptainer == 'true' }}
       shell: bash -el {0}
       run: |
+        if ! grep -q "Ubuntu" /etc/os-release; then
+          echo "Error: Apptainer installation is only supported on Ubuntu runners"
+          exit 1
+        fi
+        if ! sudo apt-get update; then
+          echo "Error: Failed to update package list"
+          exit 1
+        fi
+        if ! sudo apt-get install -y apptainer; then
+          echo "Error: Failed to install Apptainer"
+          exit 1
+        fi
-        sudo apt-get update
-        sudo apt-get install -y apptainer

Likely invalid or redundant comment.


71-79: 🛠️ Refactor suggestion

Add environment setup validation

The setup doesn't verify if the conda environment was successfully created and activated.

     - name: Setup conda
       uses: conda-incubator/setup-miniconda@v3
       with:
         channels: conda-forge,bioconda
         channel-priority: strict
         miniforge-version: latest
         environment-file: .snakemake.environment.yaml
         activate-environment: snakemake
+    - name: Verify conda environment
+      shell: bash -el {0}
+      run: |
+        if ! conda info --envs | grep -q "snakemake"; then
+          echo "Error: Failed to create conda environment"
+          exit 1
+        fi

Likely invalid or redundant comment.

johanneskoester and others added 2 commits December 10, 2024 15:34
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.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: 2

🧹 Outside diff range and nitpick comments (2)
action.yml (2)

37-40: Add runner compatibility warning in description

The Apptainer installation currently only works on Ubuntu runners. This should be clearly documented in the input description.

   install-apptainer:
-    description: Install Apptainer (true/false)
+    description: Install Apptainer (true/false). Note: Currently only supported on Ubuntu runners.
     required: false
     default: false

45-50: Improve error message clarity and consistency

The error message uses inconsistent quote styles and could be more informative.

-        echo 'Invalid value for "task": "${{ inputs.task }}". Options: "containerize", "run".'
+        echo "Invalid value for 'task': '${{ inputs.task }}'. Valid options are: 'containerize' or 'run'."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8d6dd04 and cebcb23.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
📓 Learnings (1)
action.yml (2)
Learnt from: johanneskoester
PR: snakemake/snakemake-github-action#39
File: action.yml:70-73
Timestamp: 2024-12-09T16:41:37.740Z
Learning: In Snakemake workflows, Snakemake itself provides proper error messages during the containerization step, so additional error handling in the GitHub Action script is unnecessary.
Learnt from: tedil
PR: snakemake/snakemake-github-action#39
File: action.yml:47-48
Timestamp: 2024-12-09T10:52:48.855Z
Learning: In the `action.yml` file for `snakemake-github-action`, since `environment.yaml.template` is part of the repository and is expected to exist, adding error handling to check for its presence is unnecessary.
🔇 Additional comments (2)
action.yml (2)

74-82: 🛠️ Refactor suggestion

Add error handling for conda setup

The conda setup step should be verified to ensure the environment is properly created and activated.

Add a verification step after conda setup:

     - name: Setup conda
       uses: conda-incubator/setup-miniconda@v3
       with:
         channels: conda-forge,bioconda
         channel-priority: strict
         miniforge-version: latest
         environment-file: .snakemake.environment.yaml
         activate-environment: snakemake
+    - name: Verify conda setup
+      shell: bash -el {0}
+      run: |
+        if ! conda info | grep -q "active environment : snakemake"; then
+          echo "Error: Failed to activate conda environment"
+          exit 1
+        fi

Likely invalid or redundant comment.


52-61: 🛠️ Refactor suggestion

Add comprehensive error handling for Apptainer installation

The installation step needs additional error handling for sudo access and installation verification.

     - name: Install Apptainer
       if: ${{ inputs.install-apptainer == 'true' }}
       shell: bash -el {0}
       run: |
         if ! command -v apt-get &> /dev/null; then
           echo "Error: This action currently supports Apptainer installation only on Ubuntu runners"
           exit 1
         fi
+        if ! command -v sudo &> /dev/null; then
+          echo "Error: sudo is required for Apptainer installation"
+          exit 1
+        fi
         sudo apt-get update
-        sudo apt-get install -y apptainer
+        if ! sudo apt-get install -y apptainer; then
+          echo "Error: Failed to install Apptainer"
+          exit 1
+        fi
+        if ! command -v apptainer &> /dev/null; then
+          echo "Error: Apptainer installation verification failed"
+          exit 1
+        fi

Likely invalid or redundant comment.

Comment on lines +33 to +36
snakemake-version:
description: Snakemake version to use. If not specified, uses latest version. Pin a specific version (e.g., '8.25.5') for reproducibility.
required: false
default: '*'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix invalid conda version specifier

The default value '*' is not a valid version specifier for conda packages. When this default is used, the environment creation will fail because the conda dependency specification snakemake ==* is invalid.

Consider these options:

  1. Remove the default value entirely to use the latest version
  2. Use a specific version as default (e.g., '8.25.5')

if: ${{ inputs.task == 'run' }}
shell: bash -el {0}
run: |
snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Quote paths to handle spaces and special characters

The directory and snakefile paths should be quoted to handle spaces and special characters correctly.

-        snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }}
+        snakemake --directory "${{ inputs.directory }}" --snakefile "${{ inputs.snakefile }}" --show-failed-logs ${{ inputs.args }}
-      run: snakemake --directory ${{ inputs.directory }} --snakefile ${{ inputs.snakefile }} --show-failed-logs ${{ inputs.args }} --containerize > Dockerfile
+      run: snakemake --directory "${{ inputs.directory }}" --snakefile "${{ inputs.snakefile }}" --show-failed-logs ${{ inputs.args }} --containerize > Dockerfile

Also applies to: 105-105

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