-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
104 lines (91 loc) · 2.43 KB
/
Copy pathTaskfile.yml
File metadata and controls
104 lines (91 loc) · 2.43 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
# https://taskfile.dev
version: "3"
vars:
PROJECT_NAME: github-notifications-cleaner
BUILD_DATE:
sh: date -u +'%Y-%m-%dT%H:%M:%SZ'
GIT_COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
GIT_VERSION:
sh: git describe --tags --abbrev=0 2>/dev/null || echo "unknown"
PKG_NAME:
sh: awk '/^module / {print $2}' go.mod
DEV_IMAGE_TAG: "{{ .PROJECT_NAME }}:dev"
env:
DOCKER_BUILDKIT: 1
tasks:
default:
cmds:
- task -l
build:
desc: Build the application
cmds:
- |
go build \
-gcflags "all=-N -l" \
-ldflags "-s -w \
-X {{ .PKG_NAME }}/cmd/version.BuildDate={{ .BUILD_DATE }} \
-X {{ .PKG_NAME }}/cmd/version.GitCommit={{ .GIT_COMMIT }} \
-X {{ .PKG_NAME }}/cmd/version.Version={{ .GIT_VERSION }}" \
-o build/{{ .PROJECT_NAME }} main.go
build-docker:
desc: Build the application using Docker
cmds:
- |
docker buildx build \
--build-arg BUILD_DATE={{ .BUILD_DATE }} \
--build-arg GIT_COMMIT={{ .GIT_COMMIT }} \
--build-arg GIT_VERSION={{ .GIT_VERSION }} \
--load \
-t {{ .DEV_IMAGE_TAG }} .
lint:
desc: Run linter
cmds:
- golangci-lint run
lint-docker:
desc: Lints Dockerfile
cmds:
- hadolint Dockerfile
lint-fix:
desc: Run linter with fix
cmds:
- golangci-lint run --fix
test:
desc: Run unit tests
cmds:
- |
mkdir -p ${REPORTS_DIR}
gotestsum \
--format testname \
--jsonfile reports/test-result.json -- -coverprofile=${REPORTS_DIR}/coverage.out -covermode=atomic ./...
go tool cover \
-html=${REPORTS_DIR}/coverage.out \
-o ${REPORTS_DIR}/coverage.html
env:
REPORTS_DIR: reports
silent: true
test-docker:
deps:
- build-docker
desc: Run tests against docker image
cmds:
- |
container-structure-test test \
--image {{ .DEV_IMAGE_TAG }} \
--config structure-test.yaml
gomod:
desc: Download Go modules
cmds:
- go mod download && go mod tidy
run:
desc: Runs the application
cmds:
- go run .
docgen:
desc: Generate documentation using gomarkdoc
cmds:
- gomarkdoc ./... --output docs/README.md
snapshot:
desc: Create a snapshot release
cmds:
- goreleaser release --snapshot --rm-dist