Skip to content

Normalize include order in workflow compilation#1258

Merged
pelikhan merged 3 commits intomainfrom
copilot/normalize-include-order-in-workflows
Oct 6, 2025
Merged

Normalize include order in workflow compilation#1258
pelikhan merged 3 commits intomainfrom
copilot/normalize-include-order-in-workflows

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 6, 2025

Summary

This PR fixes non-deterministic ordering of included files in generated workflow lock files by ensuring they are sorted alphabetically.

Problem

The include order in generated .lock.yml files was non-deterministic because the compiler was iterating over a Go map to build the list of included files. Since Go maps have random iteration order, this resulted in inconsistent diffs when recompiling workflows, even when no actual changes were made.

For example, dev.lock.yml would sometimes show:

# Resolved workflow manifest:
#   Includes:
#     - shared/use-emojis.md
#     - shared/keep-it-short.md

And other times:

# Resolved workflow manifest:
#   Includes:
#     - shared/keep-it-short.md
#     - shared/use-emojis.md

Solution

Added alphabetical sorting of included files after building the slice from the deduplication map in pkg/workflow/compiler.go:

var allIncludedFiles []string
for file := range allIncludedFilesMap {
    allIncludedFiles = append(allIncludedFiles, file)
}
// Sort files alphabetically to ensure consistent ordering in lock files
sort.Strings(allIncludedFiles)

Changes Made

  • pkg/workflow/compiler.go: Added sort import and alphabetical sorting after line 628
  • pkg/workflow/manifest_test.go: Added TestManifestIncludeOrdering to verify includes are always listed alphabetically
  • .github/workflows/dev.lock.yml: Recompiled with normalized include order (alphabetical: keep-it-short.md before use-emojis.md)

Impact

This is a minimal, cosmetic change that:

  • Only affects the ordering in manifest comments of lock files
  • Has no functional impact on workflow execution
  • Ensures consistent, reproducible builds
  • Makes code reviews easier by eliminating noise from random ordering changes

Validation

✅ All unit tests pass (including new test)
✅ All integration tests pass
✅ Code formatting verified with make fmt
✅ Linting passed with make lint
✅ Full validation with make agent-finish

Original prompt

This section details on the original issue you should resolve

<issue_title>[tidy] Normalize include order in workflow compilation</issue_title>
<issue_description>## Summary

This PR tidies up the codebase by recompiling workflows to normalize the include order in generated lock files.

Changes Made

  • Workflow Recompilation: Ran make recompile to ensure all workflow files are up to date
  • Include Order Normalization: The dev.lock.yml file now has includes listed in consistent alphabetical order in the resolved manifest comment

Validation Steps Completed

  1. Code Formatting: Ran make fmt - no formatting changes needed
  2. Linting: Ran make lint - all linting checks passed
  3. Workflow Recompilation: Ran make recompile - workflows recompiled successfully
  4. Tests: Ran make test - all tests passing (3.017s for main, 4.246s for workflow package)

Details

The only change is in .github/workflows/dev.lock.yml where the include order in the comment header was normalized:

  • shared/use-emojis.md and shared/keep-it-short.md are now listed alphabetically

This is a cosmetic change that ensures consistency in the generated workflow files and doesn't affect functionality.

Impact

  • No Breaking Changes: This is purely a formatting/consistency update
  • No Functional Changes: The workflow behavior remains identical
  • Code Quality: Maintains consistency in generated files

AI generated by Tidy


[!NOTE]
This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download patch artifact

The patch file is available as an artifact (aw.patch) in the workflow run linked above.
To apply the patch locally:

# Download the artifact from the workflow run
gh run download 18287326874 -n aw.patch
# Apply the patch
git am aw.patch

</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1255

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 6, 2025 16:53
- Add alphabetical sorting of included files in compiler
- Add test case to verify alphabetical ordering
- Recompile workflows to apply fix to dev.lock.yml

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Normalize include order in workflow compilation Normalize include order in workflow compilation Oct 6, 2025
Copilot AI requested a review from pelikhan October 6, 2025 17:01
@pelikhan pelikhan marked this pull request as ready for review October 6, 2025 18:14
@pelikhan pelikhan merged commit 4ae99ec into main Oct 6, 2025
12 of 17 checks passed
@pelikhan pelikhan deleted the copilot/normalize-include-order-in-workflows branch October 6, 2025 18:15
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.

[tidy] Normalize include order in workflow compilation

2 participants