Splat build.ps1 arguments as a hashtable so the CI dispatch inputs work - #1727
Splat build.ps1 arguments as a hashtable so the CI dispatch inputs work#1727Rafael-SOWNet wants to merge 1 commit into
Conversation
The workflow_dispatch inputs have no effect except to break the run. Array splatting binds positionally, and build.ps1 declares only switches with no positional parameters, so any non-default input fails the build immediately: build.ps1: A positional parameter cannot be found that accepts argument '-SkipCoverage'. Only the all-defaults path works today, because that leaves the array empty. Splatting a hashtable binds by parameter name instead. This is invisible on push and pull_request, which never populate the inputs, so it only bites someone dispatching the workflow by hand -- which is also the only way to get a matrix run on a branch with no pull request open.
|
CI evidence, since this PR shows no checks (first-time-contributor gate) — and in this case the The bug needs at least one input set to a non-default value. With everything left at its default Before — current After — this PR's branch ( The part worth more than the green tick: in the passing run the Both runs are Two notes on the change itself:
|
The problem
CI Build'sworkflow_dispatchinputs cannot be used. Setting any of them tofalsefails therun immediately:
$buildArgumentsis an array, and PowerShell array splatting binds positionally.Build/build.ps1declares only switches (SkipTests,SkipCoverage,SkipPack,SkipArchive) and no positional parameters, so the first element has nowhere to bind.Only the all-defaults path works, because that leaves the array empty and splats nothing. That
is why
pushandpull_requesthave never hit this — neither populates the inputs, so everyvalue resolves
trueand every branch of theifis skipped.The fix
Splat a hashtable instead, which binds by parameter name.
Why it is worth fixing
Beyond the inputs doing what they say: dispatching this workflow by hand is the only way to get
a full matrix run on a branch that has no pull request open, and it is the practical way for a
first-time contributor to produce CI evidence while
pull_requestruns are gated behindapproval. Right now that path only works if you want the slowest possible run — full coverage,
pack and archive — because asking to skip any of it is what breaks it.
Validation
Same workflow, same inputs, before and after. Both runs on my fork.
Before —
ci.ymlexactly as it is onmaster, dispatched withrun_tests=true, collect_coverage=false, pack_nugets=false, upload_artifacts=false:https://github.com/Rafael-SOWNet/UnitsNet/actions/runs/31124240783 — failure, at
Build selected components, with the message quoted above.After — this branch, identical inputs:
https://github.com/Rafael-SOWNet/UnitsNet/actions/runs/31136388644 — success.
Upload coverage to Codecov,Upload artifactsandUpload NuGet packageswere all skipped,which is what the inputs asked for and what previously could not be expressed.
What this does not do
No change to
Build/build.ps1, to the default behaviour ofpushorpull_request, or to anyother workflow.
.github/workflows/unitsnet-modular-ci.ymluses a plainrun:and isunaffected.