Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,18 @@ jobs:
timeout-minutes: 3
run: scripts/e2e/s3-binary.sh

# ── Phase 21: Uninstall ───────────────────────────────────────
# ── Phase 21: Mail binary service lifecycle ────────────────────
- name: E2E — Mail binary service lifecycle
timeout-minutes: 3
run: scripts/e2e/mail-binary.sh

# ── Phase 22: Uninstall ───────────────────────────────────────
# TODO: frankenphp untrust hangs in CI (internal sudo prompt, no terminal)
# - name: Test pv uninstall
# timeout-minutes: 1
# run: scripts/e2e/uninstall.sh

# ── Phase 22: Failure Diagnostics & Cleanup ────────────────────
# ── Phase 23: Failure Diagnostics & Cleanup ────────────────────
- name: Dump logs on failure
if: failure()
run: scripts/e2e/diagnostics.sh
Expand Down
17 changes: 17 additions & 0 deletions internal/binaries/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func InstallBinaryProgress(client *http.Client, b Binary, version string, progre
return installMago(client, url, progress)
case "rustfs":
return installRustfs(client, url, progress)
case "mailpit":
return installMailpit(client, url, progress)
default:
return fmt.Errorf("unknown binary: %s", b.Name)
}
Expand Down Expand Up @@ -70,6 +72,21 @@ func installRustfs(client *http.Client, url string, progress ProgressFunc) error
return MakeExecutable(destPath)
}

func installMailpit(client *http.Client, url string, progress ProgressFunc) error {
internalBin := config.InternalBinDir()
archivePath := filepath.Join(internalBin, "mailpit.tar.gz")
destPath := filepath.Join(internalBin, "mailpit")

if err := DownloadProgress(client, url, archivePath, progress); err != nil {
return err
}
if err := ExtractTarGz(archivePath, destPath, "mailpit"); err != nil {
return err
}
os.Remove(archivePath)
return MakeExecutable(destPath)
}

