-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathTaskfile.yml
More file actions
164 lines (139 loc) · 4.54 KB
/
Taskfile.yml
File metadata and controls
164 lines (139 loc) · 4.54 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
version: "3"
vars:
LINTER_VERSION: "2.1.6"
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"
schema:generate:
desc: Generate versioned and latest easyp config JSON Schema artifacts
cmds:
- "go run ./cmd/easyp schema-gen"
schema:check:
desc: Ensure schema artifacts are up to date
cmds:
- task: schema:generate
- "git diff --exit-code -- schemas/easyp-config-v1.schema.json schemas/easyp-config.schema.json"
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}}"
goreleaser:check:
desc: Check GoReleaser configuration syntax
cmds:
- goreleaser check
goreleaser:test:
desc: Test GoReleaser build (snapshot, no publish)
cmds:
- |
if ! docker buildx ls | grep -q multiarch; then
echo "Creating Docker buildx builder for multi-arch..."
docker buildx create --name multiarch --use --bootstrap || docker buildx use multiarch
fi
goreleaser release --snapshot --clean
goreleaser:test-docker:
desc: Test Docker images build (snapshot, locally)
cmds:
- |
if ! docker buildx ls | grep -q multiarch; then
echo "Creating Docker buildx builder for multi-arch..."
docker buildx create --name multiarch --use --bootstrap || docker buildx use multiarch
fi
echo "Note: In snapshot mode GoReleaser creates separate images with platform suffixes"
echo "In a real release, a multi-arch manifest will be created without suffixes"
goreleaser release --snapshot --clean