Repository navigation
Allow aw.yml packages to install shared JavaScript modules #60536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| //go:build !integration | ||
|
|
||
| package cli | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestValidateManifestResourceDestinationSharedWorkflowScripts(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| for _, destination := range []string{ | ||
| ".github/workflows/shared/runtime.mjs", | ||
| ".github/workflows/shared/lib/runtime.cjs", | ||
| ".github/workflows/shared/runtime.MJS", | ||
| } { | ||
| t.Run(destination, func(t *testing.T) { | ||
| t.Parallel() | ||
| require.NoError(t, validateManifestResourceDestination(destination)) | ||
| assert.True(t, isPackageResourceDestination(destination)) | ||
| }) | ||
| } | ||
|
|
||
| for _, destination := range []string{ | ||
| ".github/workflows/shared/runtime.js", | ||
| ".github/workflows/shared/runtime.json", | ||
| ".github/workflows/shared/runtime.md", | ||
| ".github/workflows/shared/", | ||
| ".github/workflows/shared-adjacent/runtime.mjs", | ||
| } { | ||
| t.Run(destination, func(t *testing.T) { | ||
| t.Parallel() | ||
| require.Error(t, validateManifestResourceDestination(destination)) | ||
| assert.False(t, isPackageResourceDestination(destination)) | ||
| }) | ||
| } | ||
|
|
||
| _, err := parseManifestResourceMapping(map[string]any{ | ||
| "source": "runtime.mjs", | ||
| "destination": ".github/workflows/shared/../runtime.mjs", | ||
| }, "aw.yml") | ||
| require.Error(t, err) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] Good unit coverage for 💡 Suggested additionAdd a variant of @copilot please address this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/codebase-design] The new
shared/case duplicates the extension-matching logic already present inisSharedWorkflowScriptDestination(inadd_package_ownership.go) with slightly different mechanics (strings.HasPrefix+TrimPrefixhere vs.filepath.Clean+ToSlashthere). Two independent implementations of "what counts as a shared JS resource" is a seam that will drift silently if one is updated later.💡 Suggested consolidation
Extract a single helper, e.g.
isSharedWorkflowScriptPath(destination string) (remaining string, ok bool), used by bothvalidateManifestResourceDestinationandisSharedWorkflowScriptDestination/isPackageResourceDestination. This keeps the acceptance rule (prefix +.mjs/.cjssuffix) defined in exactly one place, matching the deep-module principle of a single source of truth for a piece of domain logic reused across the manifest-parsing and ownership-tracking modules.@copilot please address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateManifestResourceDestinationnow delegates toisSharedWorkflowScriptDestinationfor the shared-script acceptance check, so the prefix+extension rule is defined in one place (7730687).