func installComposer(client *http.Client, url string, b Binary, version string, progress ProgressFunc) error {
destPath := config.ComposerPharPath()

Expand Down
43 changes: 43 additions & 0 deletions internal/binaries/mailpit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package binaries

import (
"fmt"
"runtime"
)

var Mailpit = Binary{
Name: "mailpit",
DisplayName: "Mailpit",
NeedsExtract: true,
}

var mailpitPlatformNames = map[string]map[string]string{
"darwin": {
"arm64": "darwin-arm64",
"amd64": "darwin-amd64",
},
"linux": {
"amd64": "linux-amd64",
"arm64": "linux-arm64",
},
}

func mailpitArchiveName() (string, error) {
archMap, ok := mailpitPlatformNames[runtime.GOOS]
if !ok {
return "", fmt.Errorf("unsupported OS for Mailpit: %s", runtime.GOOS)
}
platform, ok := archMap[runtime.GOARCH]
if !ok {
return "", fmt.Errorf("unsupported architecture for Mailpit: %s/%s", runtime.GOOS, runtime.GOARCH)
}
return fmt.Sprintf("mailpit-%s.tar.gz", platform), nil
}

func mailpitURL(version string) (string, error) {
archive, err := mailpitArchiveName()
if err != nil {
return "", err
}
return fmt.Sprintf("https://github.com/axllent/mailpit/releases/download/%s/%s", version, archive), nil
}
65 changes: 65 additions & 0 deletions internal/binaries/mailpit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package binaries

import (
"runtime"
"strings"
"testing"
)

func TestMailpitURL_CurrentPlatform(t *testing.T) {
url, err := mailpitURL("v1.29.6")
if err != nil {
t.Fatalf("unexpected error for %s/%s: %v", runtime.GOOS, runtime.GOARCH, err)
}
if !strings.HasPrefix(url, "https://github.com/axllent/mailpit/releases/download/v1.29.6/") {
t.Errorf("URL = %q; missing expected prefix", url)
}
if !strings.HasSuffix(url, ".tar.gz") {
t.Errorf("URL = %q; expected .tar.gz suffix", url)
}
}

func TestMailpitArchiveName_AllPlatforms(t *testing.T) {
tests := []struct {
goos, goarch, want string
}{
{"darwin", "arm64", "mailpit-darwin-arm64.tar.gz"},
{"darwin", "amd64", "mailpit-darwin-amd64.tar.gz"},
{"linux", "amd64", "mailpit-linux-amd64.tar.gz"},
{"linux", "arm64", "mailpit-linux-arm64.tar.gz"},
}
for _, tc := range tests {
archMap, ok := mailpitPlatformNames[tc.goos]
if !ok {
t.Errorf("no entry for GOOS=%s", tc.goos)
continue
}
platform, ok := archMap[tc.goarch]
if !ok {
t.Errorf("no entry for GOARCH=%s on %s", tc.goarch, tc.goos)
continue
}
got := "mailpit-" + platform + ".tar.gz"
if got != tc.want {
t.Errorf("%s/%s: got %q, want %q", tc.goos, tc.goarch, got, tc.want)
}
}
}

func TestDownloadURL_MailpitCase(t *testing.T) {
url, err := DownloadURL(Mailpit, "v1.29.6")
if err != nil {
t.Fatalf("DownloadURL returned error: %v", err)
}
if url == "" {
t.Error("DownloadURL returned empty string")
}
}

func TestLatestVersionURL_MailpitCase(t *testing.T) {
got := LatestVersionURL(Mailpit)
want := "https://api.github.com/repos/axllent/mailpit/releases/latest"
if got != want {
t.Errorf("got %q, want %q", got, want)
}
}
4 changes: 4 additions & 0 deletions internal/binaries/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func DownloadURL(b Binary, version string) (string, error) {
return composerURL(), nil
case "rustfs":
return rustfsURL(version)
case "mailpit":
return mailpitURL(version)
default:
return "", fmt.Errorf("unknown binary: %s", b.Name)
}
Expand All @@ -60,6 +62,8 @@ func LatestVersionURL(b Binary) string {
return "https://api.github.com/repos/carthage-software/mago/releases/latest"
case "rustfs":
return "https://api.github.com/repos/rustfs/rustfs/releases?per_page=1"
case "mailpit":
return "https://api.github.com/repos/axllent/mailpit/releases/latest"
default:
return ""
}
Expand Down
17 changes: 13 additions & 4 deletions internal/commands/service/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ var destroyCmd = &cobra.Command{
}

binPath := filepath.Join(config.InternalBinDir(), binSvc.Binary().Name)
_ = os.Remove(binPath)
if vs, vsErr := binaries.LoadVersions(); vsErr == nil {
if err := os.Remove(binPath); err != nil && !os.IsNotExist(err) {
ui.Subtle(fmt.Sprintf("Could not remove %s: %v (file left behind)", binPath, err))
}
// Clear the tracked version so a future service:add redownloads.
if vs, vsErr := binaries.LoadVersions(); vsErr != nil {
ui.Subtle(fmt.Sprintf("Could not load versions file: %v (manifest may be stale)", vsErr))
} else {
vs.Set(binSvc.Binary().Name, "")
_ = vs.Save()
if err := vs.Save(); err != nil {
ui.Subtle(fmt.Sprintf("Could not save versions file: %v", err))
}
}

dataDir := config.ServiceDataDir(name, "latest")
Expand All @@ -62,7 +69,9 @@ var destroyCmd = &cobra.Command{
ui.Subtle(fmt.Sprintf("Could not regenerate service site config: %v", err))
}
if server.IsRunning() {
_ = server.SignalDaemon()
if err := server.SignalDaemon(); err != nil {
ui.Subtle(fmt.Sprintf("Could not signal daemon: %v", err))
}
}
ui.Success(fmt.Sprintf("%s destroyed (binary + data gone)", binSvc.DisplayName()))
return nil
Expand Down
12 changes: 9 additions & 3 deletions internal/commands/service/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ var removeCmd = &cobra.Command{
}
// Delete the binary.
binPath := filepath.Join(config.InternalBinDir(), binSvc.Binary().Name)
_ = os.Remove(binPath)
if err := os.Remove(binPath); err != nil && !os.IsNotExist(err) {
ui.Subtle(fmt.Sprintf("Could not remove %s: %v (file left behind)", binPath, err))
}
// Clear the tracked version so a future `service:add` redownloads.
if vs, vsErr := binaries.LoadVersions(); vsErr == nil {
if vs, vsErr := binaries.LoadVersions(); vsErr != nil {
ui.Subtle(fmt.Sprintf("Could not load versions file: %v (manifest may be stale)", vsErr))
} else {
vs.Set(binSvc.Binary().Name, "")
_ = vs.Save()
if err := vs.Save(); err != nil {
ui.Subtle(fmt.Sprintf("Could not save versions file: %v", err))
}
}

// Regenerate Caddy configs (remove s3.pv.test / s3-api.pv.test routes).
Expand Down
69 changes: 0 additions & 69 deletions internal/services/mail.go

This file was deleted.

52 changes: 0 additions & 52 deletions internal/services/mail_test.go

This file was deleted.

Loading
Loading