diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index ce629d8..613a2ef 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -4,8 +4,8 @@ Reviewed all ten implementation stages against committed baseline `f04b6097b879bfa96cf188858988141c81933c77` and the agreed feature roadmap. Also reviewed all seven ReleaseKit adoption stages against -`c893e1086a8ebf649b37723c7ddf9a8035f74c8d`. Item 1 retains the completed -configured-startup finding; item 2 is the outstanding ReleaseKit finding. +`c893e1086a8ebf649b37723c7ddf9a8035f74c8d`. Item 1 records the configured-startup +finding and item 2 the ReleaseKit finding. Both findings are completed. ## 1. Make the pure-loader regression test detect accidental bootstrap @@ -49,19 +49,27 @@ framework or retesting ConfigKit's complete secrets policy. ## 2. Allow literal environment values in workflow inspection tests -Status: pending. Priority: P2. Implementation stage: 4. +Status: completed. Priority: P2. Implementation stage: 4. -Location: [doccheck_test.go](../../internal/doccheck/doccheck_test.go#L311), +Completion: the test-only environment mapping now retains native values, and the +release wiring assertion inspects only the required token's `from_secret`. +Both workflow-step fixtures cover string/numeric literals alongside a secret +reference. The regression failed before the fix and passes afterward. A scratch +workflow with added literals passes; changing its required secret name still +fails the specific delivery assertion. Full tests and doccheck race tests pass. +Production code and CI configuration are unchanged. + +Location: [doccheck_test.go](../../internal/doccheck/doccheck_test.go#L342), `woodpeckerStep.Environment` and `TestReleaseWorkflowDelivery`. -The new test-only workflow model decodes every environment value into a struct -containing `from_secret`. Woodpecker also supports ordinary literal environment +The original test-only workflow model decoded every environment value into a +struct containing `from_secret`. Woodpecker also supports ordinary literal environment values, as documented in its [environment reference](https://woodpecker-ci.org/docs/usage/environment). Consequently, adding a valid setting such as -`GOCACHE: /tmp/narratio-go-cache` makes both +`GOCACHE: /tmp/narratio-go-cache` made both `TestWoodpeckerWorkflowDependencies` and `TestReleaseWorkflowDelivery` fail during -YAML decoding. This affects all workflows inspected by the shared helper, not +YAML decoding. This affected all workflows inspected by the shared helper, not just the required release-token mapping. Before this change, unrelated environment fields were ignored. @@ -71,11 +79,11 @@ struct { FromSecret string ... }`; the same focused tests pass on the unchanged candidate. No production or workflow files in Narratio were changed by this diagnostic. -This unintentionally strengthens the CI configuration contract: every inspected -environment value must now have an object shape compatible with a secret +This unintentionally strengthened the CI configuration contract: every inspected +environment value had to have an object shape compatible with a secret reference, even though only the `RELEASEKIT_GITEA_TOKEN` mapping requires -inspection. The current checked-in workflow works, but normal CI configuration -changes would unnecessarily block the default suite and native release +inspection. The checked-in workflow worked, but normal CI configuration +changes could unnecessarily block the default suite and native release validation. Required change: retain environment values in a form that accepts native literal diff --git a/internal/doccheck/doccheck_test.go b/internal/doccheck/doccheck_test.go index 878c125..4f0ac75 100644 --- a/internal/doccheck/doccheck_test.go +++ b/internal/doccheck/doccheck_test.go @@ -176,7 +176,8 @@ func TestReleaseWorkflowDelivery(t *testing.T) { if !ok || deliver.Image != "${GO_IMAGE}" || len(workflow.Matrix.Include) != 1 || workflow.Matrix.Include[0]["GO_IMAGE"] != "golang:1.27.4-bookworm" { t.Fatalf("unexpected delivery image: %+v", workflow) } - if deliver.Environment["RELEASEKIT_GITEA_TOKEN"].FromSecret != "GITEA_RELEASE_TOKEN" { + token, ok := deliver.Environment["RELEASEKIT_GITEA_TOKEN"].(map[string]any) + if !ok || token["from_secret"] != "GITEA_RELEASE_TOKEN" { t.Fatalf("unexpected delivery environment: %+v", deliver.Environment) } commands := strings.Join(deliver.Commands, "\n") @@ -187,8 +188,28 @@ func TestReleaseWorkflowDelivery(t *testing.T) { func TestWorkflowStepShapes(t *testing.T) { for _, input := range []string{ - "steps:\n first:\n image: example\n second:\n depends_on: first\n", - "steps:\n - name: first\n image: example\n - name: second\n depends_on: first\n", + `steps: + first: + image: example + environment: + GOCACHE: /tmp/go-cache + CGO_ENABLED: 0 + TOKEN: + from_secret: example_token + second: + depends_on: first +`, + `steps: + - name: first + image: example + environment: + GOCACHE: /tmp/go-cache + CGO_ENABLED: 0 + TOKEN: + from_secret: example_token + - name: second + depends_on: first +`, } { var workflow woodpeckerWorkflow if err := yaml.Unmarshal([]byte(input), &workflow); err != nil { @@ -197,6 +218,14 @@ func TestWorkflowStepShapes(t *testing.T) { if len(workflow.Steps) != 2 || workflow.Steps["first"].Image != "example" || !workflowDependsOn(workflow.Steps, "second", "first", map[string]bool{}) { t.Fatalf("unexpected decoded steps: %+v", workflow.Steps) } + environment := workflow.Steps["first"].Environment + if environment["GOCACHE"] != "/tmp/go-cache" || environment["CGO_ENABLED"] != 0 { + t.Fatalf("unexpected literal environment values: %+v", environment) + } + token, ok := environment["TOKEN"].(map[string]any) + if !ok || token["from_secret"] != "example_token" { + t.Fatalf("unexpected secret reference: %+v", environment["TOKEN"]) + } } } @@ -309,13 +338,11 @@ func (s *woodpeckerSteps) UnmarshalYAML(value *yaml.Node) error { } type woodpeckerStep struct { - Name string `yaml:"name"` - Environment map[string]struct { - FromSecret string `yaml:"from_secret"` - } `yaml:"environment"` - DependsOn woodpeckerDependencies `yaml:"depends_on"` - Image string `yaml:"image"` - Commands []string `yaml:"commands"` + Name string `yaml:"name"` + Environment map[string]any `yaml:"environment"` + DependsOn woodpeckerDependencies `yaml:"depends_on"` + Image string `yaml:"image"` + Commands []string `yaml:"commands"` } type woodpeckerDependencies []string