-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmagefile.go
More file actions
75 lines (62 loc) · 1.4 KB
/
magefile.go
File metadata and controls
75 lines (62 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//go:build mage
// +build mage
package main
import (
"fmt"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"planningpoker/infra/dev/mage"
)
const (
nodeImageTag = "node:14-alpine"
goImageTag = "golang:1.15"
)
// Lint runs golang-ci linter.
func Lint() error {
return sh.RunV("golangci-lint", "run", "-v")
}
// TestUnit runs unit tests with coverage.
func TestUnit() error {
return sh.RunV("go", "test",
"-mod=vendor",
"-count=1",
"-covermode=atomic",
"-coverpkg=./...",
"-coverprofile=coverage.txt",
"-race",
"./...")
}
// Test runs all tests with coverage.
func TestAll() error {
return sh.RunV("go", "test",
"-mod=vendor",
"-count=1",
"-covermode=atomic",
"-coverpkg=./...",
"-coverprofile=coverage.txt",
"-race",
"-tags=component",
"./...")
}
// DevFront starts frontend watcher locally with automatic rebuild.
func DevFront() error {
env, err := mage.GetEnv()
if err != nil {
return err
}
return sh.RunV("docker", "run",
"-v", fmt.Sprintf("%s/web:/web", env.WorkingDir),
"--user", fmt.Sprintf("%s:%s", env.UserID, env.GroupID),
"--workdir", "/web",
nodeImageTag, "npm", "run", "build-watch")
}
// CI runs CI pipeline
func CI() {
mg.SerialDeps(Lint, TestAll)
}
func DockerBuild() error {
return sh.RunV("docker", "build", "-t", "pp:latest", ".")
}
func DockerRun() error {
return sh.RunV("docker", "run", "-it", "-p", "8080:8080", "pp:latest")
}