Splat build.ps1 arguments as a hashtable so the CI dispatch inputs work - #1727
Open
Rafael-SOWNet wants to merge 1 commit into
Open
Splat build.ps1 arguments as a hashtable so the CI dispatch inputs work#1727Rafael-SOWNet wants to merge 1 commit into
Rafael-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.