Skip to content

fix: preserve HCL-defined job order in parse direction YAML output#7

Merged
jccguimaraes merged 6 commits into
mainfrom
fix/jobs-order
Apr 1, 2026
Merged

fix: preserve HCL-defined job order in parse direction YAML output#7
jccguimaraes merged 6 commits into
mainfrom
fix/jobs-order

Conversation

@jccguimaraes
Copy link
Copy Markdown
Contributor

No description provided.

  Replace the goccy/go-yaml parse in parseYAMLDocument with a single
  yaml.v3 Node API pass: yamlv3.Unmarshal into *Node, then node.Decode
  for map[string]any and node.Content walk for source key order.
  Eliminates the prior double-parse and keeps both views consistent.

  Also move jobOrder from YAMLDocument struct to an explicit parameter
  on workflowToHCL, and add a clear presence-check error in
  buildWorkflowJobIndex when an ordered job name is absent from the map.
  Jobs declared as `jobs = [job.test, job.build, job.deploy]` now appear
  in that exact order in the generated YAML instead of being sorted
  alphabetically by the generic map serialiser.

  The parser stores the ref order as a `jobsOrder` sentinel key
  alongside
  the `jobs` map in the workflow body. The YAML serialiser
  (`workflowMapNode`) extracts the sentinel, writes jobs in the declared
  order via the new `appendOrderedJobsMap` helper, then falls back to
  sorted order for any jobs not covered.

  Added a byte-exact snapshot test with three jobs in non-alphabetical
  order (`test`, `build`, `deploy`) to pin this behaviour.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

Go test coverage: 65.0% for commit 8e924c4
⚠️ 1 of 19 packages have zero coverage.
  • github.com/yldio/cinzel/internal/test
View coverage for all packages
# Package Name                                     | Coverage
+ github.com/yldio/cinzel                          |    80.0%
+ github.com/yldio/cinzel/internal/ai              |    46.8%
+ github.com/yldio/cinzel/internal/cinzelerror     |    18.2%
+ github.com/yldio/cinzel/internal/command         |    39.5%
+ github.com/yldio/cinzel/internal/filereader      |    50.0%
+ github.com/yldio/cinzel/internal/filewriter      |    88.9%
+ github.com/yldio/cinzel/internal/fsutil          |    68.0%
+ github.com/yldio/cinzel/internal/hclparser       |    62.7%
+ github.com/yldio/cinzel/internal/maputil         |    93.3%
+ github.com/yldio/cinzel/internal/naming          |    93.1%
+ github.com/yldio/cinzel/internal/pin             |    58.0%
- github.com/yldio/cinzel/internal/test            |     0.0%
+ github.com/yldio/cinzel/internal/yamlwriter      |    88.9%
+ github.com/yldio/cinzel/provider/github          |    69.4%
+ github.com/yldio/cinzel/provider/github/action   |    82.1%
+ github.com/yldio/cinzel/provider/github/job      |    92.6%
+ github.com/yldio/cinzel/provider/github/step     |    69.3%
+ github.com/yldio/cinzel/provider/github/workflow |    85.6%
+ github.com/yldio/cinzel/provider/gitlab          |    63.5%

@jccguimaraes jccguimaraes merged commit 8d27137 into main Apr 1, 2026
5 checks passed
@jccguimaraes jccguimaraes deleted the fix/jobs-order branch April 1, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant