Skip to content

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

Open
ntnn19 wants to merge 1 commit into
snakemake:mainfrom
ntnn19:feature/deploy-workflow-commit-flag
Open

feat: add --commit flag to deploy-workflow#127
ntnn19 wants to merge 1 commit into
snakemake:mainfrom
ntnn19:feature/deploy-workflow-commit-flag

Conversation

@ntnn19

@ntnn19 ntnn19 commented Jul 14, 2026

Copy link
Copy Markdown

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 at an exact Git commit using the --commit option.
    • Generated workflow declarations now record the pinned commit for reproducible deployments.
    • Commit pins take precedence over branch or tag references when both are provided.
  • Documentation

    • Added guidance and examples for using commit-pinned deployments.

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 Change Stack

📝 Walkthrough

Walkthrough

Workflow deployment now accepts an optional commit SHA, prioritizes it for checkout and generated module declarations, documents its precedence with branch and tag options, and adds an integration test for the pinned declaration.

Changes

Commit-pinned deployment

Layer / File(s) Summary
CLI and deployment API contracts
snakedeploy/client.py, snakedeploy/deploy.py
The CLI and public deployment API accept and forward an optional commit value.
Commit checkout and source declaration
snakedeploy/deploy.py, snakedeploy/providers.py
Deployments check out the explicit commit, and generated provider declarations prefer commit over tag or branch.
Usage documentation and integration coverage
docs/workflow_users/workflow_deployment.rst, tests/test_client.sh
Documentation describes commit precedence, and an integration test verifies the generated Snakefile contains the commit reference.

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 commit, branch, and tag
  Deployer->>Repository: checkout commit
  Deployer->>Provider: request source declaration with commit
  Provider-->>Deployer: return commit-pinned declaration
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a --commit flag to deploy-workflow.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Comment on lines +92 to +98
deploy_workflow_parser.add_argument(
"--commit",
help="Git commit (SHA) to deploy from and pin the resulting module to. "
"Can be combined with --branch or --tag to determine which ref to "
"clone/checkout locally, while pinning the generated Snakefile module "
"declaration to this exact commit.",
)

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

Make precedence documentation consistent with implementation. When commit is supplied, it takes precedence over branch/tag for checkout and generated declarations.

  • snakedeploy/client.py#L92-L98: update the CLI help text.
  • snakedeploy/deploy.py#L283-L284: update the public API docstring.
📍 Affects 2 files
  • snakedeploy/client.py#L92-L98 (this comment)
  • snakedeploy/deploy.py#L283-L284
🤖 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/client.py` around lines 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.

Comment thread snakedeploy/deploy.py
Comment on lines +261 to 262
commit: Optional[str] = None,
force=False,

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 | ⚡ Quick win

Preserve positional compatibility when adding commit. Existing callers can silently bind their force argument to the new commit parameter.

  • snakedeploy/deploy.py#L261-L262: keep force before commit in the public deploy() signature.
  • snakedeploy/deploy.py#L21-L24: apply the same ordering to WorkflowDeployer.__init__.
📍 Affects 1 file
  • snakedeploy/deploy.py#L261-L262 (this comment)
  • snakedeploy/deploy.py#L21-L24
🤖 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/deploy.py` around lines 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.

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

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.

1 participant