Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
131 lines (117 loc) · 3.09 KB
/
Copy pathTaskfile.yml
File metadata and controls
131 lines (117 loc) · 3.09 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
---
version: "3"
silent: true
vars:
MAIN_PACKAGE: ./cmd/composeflux
APP_NAME: composeflux
GOPATH_BIN:
sh: echo "$(go env GOPATH)/bin"
BRANCH:
sh: git rev-parse --abbrev-ref HEAD
BUILD_TIME:
sh: date '+%Y-%m-%d@%H:%M:%S'
BUILD_USER:
sh: id -un
REVISION:
sh: git rev-parse --short HEAD
VERSION:
sh: git describe --tags --always
COMPILER_CC: '{{if eq OS "linux"}}musl-gcc{{else if eq OS "darwin"}}clang{{end}}'
COMPILER_CXX: '{{if eq OS "darwin"}}clang++{{end}}'
env:
GOBIN: "{{.GOPATH_BIN }}"
CGO_ENABLED: 1
CC: "{{.COMPILER_CC}}"
CXX: "{{.COMPILER_CXX}}"
tasks:
run:
desc: Runs the main application
deps:
- vet
cmds:
- go run {{.MAIN_PACKAGE}}
env:
LOG_FORMAT: console
LOG_ADD_SOURCE: true
LOG_LEVEL: debug
compose:
desc: Run the application in development mode using Docker Compose
deps:
- vet
cmd: |
docker compose -f compose-dev.yml up \
--remove-orphans \
--force-recreate \
--build
env:
LOG_FORMAT: console
LOG_ADD_SOURCE: true
LOG_LEVEL: debug
lint:
desc: Run static analysis and code linting using golangci-lint
deps:
- install
cmds:
- golangci-lint run --timeout 3m
fmt:
desc: Formats all Go source files
cmds:
- go fmt ./...
vet:
desc: Examines Go source code and reports suspicious constructs
cmds:
- go vet ./...
test:
desc: Runs all tests in the project
aliases:
- tests
deps:
- vet
cmds:
- go test ./...
build:
desc: Build the application binary for the current platform
vars:
LINUX_LDFLAGS: >-
{{if eq OS "linux"}}
-linkmode external -extldflags '-static -Wl,-unresolved-symbols=ignore-all'
{{end}}
deps:
- vet
cmd: |
go build -ldflags "-s -w {{.LINUX_LDFLAGS}} \
-X github.com/veerendra2/gopackages/version.Version={{.VERSION}} \
-X github.com/veerendra2/gopackages/version.Revision={{.REVISION}} \
-X github.com/veerendra2/gopackages/version.Branch={{.BRANCH}} \
-X github.com/veerendra2/gopackages/version.BuildUser={{.BUILD_USER}} \
-X github.com/veerendra2/gopackages/version.BuildDate={{.BUILD_TIME}}" \
-o dist/{{.APP_NAME}} {{.MAIN_PACKAGE}}
build-docker:
desc: Build Docker image
cmds:
- docker build -t {{.APP_NAME}} .
security:
desc: Run security vulnerability scan
deps:
- install
cmds:
- govulncheck ./...
serve-docs:
aliases:
- docs
desc: Serve MkDocs documentation locally with live reload
cmd: mkdocs serve --dev-addr=127.0.0.1:8000 --livereload
install:
desc: Install required tools and dependencies
cmds:
- go install golang.org/x/vuln/cmd/govulncheck@latest
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- pip install "mkdocs>=1.6,<2.0" mkdocs-material
all:
desc: Run comprehensive checks; format, lint, security and test
cmds:
- task fmt
- task lint
- task vet
- task security
- task test