-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTaskfile.yml
127 lines (106 loc) · 3.18 KB
/
Taskfile.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
version: '3'
vars:
LINTER_VERSION: "1.57.2"
GOTESTSUM_VERSION: "1.11.0"
HADOLINT_VERSION: "v2.12.1-beta"
LOCAL_BIN: "{{.USER_WORKING_DIR}}/bin"
MOCKERY_VERSION: "v2.41.0"
tasks:
install_linters:
cmds:
- "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b {{.LOCAL_BIN}} v{{.LINTER_VERSION}}"
install_gotestsum:
cmds:
- "GOBIN={{.LOCAL_BIN}} go install gotest.tools/gotestsum@v{{.GOTESTSUM_VERSION}}"
install_mockery:
cmds:
- "GOBIN={{.LOCAL_BIN}} go install github.com/vektra/mockery/v2@{{.MOCKERY_VERSION}}"
install_hadolint:
cmds:
- "docker pull ghcr.io/hadolint/hadolint:{{.HADOLINT_VERSION}}"
init:
deps:
- install_linters
- install_gotestsum
- install_mockery
cmds:
- "go get -v ./..."
build:
cmds:
- "go build -o easyp ./cmd/easyp"
test:
cmds:
- "{{.LOCAL_BIN}}/gotestsum --format pkgname -- -coverprofile=coverage.out -race -count=1 ./..."
lint:
deps:
- build
cmds:
- "docker run --rm -i ghcr.io/hadolint/hadolint:{{.HADOLINT_VERSION}} < Docker/base/Dockerfile"
- "docker run --rm -i ghcr.io/hadolint/hadolint:{{.HADOLINT_VERSION}} < Docker/lint/Dockerfile"
- "{{.LOCAL_BIN}}/golangci-lint run ./..."
quality:
deps:
- test
- lint
coverage:
cmds:
- "go tool cover -html=coverage.out"
install:
cmds:
- "go install ./cmd/easyp"
clean:
cmds:
- "rm -rf ./bin"
- "rm -rf ./coverage.out"
- "go clean -cache"
mock:
cmds:
- "{{.LOCAL_BIN}}/mockery --name {{.NAME}} --dir {{.DIR}} --output {{.DIR}}/mocks"
mocks:
cmds:
- task: mock
vars: { NAME: 'LockFile', DIR: './internal/adapters/storage' }
- task: mock
vars: { NAME: 'Rule', DIR: './internal/core' }
- task: mock
vars: { NAME: 'Console', DIR: './internal/core' }
- task: mock
vars: { NAME: 'CurrentProjectGitWalker', DIR: './internal/core' }
- task: mock
vars: { NAME: 'Storage', DIR: './internal/core' }
- task: mock
vars: { NAME: 'ModuleConfig', DIR: './internal/core' }
- task: mock
vars: { NAME: 'LockFile', DIR: './internal/core' }
docker_base:
preconditions:
- test -f Docker/base/Dockerfile
cmds:
- docker build -f Docker/base/Dockerfile -t easyp/base:latest .
- docker tag easyp/base:latest easyp/base:{{.GIT_TAG}}
docker_lint:
preconditions:
- test -f Docker/lint/Dockerfile
cmds:
- docker build -f Docker/lint/Dockerfile --build-arg="EASYP_BASE_VERSION=latest" -t easyp/lint:latest .
- docker tag easyp/lint:latest easyp/lint:{{.GIT_TAG}}
docker_push:
cmds:
- docker push easyp/base:latest
- docker push easyp/base:{{.GIT_TAG}}
- docker push easyp/lint:latest
- docker push easyp/lint:{{.GIT_TAG}}
docker:
vars:
GIT_TAG:
sh: "git describe --tags --abbrev=0"
cmds:
- task: docker_base
vars:
GIT_TAG: "{{.GIT_TAG}}"
- task: docker_lint
vars:
GIT_TAG: "{{.GIT_TAG}}"
- task: docker_push
vars:
GIT_TAG: "{{.GIT_TAG}}"