Skip to content

Add build optimization flags to Makefile, CI, and e2e test helper#550

Merged
frjcomp merged 6 commits intomainfrom
copilot/analyze-build-process-improvements
Mar 9, 2026
Merged

Add build optimization flags to Makefile, CI, and e2e test helper#550
frjcomp merged 6 commits intomainfrom
copilot/analyze-build-process-improvements

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

Align all build paths with goreleaser's existing optimization flags (-trimpath -ldflags="-s -w") to reduce binary sizes ~28% (86MB → 62MB) and improve build/test speed ~15%.

Changes

  • Makefile: Add GO_BUILD_FLAGS = -trimpath -ldflags="-s -w" applied to all 6 build targets
  • E2E test helper (testutil.go): Pass same flags in buildBinary() so fallback test builds match
  • Windows CI (test.yml): Add flags to the e2e binary build step — was the only build path still using bare go build

What was evaluated and not changed

  • goreleaser.yaml: Already had -s -w -buildid= -trimpath — no changes needed. Release format kept as formats: binary (direct binaries, no archives).
  • -buildvcs=false / -buildid=: Saves 36 bytes on top of -s -w — not worth the complexity.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…e binary sizes

Add -trimpath and -ldflags="-s -w" to all Makefile build targets and the
e2e test binary builder, matching the flags already used by goreleaser for
release builds. This strips the symbol table, DWARF debug info, and file
system paths from binaries.

Main binary size: 86MB → 62MB (~28% reduction)

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze build process to reduce binary output sizes Add build optimization flags to Makefile and e2e test helper Mar 9, 2026
- Fix Windows CI e2e build: add -trimpath -ldflags="-s -w" flags to match
  Linux/Makefile behavior (~15% faster build, ~28% smaller binary)
- Switch goreleaser release format from raw binaries to compressed archives
  (tar.gz for Linux/macOS, zip for Windows) reducing release download size
  from 62MB to ~20MB per artifact (68% reduction)

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title Add build optimization flags to Makefile and e2e test helper Reduce binary sizes: add build flags to Makefile/CI and compress release archives Mar 9, 2026
Restores `formats: binary` instead of tar.gz/zip compressed archives,
so release binaries are published directly without wrapping.

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title Reduce binary sizes: add build flags to Makefile/CI and compress release archives Add build optimization flags to Makefile, CI, and e2e test helper Mar 9, 2026
@frjcomp frjcomp marked this pull request as ready for review March 9, 2026 12:55
Copilot AI review requested due to automatic review settings March 9, 2026 12:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Aligns non-release build paths (Makefile, CI, and e2e fallback builds) with GoReleaser’s existing optimization flags to reduce binary size and improve build/test speed across the project.

Changes:

  • Add GO_BUILD_FLAGS = -trimpath -ldflags="-s -w" and apply it to all Makefile build targets.
  • Update the e2e test helper’s fallback go build to use the same optimization flags.
  • Update the Windows CI e2e build step to pass the same flags.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/e2e/internal/testutil/testutil.go Adds -trimpath and -ldflags to the fallback e2e build.
Makefile Introduces and applies a shared GO_BUILD_FLAGS variable across build targets.
.github/workflows/test.yml Adds optimization flags (and CGO setting) to the Windows e2e binary build step.

frjcomp and others added 2 commits March 9, 2026 14:07
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@frjcomp frjcomp merged commit 7bfcd9f into main Mar 9, 2026
12 checks passed
@frjcomp frjcomp deleted the copilot/analyze-build-process-improvements branch March 9, 2026 13:25
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