Skip to content

feat: add --commit flag to deploy-workflow - #127

Merged
johanneskoester merged 5 commits into
snakemake:mainfrom
ntnn19:feature/deploy-workflow-commit-flag
Sep 22, 2026
Merged

johanneskoester merged 5 commits into
snakemake:mainfrom
ntnn19:feature/deploy-workflow-commit-flag

Conversation

@ntnn19

@ntnn19 ntnn19 commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

snakedeploy deploy-workflow previously only allowed pinning a workflow deployment to a --tag or --branch, even though the underlying Snakemake github() helper also supports pinning to an exact commit via commit=. This meant users wanting full reproducibility (pinning to a specific commit rather than a potentially moving branch, or a repo with no tags) had to manually edit the generated Snakefile after deployment.

This adds a --commit option to the deploy-workflow subcommand:

  • --commit can be used standalone, or combined with --branch/--tag.
  • When given, it takes precedence for both the local checkout performed during deployment and the ref written into the generated module's github(...) call (commit="" instead of tag=/branch=).
  • The local/Gitlab providers were updated accordingly, and a new test case was added to tests/test_client.sh.
  • Docs in workflow_deployment.rst updated to document the new flag.

LLM usage disclosure: LLM tools were used to assist in generating parts of the code and PR description. The resulting changes were manually reviewed, edited, and tested by the author before submission.

Summary by CodeRabbit

  • New Features

    • Added support for deploying workflows from an exact Git commit using --commit.
    • Generated workflow declarations now record the pinned commit for reproducible deployments.
    • Deployment references are mutually exclusive: exactly one of --commit, --tag, or --branch must be provided.
    • Invalid combinations of deployment references are now rejected automatically.
  • Documentation

    • Updated deployment guidance and examples to show commit-pinned deployments and clarify reference selection requirements.

snakedeploy deploy-workflow previously only allowed pinning a workflow
deployment to a --tag or --branch, even though the underlying
Snakemake github() helper also supports pinning to an exact commit
via commit=. This meant users wanting full reproducibility (pinning
to a specific commit rather than a potentially moving branch, or a
repo with no tags) had to manually edit the generated Snakefile
after deployment.

This adds a --commit option to the deploy-workflow subcommand:

- --commit can be used standalone, or combined with --branch/--tag.
- When given, it takes precedence for both the local checkout
  performed during deployment and the ref written into the
  generated module's github(...) call (commit="<sha>" instead of
  tag=/branch=).
- The local/Gitlab providers were updated accordingly, and a new
  test case was added to tests/test_client.sh.
- Docs in workflow_deployment.rst updated to document the new flag.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: fe687ff9-b66b-4688-bd7f-1f35997bdb82

📥 Commits

Reviewing files that changed from the base of the PR and between c98520d and 90b154a.

📒 Files selected for processing (3)
  • snakedeploy/client.py
  • snakedeploy/deploy.py
  • snakedeploy/providers.py
 ______________________________
< Here's looking at you, code. >
 ------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 6f898c11-6277-45b1-98a7-15e0f7410857

📥 Commits

Reviewing files that changed from the base of the PR and between 0e1e13f and c98520d.

📒 Files selected for processing (5)
  • docs/workflow_users/workflow_deployment.rst
  • snakedeploy/client.py
  • snakedeploy/deploy.py
  • snakedeploy/providers.py
  • tests/test_client.sh
💤 Files with no reviewable changes (1)
  • snakedeploy/providers.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/workflow_users/workflow_deployment.rst
  • snakedeploy/deploy.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Workflow deployment now requires exactly one of --tag, --branch, or --commit. A commit is propagated to repository checkout and generated source declarations. Documentation and integration tests reflect the exclusive ref selection.

Changes

Commit-pinned deployment

Layer / File(s) Summary
CLI and deployment API contracts
snakedeploy/client.py, snakedeploy/deploy.py
The CLI requires exactly one ref and forwards commit through the public deployment API.
Commit checkout and source declaration
snakedeploy/deploy.py, snakedeploy/providers.py
The deployer checks out the commit, and provider declarations accept it for generated module references.
Usage documentation and integration coverage
docs/workflow_users/workflow_deployment.rst, tests/test_client.sh
Documentation describes mutually exclusive ref options, and the integration test checks that branch-plus-commit input fails.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as deploy-workflow CLI
  participant Deployer as WorkflowDeployer
  participant Repository as Git repository
  participant Provider as Github provider
  CLI->>Deployer: pass selected commit
  Deployer->>Repository: checkout commit
  Deployer->>Provider: request source declaration with commit
  Provider-->>Deployer: return commit-based declaration
Loading

Suggested reviewers: johanneskoester

Merge Risk: ⚪ Minimal · up to c9852

Workflow deployments can now be pinned to a commit while tag, branch, and commit selections are enforced as mutually exclusive. The checkout, generated source declaration, documentation, and validation coverage are aligned, with no remaining merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 4 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding the --commit flag to deploy-workflow.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@ntnn19 ntnn19 changed the title Add --commit flag to deploy-workflow feat: Add --commit flag to deploy-workflow Jul 14, 2026
@ntnn19 ntnn19 changed the title feat: Add --commit flag to deploy-workflow feat: add --commit flag to deploy-workflow Jul 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
tests/test_client.sh (1)

