-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
145 lines (124 loc) · 3.88 KB
/
Copy pathTaskfile.yml
File metadata and controls
145 lines (124 loc) · 3.88 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
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
# https://taskfile.dev/
version: "3"
set: [errexit, pipefail]
env:
OPSLEVEL_GO_PKG: "github.com/opslevel/opslevel-go/v2026"
SRC_DIR: "{{.TASKFILE_DIR}}/src"
HOMEBREW_NO_AUTO_UPDATE: 1
vars:
FAKTORY_VERSION: "1.9.3"
HELPER_IMAGE: "localhost/opslevel-runner:dev"
KIND_CLUSTER: "opslevel-runner"
tasks:
ci:
desc: Workflow to run in CI
cmds:
- task: workspace
- task: lint
- task: test
lint:
desc: Formatting and linting
dir: "{{.SRC_DIR}}"
cmds:
- test -z "$(go tool gofumpt -d -e . | tee /dev/stderr)"
- go vet ./...
- go tool golangci-lint run
fix:
desc: Fix formatting and linting
dir: "{{.SRC_DIR}}"
cmds:
- task: update-opslevel-go
- go tool gofumpt -w .
- go mod tidy
- go tool golangci-lint run --fix
setup:
desc: Setup workspace for local development
cmds:
- task: install-faktory
- task: workspace
test:
desc: Run tests
dir: "{{.SRC_DIR}}"
cmds:
- go test -race -coverprofile=coverage.txt -covermode=atomic -v ./... {{ .CLI_ARGS }}
silent: true
update-opslevel-go:
desc: Update opslevel-go version to latest release
dir: "{{.SRC_DIR}}"
cmds:
- go get -u {{.OPSLEVEL_GO_PKG}}
- go mod tidy
workspace:
desc: Setup workspace for cli & opslevel-go development
dir: "{{.SRC_DIR}}"
cmds:
- cmd: echo "Setting up opslevel-go workspace..."
silent: true
- git submodule update --init --recursive
- go work init || exit 0
- go work use . submodules/opslevel-go
- cmd: echo "opslevel-go workspace ready!"
silent: true
run:
desc: Start dev environment (Faktory + workers with hot-reload via watchexec).
deps:
- task: setup-kind
dir: "{{.SRC_DIR}}"
cmds:
- go tool goreman start
build-helper-image:
desc: Build the runner helper image and load it into kind (loads on rebuild or when absent in kind).
dir: "{{.SRC_DIR}}"
deps:
- task: setup-kind
cmds:
- HELPER_IMAGE={{.HELPER_IMAGE}} {{.TASKFILE_DIR}}/bin/build-helper-image.sh {{.KIND_CLUSTER}}
stop-kind:
desc: Clean orphaned job pods and stop kind cluster
cmds:
- "{{.TASKFILE_DIR}}/bin/stop-kind.sh {{.KIND_CLUSTER}}"
# internal (not directly called) tasks
setup-kind:
internal: true
cmds:
- "{{.TASKFILE_DIR}}/bin/setup-kind.sh --wait {{.KIND_CLUSTER}}"
install-deps:
desc: Install development dependencies (redis, watchexec)
status:
- command -v redis-server
- command -v watchexec
cmds:
- task: install-deps-{{OS}}
install-deps-darwin:
internal: true
cmds:
- brew install redis watchexec kind
install-deps-linux:
internal: true
cmds:
- sudo apt-get install -y redis-server
install-faktory:
desc: Install Faktory from GitHub releases
deps:
- install-deps
cmds:
- task: install-faktory-{{OS}}
install-faktory-darwin:
internal: true
vars:
ARCH:
sh: uname -m | sed 's/x86_64/amd64/'
ASSET_PATTERN: "faktory_{{.FAKTORY_VERSION}}.macos.{{.ARCH}}.tbz"
status:
- test -x /usr/local/bin/faktory && /usr/local/bin/faktory -v | grep -q "{{.FAKTORY_VERSION}}"
cmds:
- echo "Installing Faktory {{.FAKTORY_VERSION}} for macOS ({{.ARCH}})..."
- |
DOWNLOAD_URL=$(curl --silent "https://api.github.com/repos/contribsys/faktory/releases/tags/v{{.FAKTORY_VERSION}}" \
| jq --raw-output --arg ASSET_PATTERN "{{.ASSET_PATTERN}}" \
'.assets[] | select(.name == $ASSET_PATTERN) | .browser_download_url')
curl -fsSL "$DOWNLOAD_URL" -o /tmp/{{.ASSET_PATTERN}}
- tar -xjf /tmp/{{.ASSET_PATTERN}} -C /tmp
- sudo install -m 0755 /tmp/faktory /usr/local/bin/faktory
- rm -f /tmp/{{.ASSET_PATTERN}} /tmp/faktory
- echo "Faktory {{.FAKTORY_VERSION}} installed to /usr/local/bin/faktory"