-
Notifications
You must be signed in to change notification settings - Fork 2
/
Taskfile.yaml
185 lines (159 loc) · 5.01 KB
/
Taskfile.yaml
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# https://taskfile.dev
version: '3'
vars:
EXE: gotrxx{{exeExt}}
tasks:
default:
cmds:
- task -l
dev:provision:
desc: "sets up the workspace and gets dependecies"
cmds:
- mkdir -p bin
- mkdir -p .dev
- go mod download
- task: test:misc:certificates
- task: templates:restore
dev:install-linters:
desc: "sets up the linters"
cmds:
- go install github.com/psampaz/[email protected]
- go install github.com/segmentio/[email protected]
- go install honnef.co/go/tools/cmd/staticcheck@latest
- go install github.com/golangci/golangci-lint/cmd/[email protected]
- go install github.com/tomarrell/wrapcheck/v2/cmd/wrapcheck@v2
dev:git-tooling:
desc: "sets up git tooling"
cmds:
- go install github.com/evilmartians/lefthook@latest
- go install github.com/siderolabs/conform/cmd/conform@latest
dev:provision:all:
desc: "sets up the workspace, linters, git tooling and gets dependecies"
cmds:
- task: dev:git-tooling
- task: dev:install-linters
- task: dev:provision
build:
desc: "build the compiled binary"
cmds:
- go build -v -ldflags "-s -w -X 'main.Version=head' -X 'main.BuildTime={{now | date "2006-01-02"}}' -X 'main.GitCommit={{.GIT_COMMIT}}'" -o bin/{{.EXE}}
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
build:container:
desc: "build the docker container"
cmds:
- docker build -t ghcr.io/eisenwinter/gotrxx:dev .
assets:sass:
desc: "Rebuilds the sass unminified"
cmds:
- sass templates/static/sass/main.sass templates/static/css/main.css
assets:sass:minified:
desc: "Rebuilds the sass minified"
cmds:
- sass templates/static/sass/main.sass templates/static/css/main.css --style compressed
lint:golangci:
desc: "Runs golang ci linter"
cmds:
- golangci-lint --verbose run
silent: true
lint:goreportcard:
desc: "Runs goreportcard"
cmds:
- goreportcard-cli -v
silent: true
lint:gofmt:
desc: "Runs gofmt with -s -w"
cmds:
- gofmt -s -w ./..
silent: true
lint:wrapcheck:
desc: "Run wrapcheck"
cmds:
- wrapcheck ./...
silent: true
lint:staticcheck:
desc: "Run staticcheck"
cmds:
- staticcheck ./...
silent: true
lint:golines:
desc: "Run golines"
cmds:
- golines -w -m 100 .
silent: true
lint:all:
desc: "runs all linters"
cmds:
- task: lint:gofmt
- task: lint:golangci
- task: lint:goreportcard
- task: lint:staticcheck
- task: lint:golines
templates:dev:
desc: "Runs 11ty dev server for template styling"
dir: template_dev
cmds:
- yarn dev
silent: true
templates:restore:
desc: "restores node deps"
dir: template_dev
cmds:
- yarn
docs:serve:
desc: "Serves the docs"
cmds:
- docsify serve docs
silent: true
test:misc:certificates:
desc: "Generate test certificates"
cmds:
- openssl genrsa -out .dev/id_rsa 4096 && openssl rsa -in .dev/id_rsa -RSAPublicKey_out -out .dev/id_rsa.pub
silent: true
test:
desc: "Runs unit tests"
cmds:
- go test -v ./...
test:coverage:
desc: "Runs unit tests"
cmds:
- go test -v -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out
test:integration:sqlite:
desc: "Integration tests for the sqlite db"
cmds:
- go test -tags=integration -count=1 -v ./...
env:
INTEGRATION_TEST_DB_TYPE: sqlite
INTEGRATION_TEST_DB_DSN: :memory:?cache=shared
silent: true
test:integration:sqlite:coverage:
desc: "Integration tests for the sqlite db"
cmds:
- go test -coverprofile=coverage.out -tags=integration -count=1 -v ./...
- go tool cover -html=coverage.out
env:
INTEGRATION_TEST_DB_TYPE: sqlite
INTEGRATION_TEST_DB_DSN: :memory:?cache=shared
silent: true
test:integration:mariadb:
desc: "Integration tests for the maria/mysql db (runs on mariadb:10.9.2)"
cmds:
- docker start gotrxx-mariadb || docker run -d -p 3306:3306 --name gotrxx-mariadb --env MARIADB_DATABASE=gotrxx --env MARIADB_USER=example --env MARIADB_PASSWORD=example --env MARIADB_ROOT_PASSWORD=secret-example docker.io/library/mariadb:10.9.2
- go test -tags=integration -count=1 -v ./...
# - docker stop gotrxx-mariadb
env:
INTEGRATION_TEST_DB_TYPE: mysql
INTEGRATION_TEST_DB_DSN: example:example@tcp(localhost:3306)/gotrxx
silent: true
test:integration:pg:
desc: "Integration tests for the postgres db (runs on postgres:14.5)"
cmds:
- docker start gotrxx-pg || docker run -d -p 5432:5432 --name gotrxx-pg --env POSTGRES_USER=example --env POSTGRES_PASSWORD=example --env POSTGRES_DB=gotrxx docker.io/library/postgres:14.5
- go test -tags=integration -count=1 -v ./...
# - docker stop gotrxx-pg
env:
INTEGRATION_TEST_DB_TYPE: pg
INTEGRATION_TEST_DB_DSN: postgres://example:example@localhost:5432/gotrxx
silent: true