[GitHubActions] generator: typed workflow_dispatch inputs (string, boolean, number, choice, environment)#440
Conversation
e7dfff3 to
515326f
Compare
be778e8 to
392af0f
Compare
|
What are the opinions regarding |
392af0f to
0a8ed8f
Compare
Yeah, with TreatWarningsAsErrors it can. I Kept it warning-level as per AGENTS.md rule #2 a non-error I can add a DiagnosticId so it's individually NoWarn-able if you'd prefer. I would probably need to add |
|
I'll try to look into this as soon as possible, promised. Just a bit busy at the moment :-( |
|
@dennisdoomen this one please, I keep wanting to have a look but no spare time at the moment. This has been sitting here for a while now |
|
@ChrisonSimtian No rush, TYT =) |
|
@ChrisonSimtian I added #472 as a suggestion how to handle this. |
Typed, compile-checked declaration surface for workflow_dispatch inputs (string/boolean/number/choice/environment), repeatable on the build class and scoped by workflow. Pure data carriers; not yet consumed.
Collect [GitHubActionsInput] off the build class, scope by workflow name, and fold the legacy OnWorkflowDispatch*Inputs arrays into one model. The trigger writer emits type:/default:/options: (string omits type:, keeping existing output byte-identical). Misconfiguration fails generation loudly via ArgumentException (choice without options, default outside options/non-numeric/ non-boolean, unknown workflow name, options on a non-choice, duplicate or blank names). The legacy arrays are marked [Obsolete] (removal 2027.x.x).
Covers every loud check: choice without options, default outside options, options on a non-choice, non-numeric/non-boolean defaults, unknown workflow name, duplicate names, and blank names.
Three Verify cases: every input kind (dispatch-typed-inputs), Workflows scoping (dispatch-input-scoping), and legacy + typed coexistence (dispatch-legacy-plus-typed). TestGitHubActionsAttribute gains a named-workflow ctor and Inputs/WorkflowNames seams so cases vary inputs without static class-level attributes.
Workflow names are spaces-to-underscores normalized in the ctor, so an input's Workflows scope must be normalized the same way. Without this, scoping to a workflow declared with a space (e.g. "My Workflow") silently dropped the input and validation threw "unknown workflow" for a correctly-spelled name.
Direct trigger-layer tests for the restored obsolete OptionalInputs/RequiredInputs arrays (the attribute path only ever sets Inputs), plus equivalence guards proving the obsolete and new APIs emit byte-identical YAML, and a regression test for spaced-workflow scoping.
Trim the new inline comments to explain why (the test-injection seam, the backward-compatible legacy fold, the spaced-name normalization) rather than restating the code, matching the repo's concise comment style.
Give the four obsolete workflow_dispatch input arrays a DiagnosticId and UrlFormat so consumers building with TreatWarningsAsErrors can NoWarn this one deprecation instead of blanket-disabling CS0618. A custom DiagnosticId replaces CS0618, so the internal bridge and test suppressions are flipped to disable FALLOUTOBS001. Generated YAML is unchanged (compile-time consumer diagnostic only), so no snapshots move. Register FALLOUTOBS001 in the docs/obsolete_apis.md registry.
5716a9d to
92bb537
Compare
Closes #386.
Adds a typed, compile-checked way to declare
workflow_dispatchinputs via a new repeatable[GitHubActionsInput]attribute — replacing the untypedOnWorkflowDispatch*Inputsstring arrays. Supportsstring/boolean/number/choice/environment, per-inputdefault:, choiceoptions:, and per-workflow scoping.How it works
Build.GetType().GetCustomAttributes<…>(), mirroring the existing[AppVeyorSecret]/[TeamCityToken]pattern. Scoped per workflow byWorkflows(empty = every dispatch workflow).stringinputs omittype:, so untyped output stays byte-identical.default:is emitted verbatim (per the issue; consistent withEnv/CheckoutWith).GetImports()still feeds every input, so each stays importable asenv: NAME: ${{ github.event.inputs.NAME }}.Misconfiguration is loud
Generation throws
ArgumentException(not silent) for: choice without options, default outside options, non-numeric/non-boolean default,optionson a non-choice, an unknownWorkflowstarget, and duplicate/blank input names.Backward compatibility
OnWorkflowDispatchOptionalInputs/RequiredInputskeep working, folded into the same model (emit first, untyped). Existing 9 snapshots are byte-identical.[Obsolete]→"Use [GitHubActionsInputAttribute] instead. Removed in 2027.x.x."Strictly additive; the removal is the future breaking change, batched to the year cut.Tests
GitHubActionsInputValidationTest.cs— every loud check.dispatch-typed-inputs(all kinds),dispatch-input-scoping(Workflows filtering),dispatch-legacy-plus-typed(coexistence). The existingdetailed-triggerscase is now the regression guard for the obsolete legacy path.