diff options
| author | Paul Buetow <paul@buetow.org> | 2026-01-21 21:37:34 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-01-21 21:37:34 +0200 |
| commit | 95bdcf2c73a643df227bccf909f3aa17d08b0f1c (patch) | |
| tree | 11db378e2dee076fbf18c1dc58fae1d18c4d8789 /Magefile.go | |
| parent | f8574d5ecf31021b1aee7fcb0c8b45c190bffead (diff) | |
Convert Taskfile.yaml to Magefile.go
Replace task runner with mage for build automation.
All existing targets preserved: build, run, test variants, install, clean.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'Magefile.go')
| -rw-r--r-- | Magefile.go | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Magefile.go b/Magefile.go new file mode 100644 index 0000000..0d355cd --- /dev/null +++ b/Magefile.go @@ -0,0 +1,81 @@ +//go:build mage + +package main + +import ( + "fmt" + "os" + + "github.com/magefile/mage/sh" +) + +var Default = Build + +// Build compiles the totalrecall binary +func Build() error { + return sh.RunV("go", "build", "-o", "totalrecall", "./cmd/totalrecall") +} + +// Run executes the application without building +func Run() error { + return sh.RunV("go", "run", "./cmd/totalrecall") +} + +// Test runs all tests +func Test() error { + return sh.RunV("go", "test", "./...") +} + +// TestVerbose runs all tests with verbose output +func TestVerbose() error { + return sh.RunV("go", "test", "-v", "./...") +} + +// TestCoverage runs all tests with coverage report +func TestCoverage() error { + return sh.RunV("go", "test", "-cover", "./...") +} + +// TestCoverageHtml runs all tests and generates HTML coverage report +func TestCoverageHtml() error { + if err := sh.RunV("go", "test", "-coverprofile=coverage.out", "./..."); err != nil { + return err + } + if err := sh.RunV("go", "tool", "cover", "-html=coverage.out", "-o", "coverage.html"); err != nil { + return err + } + fmt.Println("Coverage report generated at coverage.html") + return nil +} + +// TestRace runs all tests with race detector +func TestRace() error { + return sh.RunV("go", "test", "-race", "./...") +} + +// TestShort runs only short tests (skip integration tests) +func TestShort() error { + return sh.RunV("go", "test", "-short", "./...") +} + +// TestAll runs comprehensive test suite with coverage and race detection +func TestAll() error { + fmt.Println("Running comprehensive test suite...") + return sh.RunV("go", "test", "-v", "-race", "-cover", "./...") +} + +// Install installs the binary to Go bin directory +func Install() error { + return sh.RunV("go", "install", "./cmd/totalrecall") +} + +// Clean removes build artifacts and test coverage files +func Clean() error { + files := []string{"totalrecall", "coverage.out", "coverage.html"} + for _, f := range files { + if err := os.Remove(f); err != nil && !os.IsNotExist(err) { + return err + } + } + return sh.RunV("go", "clean", "-testcache") +} |
