-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTaskfile.yml
142 lines (123 loc) · 3.53 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
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
version: "3"
tasks:
integration-test:
aliases: ["it"]
desc: Startup docker resources and run integration tests. Cleanup when done.
dir: ./garden-app
cmds:
- docker compose -f ../deploy/docker-compose.yml --profile test up -d
- defer: docker volume rm deploy_influxdb
- defer: docker compose -f ../deploy/docker-compose.yml --profile test down
- sleep 15
- go test -race -covermode=atomic -coverprofile=integration_coverage.out -coverpkg=./... ./integration_tests
unit-test:
aliases: ["ut"]
desc: Run unit tests for Go app
dir: ./garden-app
cmds:
- go test -short -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./... {{.CLI_ARGS}} ./...
lint:
desc: Run linting for Go app
dir: ./garden-app
cmds:
- golangci-lint run
gofumpt:
desc: Run gofumpt to format Go app
dir: ./garden-app
cmd: gofumpt -w .
up:
desc: Start docker containers for run-local (optional args for -d)
dir: ./deploy
cmds:
- docker compose --profile run-local up {{.CLI_ARGS}}
down:
desc: Remove docker containers for run-local
dir: ./deploy
cmds:
- docker compose --profile run-local down
run:
desc: Run Go app
dir: ./garden-app
cmds:
- go run main.go {{.CLI_ARGS}}
run-server:
desc: Run backend Go app server
aliases: [rs]
dir: ./garden-app
cmds:
- go run main.go serve --config config.yaml
run-dev:
desc: Run backend Go app server and read UI templates from local FS
aliases: [dev]
dir: ./garden-app
cmds:
- DEV_TEMPLATE=server/templates/* go run main.go serve --config config.yaml
run-vcr:
desc: Run backend Go app server with VCR enabled
aliases: [vcr]
dir: ./garden-app
vars:
vcr_base_dir: server/vcr/testdata/vcr_server
env:
VCR_CASSETTE: "{{ .vcr_base_dir }}/fixtures/{{ .CLI_ARGS }}"
cmds:
- go run main.go serve --config ./{{ .vcr_base_dir }}/config.yaml
run-controller:
desc: Run mock controller
aliases: [rc]
dir: ./garden-app
cmds:
- go run main.go controller --config config.yaml --enable-ui=false
run-docker:
desc: Run backend in Docker container
aliases: [rd]
dir: ./garden-app
cmds:
- |
docker run --rm --network host \
-v ./gardens.yaml:/gardens.yaml \
-v ./config.yaml:/config.yaml \
ghcr.io/calvinmclean/garden-app:{{.CLI_ARGS | default "latest"}} \
serve --config /config.yaml
generate-mocks:
desc: Use mockery to generate mocks from Go interfaces
dir: ./garden-app/pkg
cmds:
- mockery --all --inpackage
docker-build:
desc: Build docker container
dir: ./garden-app
cmds:
- docker build --target {{.TARGET}} -t ghcr.io/calvinmclean/garden-app:{{.TAG}} .
vars:
TAG: '{{default "latest" .TAG}}'
TARGET: '{{default "production" .TARGET}}'
docker-build-demo:
cmds:
- task: docker-build
vars:
TAG: "demo"
TARGET: "demo"
docker-push-demo:
cmds:
- task: docker-push
vars:
TAG: "demo"
TARGET: "demo"
docker-push:
desc: Build and push docker container
dir: ./garden-app
cmds:
- task: docker-build
- docker push ghcr.io/calvinmclean/garden-app:{{.TAG}}
vars:
TAG: '{{default "latest" .TAG}}'
TARGET: '{{default "production" .TARGET}}'
fly:
dir: ./garden-app
cmds:
- flyctl deploy
pio:
dir: ./garden-controller
cmds:
- pio {{ .CLI_ARGS | default "run" }}