Skip to content

feat(pipeline): add parameters support to luca run#82

Merged
albertodebortoli merged 6 commits into
mainfrom
feature/pipeline-parameters
May 24, 2026
Merged

feat(pipeline): add parameters support to luca run#82
albertodebortoli merged 6 commits into
mainfrom
feature/pipeline-parameters

Conversation

@albertodebortoli
Copy link
Copy Markdown
Member

@albertodebortoli albertodebortoli commented May 24, 2026

Description

  • Adds a parameters: block to pipeline YAML files, allowing pipelines to declare named input parameters with optional descriptions and default values.
  • Values are supplied at invocation time via --param KEY=VALUE (repeatable) and substituted into task commands using ${name} syntax before execution.
  • A required parameter (no default:) causes a clear error if not supplied via --param.
  • Closes no specific issue; this is new standalone functionality building on the existing luca run pipeline feature.

Design decisions:

  • ParameterResolver is a separate Core component (protocol + struct) following the existing DI pattern, making it independently testable and injectable.
  • Template substitution (${key}) is applied in PipelineRunner just before subprocess execution, keeping the pipeline model immutable.
  • The PipelineRunning protocol gains a parameters: overload via a protocol extension default, so all existing callers remain unchanged.
  • --param values with = in the value (e.g. URLs) are handled correctly via maxSplits: 1.

Type of Change

  • Feature

How Has This Been Tested?

  • Added / updated unit tests
  • Manually tested locally (describe)
  • Tested on macOS (arch: arm64)

New tests added (32 tests across 4 files):

  • PipelineLoaderTestsparameters: block decoded from YAML, nil when absent, full fixture round-trip
  • ParameterResolverTests — 11 tests covering all resolution paths: defaults, required params, unknown params, multiple params, error descriptions
  • PipelineRunnerTests — 4 substitution tests: single token, multiple tokens, empty params (command unchanged), unknown token (left as-is)

Manual smoke tests:

# Default value used
luca run --file pipeline.yml
# → echo "hello, world"

# CLI override
luca run --file pipeline.yml --param greeting=hi
# → echo "hi, world"

# Dry-run shows parameters block with (default)/(override) labels
luca run --file pipeline.yml --dry-run --param greeting=hi

# Unknown param → clear error
luca run --file pipeline.yml --param unknown=val
# → Error: Unknown parameter 'unknown'. It is not declared in the pipeline's parameters block.

# Required param missing → clear error
luca run --file pipeline.yml
# → Error: Required parameter 'upload' was not provided. Pass it with --param upload=<value>.

Full test suite: 444 tests, all passing.

Screenshots / Demo (if applicable)

Pipeline YAML example:

parameters:
  - name: flavor
    description: Build flavor (debug or release)
    default: debug
  - name: upload
    description: Whether to upload the artifact

tasks:
  - name: Build
    command: build --flavor ${flavor}
  - name: Upload
    command: upload --artifact ${upload}
luca run ci --param flavor=release --param upload=true

Checklist

  • Swift code builds locally (swift build)
  • Tests pass locally (swift test)
  • Code style / formatting respected
  • Documentation updated (README / comments)
  • Version / tag alignment considered (if release related)
  • PR title follows conventional style (optional)

CI Considerations

  • Affects build time notably
  • Requires new secrets / env vars
  • Alters release process

Breaking Changes?

  • No

Additional Notes

The when: conditional execution clause (skip tasks based on parameter values) was deliberately deferred to a follow-up iteration to keep this PR focused.

@albertodebortoli albertodebortoli added this to the 0.19.0 milestone May 24, 2026
@albertodebortoli albertodebortoli added the feature New feature or enhancement label May 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@albertodebortoli albertodebortoli marked this pull request as ready for review May 24, 2026 11:56
@albertodebortoli albertodebortoli merged commit acec16e into main May 24, 2026
3 checks passed
@albertodebortoli albertodebortoli deleted the feature/pipeline-parameters branch May 24, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant