fix(v3): run root Taskfile for build/package/dev so customisations are honoured (#5615)#5617
fix(v3): run root Taskfile for build/package/dev so customisations are honoured (#5615)#5617leaanthony wants to merge 1 commit into
Conversation
…e honoured (#5615) wails3 build/dev/package rewrote the verb to a platform-namespaced task (build -> {{OS}}:build) unconditionally, bypassing the project's root Taskfile.yml. Any user customisation to the root build/package/run task was silently ignored. The root tasks now dispatch to the platform Taskfile via a {{.GOOS}} variable (defaulting to the host OS), and the CLI runs the root task, passing GOOS/ARCH through as variables. This honours root-Taskfile customisations for both native and cross-compilation builds. sign, which has no root task, still targets the platform task directly. The experimental wake runner keeps using the concrete platform task name.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughThe PR adds a ChangesRoot Taskfile GOOS dispatch
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR adjusts the v3 CLI’s task dispatch so wails3 build and wails3 package execute the project’s root Taskfile.yml tasks (allowing user customisations there to run), while still dispatching into platform-specific Taskfiles via a new GOOS variable in the scaffolded Taskfile template.
Changes:
- Update the root Taskfile template to dispatch
build/package/runvia{{.GOOS}}(with a default to host OS). - Change the CLI task wrapper to run root tasks for
build/packageand passGOOS/ARCHthrough as Task variables. - Add/adjust unit tests to cover host vs cross dispatch, and template regression coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| v3/UNRELEASED_CHANGELOG.md | Adds a changelog entry describing the task dispatch fix (currently mentions dev, which appears inaccurate). |
| v3/internal/templates/taskfile_template_test.go | Adds a regression test ensuring the Taskfile template dispatches via {{.GOOS}}. |
| v3/internal/templates/_common/Taskfile.tmpl.yml | Introduces a GOOS var and updates root tasks to dispatch to {{.GOOS}}:<verb>. |
| v3/internal/commands/task_wrapper.go | Routes build/package through root tasks and forwards GOOS/ARCH as variables. |
| v3/internal/commands/task_wrapper_test.go | Updates/extends tests to validate new wrapper behavior and variable passthrough. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // rootDispatchTasks are the verbs that have a top-level task in the generated | ||
| // root Taskfile which dispatches to the platform-specific task via the GOOS | ||
| // variable (e.g. `build` -> `{{.GOOS}}:build`). For these we run the root task | ||
| // and pass GOOS as a variable, so user customisations in the root Taskfile are | ||
| // honoured for both native and cross-compilation builds. Verbs absent here | ||
| // (e.g. `sign`, which only exists per-platform) always target the | ||
| // platform-specific task directly. | ||
| var rootDispatchTasks = map[string]bool{ | ||
| "build": true, | ||
| "package": true, | ||
| } |
|
|
||
| ## Fixed | ||
| <!-- Bug fixes --> | ||
| - `wails3 build`/`dev`/`package` now run the project's root `Taskfile.yml` task instead of bypassing it with an OS-prefixed task, so customisations to the root `build`/`package`/`run` tasks are honoured. The root tasks dispatch to the platform Taskfile via a new `{{.GOOS}}` variable, which works for both native and cross-compilation builds (#5615) |
| // TestCommonTaskfileDispatchesViaGOOS guards the fix for #5615: the root | ||
| // build/package/run tasks must dispatch to the platform Taskfile via the GOOS | ||
| // variable (so `wails3 build`/`dev`/`package` run the root task and honour any | ||
| // customisations there, for both native and cross builds), rather than the | ||
| // built-in {{OS}} which the CLI used to bypass with an OS-prefixed task name. |
Description
Fixes #5615.
wails3 build/dev/packagewere silently bypassing the project's rootTaskfile.yml. Intask_wrapper.go, the CLI rewrote the verb to a platform-namespaced task (build→linux:build) unconditionally — because the target OS defaults toruntime.GOOS, which is always a valid platform. So every invocation jumped straight into the platform namespace, and any customisation a user made to the rootbuild/package/runtask never ran. Editing the root Taskfile (the file users are meant to customise) appeared to have no effect, which is what triggered the report.Fix
The root tasks now dispatch to the platform Taskfile via a
{{.GOOS}}variable instead of the{{OS}}built-in:The CLI now runs the root task (
build/package) and passesGOOS/ARCHthrough as variables, rather than targeting the platform-prefixed task directly. This means root-Taskfile customisations are honoured for both native and cross-compilation builds:wails3 build→ rootbuild→{{.GOOS}}= host →darwin:build(root task runs)wails3 build GOOS=windows→ rootbuild(withGOOS=windows) →windows:build(root task still runs)sign, which has no root task, still targets the platform-specific task directly. The experimentalwakerunner keeps using the concrete platform task name (unchanged).Verification
task_wrapper_test.go(host & cross dispatch,sign, GOOS arg/env precedence — host-relative so they pass on any platform) and a template regression testTestCommonTaskfileDispatchesViaGOOS.wails3 init -t react: a marker added to the rootbuildtask now runs for bothwails3 buildandwails3 build GOOS=windows, then dispatches to the correct platform task. (Confirmed via the literalwails3 devpath on Linux too.)Projects generated before this change have a root Taskfile that still uses
{{OS}}:buildand noGOOSvar. With the new CLI:wails3 build GOOS=…) on such projects will build for the host OS, because the old root task ignores the passedGOOSvar. Those projects need to update their rootTaskfile.ymlto use{{.GOOS}}(or be re-initialised) to cross-compile. Since this targets v3 alpha, calling this out for awareness.Note on the original report
I could not reproduce the reporter's literal symptom — a fresh
wails3 init -t react+wails3 devbuilt successfully on both Linux and macOS. This PR fixes the root-Taskfile bypass identified during triage (the behaviour @leaanthony pointed to). If @its-ernest hit an actual compile/task error, that may be separate — worth confirming with their exacttaskoutput before closing.Summary by CodeRabbit