Skip to content

Make actions/setup/ the source of truth for both shell and JavaScript files#7582

Merged
pelikhan merged 5 commits intomainfrom
copilot/update-setup-js-files
Dec 25, 2025
Merged

Make actions/setup/ the source of truth for both shell and JavaScript files#7582
pelikhan merged 5 commits intomainfrom
copilot/update-setup-js-files

Conversation

Copy link
Contributor

Copilot AI commented Dec 25, 2025

Make actions/setup/ the source of truth for both shell and JavaScript files

This PR reverses the sync direction for both shell scripts and JavaScript files, making actions/setup/ the source of truth for both file types that get copied to pkg/workflow/ (not the other way around).

Plan

  • Analyze current architecture
    • Shell scripts embedded via //go:embed from pkg/workflow/sh/
    • JavaScript embedded via //go:embed from pkg/workflow/js/
    • actions/setup/ populated by buildSetupAction function
    • Current flow: pkg/workflow/actions/setup/
  • Update sync direction for shell scripts
    • Create new sync mechanism to copy from actions/setup/sh/pkg/workflow/sh/
    • Add Makefile target for syncing shell scripts
    • Update buildSetupAction to NOT copy shell scripts
  • Update sync direction for JavaScript files
    • Create new sync mechanism to copy from actions/setup/js/pkg/workflow/js/
    • Add Makefile target for syncing JavaScript files
    • Update buildSetupAction to NOT copy JavaScript files
  • Update .gitattributes
    • Mark pkg/workflow/sh/*.sh as linguist-generated
    • Mark pkg/workflow/js/*.cjs as linguist-generated
    • Ensure actions/setup/sh/*.sh and actions/setup/js/*.cjs are NOT marked as generated
  • Update developer documentation
    • Update AGENTS.md with new sync patterns for both file types
    • Update specs/actions.md
    • Add instructions for modifying both shell scripts and JavaScript files
  • Test changes
    • Run sync scripts - ✅ Both working
    • Verify files are synced correctly - ✅ 6 shell + 117 JS files synced
    • Run make build and test - ✅ Build works
    • Run make actions-build - ✅ Recognizes files as source of truth

Changes Made

Makefile:

  • Added sync-shell-scripts target that copies actions/setup/sh/*.shpkg/workflow/sh/
  • Added sync-js-scripts target that copies actions/setup/js/*.cjspkg/workflow/js/
  • Updated build target to depend on both sync targets
  • Added help text for both targets

pkg/cli/actions_build_command.go:

  • Updated buildSetupAction() to NOT copy any files (both JS and shell are now source of truth)
  • Shows count of source files instead of copying them
  • Updated ActionsCleanCommand() to NOT remove js/ or sh/ directories from actions/setup

.gitattributes:

  • Added pkg/workflow/sh/*.sh linguist-generated=true to mark generated shell files
  • Added pkg/workflow/js/*.cjs linguist-generated=true to mark generated JavaScript files
  • Removed actions/setup/js/*.cjs linguist-generated=true (no longer generated)

Documentation:

  • Updated AGENTS.md with:
    • "Shell Script Sync" section explaining shell script pattern
    • "JavaScript File Sync" section explaining JavaScript pattern (now same as shell)
    • Summary showing both patterns use the same approach
  • Updated specs/actions.md with:
    • Detailed sync flow diagram for both file types
    • Sync process explanation for both
    • Instructions for modifying and adding both shell scripts and JavaScript files
    • Updated Key Files section

Sync Patterns

Both file types now follow the SAME pattern:

File Type Source of Truth Generated Sync Command
Shell scripts actions/setup/sh/ pkg/workflow/sh/ make sync-shell-scripts (runs before build)
JavaScript actions/setup/js/ pkg/workflow/js/ make sync-js-scripts (runs before build)

Key points:

  • Both shell scripts and JavaScript live in actions/setup/ as source of truth
  • Both are synced to pkg/workflow/ during make build
  • Both are embedded in the binary via //go:embed
  • Test files (*.test.cjs) remain only in pkg/workflow/js/ and are not synced
  • Actions/setup contains production files, pkg/workflow contains production + tests

Testing Results

All tests passed:

  • make sync-shell-scripts copies 6 shell files correctly
  • make sync-js-scripts copies 117 JavaScript files correctly
  • make build automatically runs both syncs and builds successfully
  • make actions-build works correctly, showing files as source of truth
  • Binary embeds both file types correctly
Original prompt

Make actions/setup/js sh files the source of truth that get copied to pkg/workflow (and not the other way around). Update sync scripts and .gitattributes, developer instructions.


✨ 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 December 25, 2025 01:25
- Add sync-shell-scripts Makefile target to copy from actions/setup/sh/ to pkg/workflow/sh/
- Update build target to run sync-shell-scripts before building binary
- Update buildSetupAction to NOT copy shell scripts (they already exist in actions/setup/sh/)
- Update ActionsCleanCommand to NOT remove sh/ directory (it's source of truth)
- Mark pkg/workflow/sh/*.sh as linguist-generated in .gitattributes
- Update AGENTS.md and specs/actions.md with new sync pattern documentation
- Add Makefile help text for sync-shell-scripts target

Shell scripts now follow the pattern:
  actions/setup/sh/*.sh (source) → pkg/workflow/sh/*.sh (generated) → embedded in binary

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Make setup js files the source of truth Make actions/setup/sh the source of truth for shell scripts Dec 25, 2025
Copilot AI requested a review from pelikhan December 25, 2025 01:32
@pelikhan
Copy link
Contributor

@copilot also source of truth for JavaScript scripts

Add JavaScript File Sync section to clarify that JavaScript files follow the OPPOSITE pattern from shell scripts:
- Shell: actions/setup/sh/ (source) → pkg/workflow/sh/ (generated)
- JavaScript: pkg/workflow/js/ (source) → actions/setup/js/ (generated)

Both have generated files in actions/setup/, but from different source directories.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 25, 2025

@copilot also source of truth for JavaScript scripts

Added JavaScript File Sync section to AGENTS.md documenting both patterns in commit 67a702c:

  • Shell scripts: actions/setup/sh/ (source) → pkg/workflow/sh/ (generated)
  • JavaScript: pkg/workflow/js/ (source) → actions/setup/js/ (generated)

Both have generated files in actions/setup/, but from different source directories. Shell scripts live with the setup action while JavaScript lives with the workflow compiler.

@pelikhan
Copy link
Contributor

@copilot make actions/setup/js also the source of truth for JavaScript scripts

Reverse JavaScript sync direction to match shell scripts pattern:
- Add sync-js-scripts Makefile target to copy from actions/setup/js/ to pkg/workflow/js/
- Update build target to run sync-js-scripts before building binary
- Update buildSetupAction to NOT copy JavaScript files (they're now source of truth)
- Update ActionsCleanCommand to NOT remove js/ directory from actions/setup
- Mark pkg/workflow/js/*.cjs as linguist-generated in .gitattributes
- Remove linguist-generated marking from actions/setup/js/*.cjs
- Update AGENTS.md and specs/actions.md documentation

Both JavaScript and shell scripts now follow the same pattern:
- Shell: actions/setup/sh/ (source) → pkg/workflow/sh/ (generated)
- JavaScript: actions/setup/js/ (source) → pkg/workflow/js/ (generated)

Test files (*.test.cjs) remain only in pkg/workflow/js/ and are not synced.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 25, 2025

@copilot make actions/setup/js also the source of truth for JavaScript scripts

Done in commit 29e2fca. Both JavaScript and shell scripts now follow the same pattern:

  • Shell: actions/setup/sh/ (source) → pkg/workflow/sh/ (generated)
  • JavaScript: actions/setup/js/ (source) → pkg/workflow/js/ (generated)

Both are synced to pkg/workflow/ during make build and embedded in the binary. Test files remain only in pkg/workflow/js/.

Copilot AI changed the title Make actions/setup/sh the source of truth for shell scripts Make actions/setup/ the source of truth for both shell and JavaScript files Dec 25, 2025
@pelikhan pelikhan marked this pull request as ready for review December 25, 2025 10:34
@pelikhan pelikhan merged commit 960d768 into main Dec 25, 2025
123 checks passed
@pelikhan pelikhan deleted the copilot/update-setup-js-files branch December 25, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants