Skip to content

fix: install ballast-go from release assets#64

Merged
markcallen merged 2 commits intomainfrom
fix/doctor-go-backend-install
Mar 23, 2026
Merged

fix: install ballast-go from release assets#64
markcallen merged 2 commits intomainfrom
fix/doctor-go-backend-install

Conversation

@markcallen
Copy link
Contributor

Summary

  • switch released ballast-go installs in the wrapper from go install to the published GitHub release archives
  • add a regression test covering the broken doctor --fix Go backend install path
  • update Go installation docs to match the release-asset distribution model

Testing

  • pnpm test
  • pnpm run test:coverage
  • go test ./... (in cli/ballast)

Copilot AI review requested due to automatic review settings March 23, 2026 21:44
Copy link
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

This PR updates the Ballast Go wrapper’s backend installation flow so ballast-go is installed from GitHub Release archives (instead of go install from a module path), adds a regression test for the install-cli Go install behavior, and aligns documentation with the release-asset distribution model.

Changes:

  • Switch Go backend installs in the wrapper to download/extract the published ballast-go_<ver>_<os>_<arch> release archive.
  • Add a Go-focused regression test ensuring pinned installs use the release archive URL and avoid the invalid module path.
  • Update installation docs/README examples to use the release archive install commands and stop suggesting go run ...@latest.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
cli/ballast/main.go Replaces go install ...@<version> with a release-archive download/extract install path for ballast-go.
cli/ballast/main_test.go Adds a regression test asserting pinned Go installs use the GitHub Releases archive URL and avoid the module path.
docs/installation.md Updates Go install docs to download/install from GitHub release assets and adjusts monorepo examples accordingly.
README.md Mirrors the updated Go install instructions and replaces monorepo go run ...@latest guidance with ballast-go usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +709 to +716
func releasedGoArchiveURL(release string) (string, error) {
goos, goarch, archiveExt, err := releasedGoArchiveParts(runtime.GOOS, runtime.GOARCH)
if err != nil {
return "", err
}
filename := fmt.Sprintf("ballast-go_%s_%s_%s.%s", release, goos, goarch, archiveExt)
return fmt.Sprintf("https://github.com/everydaydevopsio/ballast/releases/download/v%s/%s", release, filename), nil
}
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The Go backend installer now downloads a release archive directly but does not verify its integrity/authenticity (e.g., via the published release checksums). This is a security regression versus go install module checksum verification; consider downloading the ballast-go_checksums.txt asset for the release and validating the archive’s SHA256 before extracting/installing.

Copilot uses AI. Check for mistakes.
Comment on lines +699 to +706
script := `set -e
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
archive="$tmpdir/ballast-go.tar.gz"
curl -fsSL "$1" -o "$archive"
tar -xzf "$archive" -C "$tmpdir"
install -m 0755 "$tmpdir/ballast-go" "$2"`
return []string{"sh", "-c", script, "sh", url, destination}, nil
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

releasedGoInstallCommand relies on external tools (sh, curl, tar, install / PowerShell cmdlets) being present. On minimal distros/containers or restricted environments this will fail at runtime with a generic install error; consider implementing the download+extract in Go (net/http + archive/zip/tar/gzip) or at least preflight-checking required executables and returning a clearer, actionable error.

Copilot uses AI. Check for mistakes.
esac
curl -fsSL -o /tmp/ballast-go.tar.gz "https://github.com/everydaydevopsio/ballast/releases/download/v${VERSION}/ballast-go_${VERSION}_${OS}_${ARCH}.tar.gz"
tar -xzf /tmp/ballast-go.tar.gz -C /tmp
install -m 0755 /tmp/ballast-go ~/.local/bin/ballast-go
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

These instructions assume ~/.local/bin already exists. Add a mkdir -p ~/.local/bin (and/or a note about ensuring it’s on PATH) before the install command to avoid failures on fresh environments.

Suggested change
install -m 0755 /tmp/ballast-go ~/.local/bin/ballast-go
mkdir -p "${HOME}/.local/bin" # Ensure ~/.local/bin exists and is on your PATH
install -m 0755 /tmp/ballast-go "${HOME}/.local/bin/ballast-go"

Copilot uses AI. Check for mistakes.
arm64|aarch64) ARCH=arm64 ;;
esac
curl -fsSL -o /tmp/ballast-go.tar.gz "https://github.com/everydaydevopsio/ballast/releases/download/v${VERSION}/ballast-go_${VERSION}_${OS}_${ARCH}.tar.gz"
tar -xzf /tmp/ballast-go.tar.gz -C /tmp
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

These instructions assume ~/.local/bin already exists. Add a mkdir -p ~/.local/bin (and/or a note about ensuring it’s on PATH) before the install command to avoid failures on fresh environments.

Suggested change
tar -xzf /tmp/ballast-go.tar.gz -C /tmp
tar -xzf /tmp/ballast-go.tar.gz -C /tmp
mkdir -p ~/.local/bin

Copilot uses AI. Check for mistakes.
Comment on lines +291 to +294
t.Fatalf("expected go install to use a release archive, got %q", got)
}
if strings.Contains(got, "go install github.com/everydaydevopsio/ballast/packages/ballast-go/cmd/ballast-go@") {
t.Fatalf("expected go install to avoid the invalid module path, got %q", got)
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The test failure messages still refer to “go install”, but the installer now uses a shell/powershell download+extract command. Updating the assertion messages to match the actual behavior will make failures less confusing.

Suggested change
t.Fatalf("expected go install to use a release archive, got %q", got)
}
if strings.Contains(got, "go install github.com/everydaydevopsio/ballast/packages/ballast-go/cmd/ballast-go@") {
t.Fatalf("expected go install to avoid the invalid module path, got %q", got)
t.Fatalf("expected installer to use a release archive, got %q", got)
}
if strings.Contains(got, "go install github.com/everydaydevopsio/ballast/packages/ballast-go/cmd/ballast-go@") {
t.Fatalf("expected installer to avoid the invalid module path, got %q", got)

Copilot uses AI. Check for mistakes.
@markcallen
Copy link
Contributor Author

Addressed the Copilot review items from https://github.com/everydaydevopsio/ballast/pull/64/files:

  • cli/ballast/main.go checksum verification: fixed in 6f559b5. The release installer now downloads ballast-go_checksums.txt for the matching release and verifies the archive SHA256 before extraction on both Unix and Windows.
  • cli/ballast/main.go external tool dependency concern: tracked in follow-up issue Improve ballast-go release installer portability by removing shell tool assumptions #65 to keep this PR scoped.
  • docs/installation.md ~/.local/bin assumption: fixed in 6f559b5 by creating ${HOME}/.local/bin before install.
  • README.md ~/.local/bin assumption: fixed in 6f559b5 by creating ${HOME}/.local/bin before install.
  • cli/ballast/main_test.go stale go install wording: fixed in 6f559b5, and the regression now also asserts the checksum asset is part of the installer flow.

@markcallen markcallen merged commit c719d02 into main Mar 23, 2026
11 checks passed
@markcallen markcallen deleted the fix/doctor-go-backend-install branch March 23, 2026 22:30
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.

2 participants