54-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test checkout precedence, not only declaration rendering.

The current assertion would pass even if checkout still used the branch or skipped commit checkout. Add a commit-only invocation and verify a copied file or focused unit test reflects the requested commit.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_client.sh` around lines 54 - 55, The deploy-workflow test
currently verifies only that the commit is rendered in the Snakefile, not that
checkout uses it. Extend the test around the existing runTest invocations with a
commit-only deployment and assert that a copied file or focused unit test
matches the requested commit, ensuring commit checkout takes precedence over the
branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@snakedeploy/client.py`:
- Around line 92-98: The precedence documentation must state that commit
overrides branch and tag for both checkout and generated declarations. Update
the --commit help text in snakedeploy/client.py lines 92-98 and the public API
docstring in snakedeploy/deploy.py lines 283-284 to describe this precedence
consistently.

In `@snakedeploy/deploy.py`:
- Around line 261-262: Preserve positional API compatibility by placing the
existing force parameter before the newly added commit parameter in both
deploy() and WorkflowDeployer.__init__. Update snakedeploy/deploy.py lines
261-262 and 21-24 respectively; keep all other parameter behavior unchanged.

In `@snakedeploy/providers.py`:
- Around line 77-80: Ensure the Local provider does not silently ignore a
requested commit: either implement commit-aware checkout in Local.checkout or
explicitly reject --commit for Local before deployment proceeds. Update the
related get_source_file_declaration flow only as needed to preserve the
requested snapshot behavior.

In `@tests/test_client.sh`:
- Around line 54-55: Quote the new shell expansions in the deploy-workflow test:
update the commit argument to use "${commit_sha}" and the Snakefile path passed
to grep to use "${dest}/workflow/Snakefile", preserving the existing runTest
behavior.

---

Nitpick comments:
In `@tests/test_client.sh`:
- Around line 54-55: The deploy-workflow test currently verifies only that the
commit is rendered in the Snakefile, not that checkout uses it. Extend the test
around the existing runTest invocations with a commit-only deployment and assert
that a copied file or focused unit test matches the requested commit, ensuring
commit checkout takes precedence over the branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d53391b-09b9-4175-99a4-903703d0f657

📥 Commits

Reviewing files that changed from the base of the PR and between fb1ea2b and 0e1e13f.

📒 Files selected for processing (5)
  • docs/workflow_users/workflow_deployment.rst
  • snakedeploy/client.py
  • snakedeploy/deploy.py
  • snakedeploy/providers.py
  • tests/test_client.sh

Comment thread snakedeploy/client.py Outdated
Comment thread snakedeploy/deploy.py Outdated
Comment thread snakedeploy/providers.py
Comment on lines +77 to 80
def get_source_file_declaration(
self, path: str, tag: str, branch: str, commit: Optional[str] = None
):
relative_path = path.replace(self.source_url, "").strip(os.sep)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Do not silently ignore --commit for local repositories.

repo_clone invokes provider.checkout(..., commit), but Local.checkout() is a no-op and this declaration cannot encode the commit. A local deployment therefore copies the current working tree rather than the requested snapshot. Either implement commit checkout for Git-backed local sources or reject --commit for the Local provider.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@snakedeploy/providers.py` around lines 77 - 80, Ensure the Local provider
does not silently ignore a requested commit: either implement commit-aware
checkout in Local.checkout or explicitly reject --commit for Local before
deployment proceeds. Update the related get_source_file_declaration flow only as
needed to preserve the requested snapshot behavior.

Comment thread tests/test_client.sh Outdated
Comment on lines +54 to +55
runTest 0 $output snakedeploy deploy-workflow "${repo}" "${dest}" --branch master --commit ${commit_sha} --name dna-seq-commit
runTest 0 $output grep "commit=\"${commit_sha}\"" ${dest}/workflow/Snakefile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Quote the new shell variables.

commit_sha and the Snakefile path are expanded unquoted, allowing word splitting or glob expansion. Use "${commit_sha}" and "${dest}/workflow/Snakefile".

🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 54-54: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 55-55: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 55-55: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_client.sh` around lines 54 - 55, Quote the new shell expansions in
the deploy-workflow test: update the commit argument to use "${commit_sha}" and
the Snakefile path passed to grep to use "${dest}/workflow/Snakefile",
preserving the existing runTest behavior.

Source: Linters/SAST tools

Comment thread docs/workflow_users/workflow_deployment.rst Outdated
@johanneskoester
johanneskoester merged commit 9bb3cc7 into snakemake:main Sep 22, 2026
4 checks passed
@johanneskoester

Copy link
Copy Markdown
Contributor

Thank you so much!

johanneskoester pushed a commit that referenced this pull request Sep 22, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.17.0](v0.16.2...v0.17.0)
(2026-09-22)


### Features

* add --commit flag to deploy-workflow
([#127](#127))
([9bb3cc7](9bb3cc7))


### Bug Fixes

* empty PRs for when meta wrappers have no changes
([#128](#128))
([54d8c48](54d8c48))
* Fix --version
([#125](#125))
([fb1ea2b](fb1ea2b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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