Skip to content

Conversation

@m-jahn
Copy link
Member

@m-jahn m-jahn commented Dec 4, 2025

Summary by CodeRabbit

  • Chores
    • Conda setup now pre-detects an existing Miniconda installation and skips reinstallation when present.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

📝 Walkthrough

Walkthrough

Added a pre-check step that detects an existing Miniconda installation and sets an output; the conda setup step now runs only when that output is 'false' and uses a fixed installation directory.

Changes

Cohort / File(s) Summary
Miniconda install gating
action.yml
Added a step that checks for $HOME/miniconda3 and writes installed=true/false to GITHUB_OUTPUT (steps.check-miniconda.outputs.installed); made the "Setup conda" step conditional on that output being 'false'; passed installation-dir: /home/runner/miniconda3 to conda-incubator/setup-miniconda@v3.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review points:
    • Confirm the file-existence check reliably matches runner paths and sets GITHUB_OUTPUT correctly.
    • Verify the conditional expression uses correct GitHub Actions syntax and string comparison.
    • Ensure installation-dir: /home/runner/miniconda3 is compatible with runner permissions and other workflow steps.

Suggested reviewers

  • johanneskoester
  • dlaehnemann
  • tedil

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a check for existing Miniconda before installation, which directly addresses issue #47 about conda installation failures.
Linked Issues check ✅ Passed The PR implements a solution to check for pre-existing Miniconda installation and skip setup when already installed, which addresses the root cause of issue #47's conda installation failure.
Out of Scope Changes check ✅ Passed All changes in action.yml are directly related to the linked issue #47; the PR adds a conditional check for Miniconda presence and makes setup conditional on this check.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 17d67ca and 772c083.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-12-09T10:52:48.855Z
Learnt from: tedil
Repo: snakemake/snakemake-github-action PR: 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.

Applied to files:

  • action.yml
📚 Learning: 2024-12-09T16:41:37.740Z
Learnt from: johanneskoester
Repo: snakemake/snakemake-github-action PR: 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.

Applied to files:

  • action.yml
⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (3)
action.yml (3)

76-87: Verify alignment between check and setup-miniconda default installation directory.

The installation-dir parameter in setup-miniconda defaults to an empty string, meaning the action will use its default behavior when installing. The check assumes miniconda will be at $HOME/miniconda3, but this relies on setup-miniconda's implicit default matching this path when it downloads/installs. While Miniconda installers default to the user's home directory (e.g., /home/pythonuser/miniconda3), the action's default isn't explicitly documented.

Consider either:

  1. Explicitly setting installation-dir: $HOME/miniconda3 in the Setup conda step (line 93) to guarantee consistent behavior, OR
  2. Verifying with setup-miniconda maintainers that its default installation path matches $HOME/miniconda3 when no installation-dir is provided.

This is especially important for correctness across GitHub-hosted runners and to prevent potential mismatches if setup-miniconda's defaults change.


76-94: AI summary mentions "fixed installation directory" but the code doesn't enforce this explicitly.

The AI-generated summary states: "the conda setup step now uses a fixed installation directory." However, the Setup conda step (lines 88-94) does not include an explicit installation-dir parameter. This suggests the summary may be describing the intended behavior rather than what the code actually enforces. If the fix relies on an implicit default, this should be clarified in documentation or made explicit in the action.yml.


76-87: The check logic and conditional syntax are sound.

The directory existence check (line 80) is reliable for the intended purpose, and the GITHUB_OUTPUT integration (lines 81-84) is correct. The conditional on line 87 properly references the check output. The approach directly addresses the underlying issue from #47: preventing re-installation when miniconda is already present will avoid the symbolic link error.

The fix aligns with the past review feedback and resolves the core problem.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73be4c1 and 2dd07a3.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tedil
Repo: snakemake/snakemake-github-action PR: 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.
⏰ 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). (1)
  • GitHub Check: build

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

🧹 Nitpick comments (1)
action.yml (1)

76-85: Consider a more robust check for a valid Miniconda installation.

While checking for directory existence is an improvement over the previous .condarc approach, it doesn't verify that the installation is valid or functional. A partially failed installation could leave the directory in a corrupt state, causing subsequent steps to fail silently.

For better robustness, consider checking for the conda executable itself:

if [ -x "/home/runner/miniconda3/bin/conda" ]; then
  echo "installed=true" >> $GITHUB_OUTPUT
else
  echo "installed=false" >> $GITHUB_OUTPUT
fi

Alternatively, if the setup-miniconda action sets the $CONDA environment variable on successful installation, you could check that. However, the directory-only check does address the core issue from #47 (preventing re-installation and the symlink error).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1be8a7 and 17d67ca.

📒 Files selected for processing (1)
  • action.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-12-09T10:52:48.855Z
Learnt from: tedil
Repo: snakemake/snakemake-github-action PR: 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.

Applied to files:

  • action.yml
🔇 Additional comments (1)
action.yml (1)

86-95: No issues found — installation-dir is a supported parameter in setup-miniconda@v3.

The installation-dir input is officially supported and documented in the action's v3.x releases. The conditional logic and parameter usage in lines 86–95 are correct.

@m-jahn m-jahn requested a review from ezherman December 4, 2025 10:43
Copy link

