-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
105 lines (92 loc) · 2.52 KB
/
Taskfile.yml
File metadata and controls
105 lines (92 loc) · 2.52 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
version: "3"
vars:
FUNCNAME: titleparser
BUILDDIR: build
dotenv: [".env", "{{.ENV}}/.env.", "{{.HOME}}/.env"]
tasks:
default:
desc: Default task, runs build
cmds:
- task: build
clean:
desc: Remove build artifacts
cmds:
- rm -rf {{.BUILDDIR}}
build-local:
deps: [test]
cmds:
- go build -o {{.FUNCNAME}}
build:
desc: Build the Go application
deps:
- clean
- test
- lint
cmds:
- env GOOS=linux GOARCH=arm64 go build -ldflags="-X main.Version={{.GIT_COMMIT}}" -o {{.BUILDDIR}}/bootstrap
- cd {{.BUILDDIR}} && zip {{.FUNCNAME}}.zip bootstrap
generates:
- "{{.BUILDDIR}}/bootstrap"
- "{{.BUILDDIR}}/{{.FUNCNAME}}.zip"
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
build-ci:
desc: Build the Go application for CI (excludes tests with ci build tag)
deps:
- clean
- test-ci
cmds:
- env GOOS=linux GOARCH=arm64 go build -ldflags="-X main.Version={{.GIT_COMMIT}}" -o {{.BUILDDIR}}/bootstrap
- cd {{.BUILDDIR}} && zip {{.FUNCNAME}}.zip bootstrap
generates:
- "{{.BUILDDIR}}/bootstrap"
- "{{.BUILDDIR}}/{{.FUNCNAME}}.zip"
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
test:
cmds:
- go vet ./...
- go test -cover ./...
test-ci:
desc: Run tests excluding files with ci build tag
cmds:
- go vet ./...
- go test -tags=ci -cover -v ./...
lint:
desc: Run Go linters
cmds:
- golangci-lint run ./...
silent: true # to ignore errors but keep the output
publish:
deps: [build]
cmds:
- aws lambda update-function-code --publish --function-name {{.FUNCNAME}} --zip-file fileb://{{.BUILDDIR}}/{{.FUNCNAME}}.zip
- task: verify-deployment
verify-deployment:
desc: Verify Lambda function deployment status
silent: true
cmds:
- |
echo "Verifying deployment of {{.FUNCNAME}}..."
aws lambda get-function --function-name {{.FUNCNAME}} --query 'Configuration.[LastModified,State]' --output text
if [ $? -eq 0 ]; then
echo "✅ Function {{.FUNCNAME}} deployed successfully"
else
echo "❌ Function deployment verification failed"
exit 1
fi
upgrade-deps:
desc: Upgrade all dependencies to their latest versions
silent: true
cmds:
- go get -u ./...
- go mod tidy
- echo "✅ Dependencies upgraded successfully"
sources:
- go.mod
- go.sum
generates:
- go.mod
- go.sum