Dan Anglin
fc5fa7b0ca
This PR allows users to specify the path to the database file Pelican now expects the user to specify the path to the project's database file which allows users to open different projects. This is a breaking change because Pelican no longer opens the default path automatically. If no path is set then Pelican stops with an error message.
73 lines
1.2 KiB
Go
73 lines
1.2 KiB
Go
//go:build mage
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/magefile/mage/sh"
|
|
)
|
|
|
|
const (
|
|
binary = "pelican"
|
|
)
|
|
|
|
var Default = Build
|
|
|
|
// Test run the go tests
|
|
// To enable verbose mode set PELICAN_TEST_VERBOSE=1.
|
|
// To enable coverage mode set PELICAN_TEST_COVER=1.
|
|
func Test() error {
|
|
goTest := sh.RunCmd("go", "test")
|
|
|
|
args := []string{"./..."}
|
|
|
|
if os.Getenv("PELICAN_TEST_VERBOSE") == "1" {
|
|
args = append(args, "-v")
|
|
}
|
|
|
|
if os.Getenv("PELICAN_TEST_COVER") == "1" {
|
|
args = append(args, "-cover")
|
|
}
|
|
|
|
return goTest(args...)
|
|
}
|
|
|
|
// Lint runs golangci-lint against the code.
|
|
func Lint() error {
|
|
return sh.RunV("golangci-lint", "run", "--color", "always")
|
|
}
|
|
|
|
// Build build the executable
|
|
func Build() error {
|
|
main := "./cmd/" + binary + "/main.go"
|
|
return sh.Run("go", "build", "-o", binary, main)
|
|
}
|
|
|
|
// Clean clean the workspace
|
|
func Clean() error {
|
|
if err := sh.Rm(binary); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := sh.Run("go", "clean", "./..."); err != nil {
|
|
return err
|
|
}
|
|
|
|
testDBDir := "./test/databases"
|
|
|
|
files, err := os.ReadDir(testDBDir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, f := range files {
|
|
filename := f.Name()
|
|
if strings.HasSuffix(filename, ".db") {
|
|
sh.Rm(testDBDir + "/" + filename)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|