Skip to content

feat: migrate mage gobuild to a mise task - #1223

Open
malept wants to merge 7 commits into
mainfrom
malept-claude/nice-clarke-monr0l
Open

malept wants to merge 7 commits into
mainfrom
malept-claude/nice-clarke-monr0l

Conversation

@malept

@malept malept commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What this PR does / why we need it

Moves mage gobuild to a mise task so that building a service's binary no longer depends on mage. This is part of retiring mage in favor of mise tasks, continuing the same migration already done for version and docker-build.

Jira ID

DT-4635

Notes for your reviewers

  • Gobuild turned out to be fully shell-portable, so no Go code was added; Gobuild and the helpers only it used (readSecret, getAppVersion, getAppName, getLDFlagsStringFromMap) are removed from the mage codebase.
  • make gobuild becomes a deprecation-warning wrapper around mise run build:go, matching the existing version/docker-build pattern. make build and make devspace call the mise task directly so they don't pay that warning's delay.
  • The CircleCI cache-warming job now calls mise run build:go directly instead of through make build. This means that job no longer runs a repository's pre-build:: hooks (e.g. codegen); that's acceptable since the job only exists to warm the Go build/module cache, not to produce a real build.
  • CGO_ENABLED detection is deduplicated into a new get_cgo_enabled helper in shell/lib/bootstrap.sh, used by both shell/cgo-enabled.sh and the new task, so it computes a correct default even for callers (like the CircleCI job above) that bypass the Makefile.
  • Secret reads (honeycomb/apiKey, telefork/api-keys/default) are best-effort, matching the old mage behavior: a warning is logged and the build continues if either is missing.
  • Two intentional behavior changes from reusing existing shared helpers instead of the old mage-specific Go code:
    • The embedded version string now comes from get_app_version (same as the version task), which doesn't fall back to the commit SHA the way the old getAppVersion() did with git describe --always. A repo with no version tags now embeds v0.0.0-dev instead of the SHA.
    • The app name used for the local secret lookup path (~/.outreach/<app>/...) now comes from service.yaml's name field (via get_app_name), not the current directory's basename. This also matches devconfig.sh, which already writes those secrets under get_app_name's value, so it's an alignment fix for repos checked out under a different directory name.
  • Manually verified end-to-end in a container matching CI's image: built cmd/devbase via the new task, ran the resulting binary, and confirmed the embedded version/ldflags are correct with no stray output leaking into them.

🤖 Generated with Claude Code

https://claude.ai/code/session_014x7tHL2QpGrPgZDfzLKXyp

Move mage's `Gobuild` target to a new mise task, `.mise/tasks/build/go`,
as plain shell backed by shell/lib helpers (get_app_version,
get_cgo_enabled, read_local_secret, get_box_field) -- the same pattern
already used for the `version` and `docker-build` migrations. No Go
code was needed for this migration, so `Gobuild` and the helpers only
it used (readSecret, getAppVersion, getAppName,
getLDFlagsStringFromMap) are removed from the mage codebase.

`make gobuild` becomes a deprecation-warning wrapper around
`mise run build:go`, matching the existing version/docker-build
pattern; `make build` and `make devspace` call the mise task directly
so they don't pay that warning's delay. The CircleCI cache-warming job
now calls `mise run build:go` directly instead of through `make build`.

CGO_ENABLED detection is deduplicated into a new
shell/lib/bootstrap.sh helper, get_cgo_enabled, used by both
shell/cgo-enabled.sh and the new task.

Refs: DT-4635

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014x7tHL2QpGrPgZDfzLKXyp
Match the convention used by other executable shell entrypoints
(e.g. .mise/tasks/stencil/post/circleci-orb-sync) by sourcing
shell/lib/shell.sh and calling ensure_bash_5_or_greater before running
any logic.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014x7tHL2QpGrPgZDfzLKXyp
@malept malept changed the title refactor: migrate Go build from Mage to mise task feat: migrate mage gobuild to a mise task Sep 30, 2026
@malept malept changed the title feat: migrate mage gobuild to a mise task feat: migrate mage gobuild to a mise task Sep 30, 2026
@getoutreach-ci-2

Copy link
Copy Markdown

Link to code coverage report (posted by coverbot 🤖)

@malept
malept marked this pull request as ready for review October 2, 2026 01:56
@malept
malept requested a review from a team October 2, 2026 01:56

@marnagy marnagy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Go changes only remove code, and go vet -tags mage on root/ passes with Go 1.25.7. The comments below are on the new shell task.

suggestion (non-blocking): Add a bats test for .mise/tasks/build/go.

The test should cover how the build path is selected and how the ldflags and env are assembled. At the moment, only the helper functions have tests.

praise: The dead mage helpers are fully removed, and the new get_cgo_enabled and read_local_secret helpers have tests.

  • Generated using AI

Comment thread .mise/tasks/build/go Resolved
Comment thread .mise/tasks/build/go Resolved
Comment thread .mise/tasks/build/go Resolved
Comment thread .mise/tasks/build/go Resolved
Comment thread .mise/tasks/build/go Resolved
Comment thread .mise/tasks/build/go Resolved
Comment thread .mise/tasks/build/go Resolved
Comment thread shell/lib/secrets.sh Resolved
Comment thread orbs/shared/jobs/save_e2e_cache.yaml Resolved
claude added 3 commits October 7, 2026 15:46
- Restore plugin-over-cmd build path priority to match the old mage
  Gobuild behavior when a repo has both directories.
- Fail loudly when box config has no org, instead of silently
  producing a malformed GOPRIVATE.
- Propagate read_local_secret's real cat exit status, and stop
  swallowing stderr in the mise task so a real read error (e.g.
  permissions) isn't masked by the generic "missing secret" warning.
- Add the devbase:sync dependency, matching the version/docker:build
  tasks.
- Trim a comment that mostly repeated the code next to it.
- Make shell/lib/box.sh's BOXPATH respect a pre-set override, like
  shell/lib/secrets.sh's OUTREACH_SECRETS_DIR, so tests that invoke a
  script in a fresh process can point it elsewhere.
- Add a bats test for .mise/tasks/build/go covering build path
  selection and ldflags/env assembly.

Addresses review comments from marnagy on #1223.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014x7tHL2QpGrPgZDfzLKXyp
Addresses a further review comment from marnagy on
#1223.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014x7tHL2QpGrPgZDfzLKXyp
@malept
malept requested a review from marnagy October 7, 2026 15:49
CI sets BASH_ENV to re-run `mise activate bash --shims` on every new
bash process. Since each test invokes the task via `bash "$TASK"`,
that re-activation re-prepended mise's real `go` shim ahead of the
stub_command shim this test file put on PATH, so the tests exercised
the real `go build` instead of the stub and failed with "directory
prefix ... does not contain main module" in CI (this didn't reproduce
locally, since my manual container runs never set BASH_ENV the way
CircleCI's job setup does).

Fixed by running the task via `env -u BASH_ENV bash "$TASK"`.
Reproduced the CI failure locally by sourcing a BASH_ENV script that
runs `mise activate bash --shims`, confirmed it fails the same way,
and confirmed this fix resolves it both with and without that
BASH_ENV set.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014x7tHL2QpGrPgZDfzLKXyp
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.

3 participants