-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
112 lines (96 loc) · 2.97 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
# Taskfile is used to run common tasks when developing the application.
# Check : https://taskfile.dev/usage/
version: "3"
vars:
PROJECT_NAME: "raindrop-images-dl"
REPORTS_DIR: reports
GIT_VERSION:
sh: git describe --tags 2>/dev/null || echo "v0.0.0"
GIT_SHA:
sh: git rev-parse --short HEAD 2>/dev/null
BUILD_DATE:
sh: date -u +'%Y-%m-%dT%H:%M:%SZ'
env:
DOCKER_BUILDKIT: 1
dotenv: [".env", ".env.example", ".env.{{.ENV}}"]
tasks:
default:
cmds:
- task -l
# ==================================================
# Linting and Tests
# ==================================================
lint:
desc: Runs all linting tasks
cmds:
- task lint-go
- task lint-docker
- task lint-api
lint-go:
desc: Lints Go code using golangci-lint
aliases:
- golint
cmds:
- golangci-lint run --fix
lint-docker:
desc: Lints Dockerfile using Hadolint
aliases:
- hadolint
cmds:
- hadolint Dockerfile
fmt:
desc: Formats all code
cmds:
- gofumpt -l -w .
gomarkdoc:
desc: Generates documentation from Go comments
cmds:
- gomarkdoc --output "{{ print `{{.Dir}}/README.md` }}" ./internal/...
test:
desc: Runs application tests
summary: Executes all package level tests (unit and integration)
cmds:
- mkdir -p {{.REPORTS_DIR}}
- gotestsum --format="testname" --junitfile {{.REPORTS_DIR}}/unit-tests.xml --jsonfile {{.REPORTS_DIR}}/unit-tests.json -- -coverprofile={{.REPORTS_DIR}}/cover.out -covermode=atomic ./internal/...
test-cover-report:
desc: Opens the test coverage report in the browser
cmds:
- go tool cover -html=reports/cover.out
snapshot:
desc: Builds a snapshot release
cmds:
- goreleaser --snapshot --clean
build:
desc: Builds the application locally
cmds:
- |
go build -o build/{{.PROJECT_NAME}} -ldflags="-w -s \
-X github.com/brpaz/raindrop-images-dl/internal/version.Version={{ .VERSION }} \
-X github.com/brpaz/raindrop-images-dl/internal/version.GitCommit={{ .GIT_COMMIT }}\
-X github.com/brpaz/raindrop-images-dl/internal/version.BuildDate={{ .BUILD_DATE }} \
-extldflags '-static'" \
cmd/main.go
# ==================================================
# Build tasks
# ==================================================
build-docker:
desc: Builds the application using docker
cmds:
- |
docker buildx build \
--build-arg VERSION={{ .GIT_VERSION }} \
--build-arg REVISION={{ .GIT_SHA }} \
--build-arg BUILDTIME={{ .BUILD_DATE }} \
--load \
-t {{.PROJECT_NAME }}:local-dev .
# ==================================================
# Build Nix
# ==================================================
build-nix:
desc: Builds the application using Nix
cmds:
- nix build
dev:
desc: Starts the application in development mode
cmds:
- nix develop -c zsh