@ezherman ezherman left a comment

Choose a reason for hiding this comment

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

Thanks @m-jahn! See my thoughts below on the changes & let me know what you think.

Also, qould it be sensible to add a second run step, and/or a preceding setup-miniconda step, to https://github.com/snakemake/snakemake-github-action/blob/master/.github/workflows/main.yml to ensure we test the feature keeps working going forward?

action.yml Outdated
id: check-miniconda
shell: bash -el {0}
run: |
if [ -d "/home/runner/miniconda3" ]; then
Copy link

Choose a reason for hiding this comment

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

A self‑hosted runner may use a different home path. What about $HOME/miniconda3?

Copy link

Choose a reason for hiding this comment

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

Or to check more generally for a conda installation, e.g. which conda

Copy link
Member Author

Choose a reason for hiding this comment

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

good points. I like the checking for $HOME, if this env var is available on the github runner, it's fine with me.
Just checking with which conda is dangerous though, as the test would succeed for any conda available, not necessarily our one with snakemake.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK so the problem is that $HOME is not available in statements like installation-dir: /home/runner/miniconda3, only in the run: directive of a step. So it would be more complicated to do this, then what we have now.

Copy link

Choose a reason for hiding this comment

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

Why do we need to specify installation-dir? I believe it already defaults to $HOME/miniconda3

fi
- name: Setup conda
if: steps.check-miniconda.outputs.installed == 'false'
Copy link

Choose a reason for hiding this comment

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

If the setup step is skipped, conda won't be set up with .snakemake.environment.yaml as the default environment. Will snakemake then not be available as a consequence? If so, I imagine we need an additional step that installs snakemake into the base environment, or creates a snakemake conda environment, if conda is already available.

Copy link
Member Author

Choose a reason for hiding this comment

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

the idea is that this check is specific for the miniconda setup step. when you run this step twice, as we do in the standard snakemake testing workflow, the env is already present and checked out from the first step, including snakemake. the test in this repo succeeded, meaning it works as expected. that's why I would also not test for any conda installation, as this could be the wrong one, only for the specific miniconda3 one.

Copy link

@ezherman ezherman Dec 4, 2025

Choose a reason for hiding this comment

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

Gotcha yes, I see the containerize step would trigger a second setup miniconda step so there isn't a need for a second run step.

Regarding testing for miniconda3: if the workflow includes setup-miniconda upstream, then I believe the current implementation would not install snakemake. Or am I missing something? For example, if setup-miniconda is used to enable pytest:

  Testing:
    runs-on: ubuntu-latest
    needs:
      - Linting
      - Formatting
    steps:
      - uses: actions/checkout@v4

      - uses: conda-incubator/setup-miniconda@v3
        with:
          miniforge-version: latest
          use-mamba: true
          environment-file: .test/envs/test.yaml

      - name: Test workflow python functions with pytest
        shell: bash -el {0}
        run: |
          pytest workflow/tests/*.py

      - name: Test workflow
        uses: snakemake/[email protected]
        with:
          directory: .test
          snakefile: workflow/Snakefile
          args: "--use-conda --show-failed-logs --cores 2 --conda-cleanup-pkgs cache"

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. This is an edge case. A custom workflow with another setup-miniconda@v3 step would skip installing snakemake and fail. Is this a risk we can take (honest question)? In the end, the github action needs to work mainly for the test workflows, and it does so by wrapping several steps into a single one. In the example you posted, one would need to work around this by replacing the snakemake action with some selected steps.

Copy link

Choose a reason for hiding this comment

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

It's actually an important use-case, in my opinion. An extension is of this is to follow the snakemake-github-action with integration tests, which would not be possible if the action needs to be run in a separate job. Why limit the action to only operate in jobs that only use the snakemake github action?

What could go wrong by checking for a conda installation more generally, and updating/installing the snakemake environment if i conda exists?

Copy link
Member Author

Choose a reason for hiding this comment

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

An extension of this is to follow the snakemake-github-action with integration tests, which would not be possible if the action needs to be run in a separate job

You can do this if you first run the snakemake action that installs miniconda, then the tests. The other way around as the example above won't work.

What could go wrong by checking for a conda installation more generally, and updating/installing the snakemake environment if i conda exists?

Possible, but then the action steps will change quite a lot. One would need different checks, like A) is any conda available? If not install miniconda + snakemake env as before. If yes, is snakemake available? If not create only env and activate, not using the setup-miniconda action. And checking for conda does not make sure that mamba is available (don't know what consequences that would have). At least current conda should also use the libmamba solver so should be equally fast.
If you have a good solution in mind don't hesitate to make a commit!

action.yml Outdated
miniforge-version: latest
environment-file: .snakemake.environment.yaml
activate-environment: snakemake
installation-dir: /home/runner/miniconda3
Copy link

Choose a reason for hiding this comment

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

Here too, I believe $HOME/miniconda3 would be safer in case a self-hosted runner is used. Although is this parameter needed, which points to the default path, if we've already checked for a conda installation?

@m-jahn m-jahn marked this pull request as draft December 5, 2025 14:14
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.

test actions currently fail with a conda error due to multiple miniconda installs

2 participants