Repository navigation
feat(go): find files outside the module from go.mod - #63
Conversation
de979e5 to
69ac267
Compare
A module's build can read files outside its directory through the local replace directives of go.mod. Generation now finds them itself: the go.mod of each replace target go.mod requires, the Go files of every package the module imports from one, transitively, and the files those packages embed, with their assembly, header and syso files. The list becomes the resources member of the generated entrypoint, so the engine loads the files with the module, and the entrypoint builds and runs the module from the module context. Loading resources needs dagger v1.0.0-beta.17, whose CurrentModule has contextDirectory and sourceSubpath. Generation refuses a module that reads files outside its directory on an older engine. A module that reads nothing outside generates as before. The //go:resources directive is removed. Generation refuses a replace target that leaves the workspace root or has no go.mod, an imported package without Go files, and a path through a symlink, at the go.mod line or import that needs it. Signed-off-by: Yves Brissaud <[email protected]>
Pin the target engine to the v1.0.0-beta.17 release, the first that loads entrypoint resources. The include fixture no longer lists its files: generation finds them from its replace directive. The module builds from its context, reuses results across sessions until an included file changes, and runs from another repository and from a git source; generation refuses it on the beta.16 floor. The refusals check covers a replace target that leaves the workspace root, one without go.mod, an imported package without Go files and a target that .gitignore hides. Signed-off-by: Yves Brissaud <[email protected]>
69ac267 to
7f77348
Compare
|
@eunomie I stacked (and merged) #64 on this PR, targeting The confusion was between compiler input selection and function-cache invalidation. Transitive Go imports and embedded files need both: the SDK must provide their current contents, and a cached function result must not skip that work. Receiving a workspace only in the constructor is insufficient if another affected function has no fresh workspace input. In #64, modules with external compiler inputs must take a required This reruns discovery for fresh calls, while unchanged selected file contents can reuse compilation caches. I verified it on the unmodified beta.17 engine: changing only an external embedded file changes So resources are optional for this approach because the workspace contract supplies invalidation. Removing the resource list alone, without that contract, would still allow stale results. The engine rollback and repository module ports will remain separate PRs. |
Rediscover imported packages, local replacements and embedded files for workspace-dependent entrypoint calls. Require a workspace on affected constructors and functions so a cached result cannot skip discovery. Adapt the local package scanner from Yves Brissaud’s PR #63. Co-authored-by: Yves Brissaud <[email protected]> Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
feat(go): discover external compilation inputs from workspaces
Removes
//go:resources(unreleased) and #60's Workspace form. From go.mod, generation lists each required localreplacetarget's go.mod, Go files of packages imported from it, and their//go:embedfiles, erring wide (all build tags, module tests, whole embed directories). dagger v1.0.0-beta.17 (dagger/dagger#14639) loads thisresourceslist into the module context and digest, so edits give fresh results.Refused: a target leaving the workspace root or without go.mod, an imported package without Go files, an invalid or cross-module embed, a symlinked path, and outside files before v1.0.0-beta.17. Other modules generate byte-identical output.
Other outside files are absent at run time; regenerate after changing replaces, imports or embeds.
On dagger/dagger the scan picks 3-7 files for three modules and none for three, replacing
include; all six build offline.All engine-e2e checks pass on the beta.17 pin and floors.
Non-test: +373/-468.
Walkthrough: https://gistpreview.github.io/?f7660f53e9de013b03da2d3255d4f14d