Skip to content

Commit 9595db4

Browse files
committed
Replacing Makefile by taskfile.yaml
1 parent 96adb04 commit 9595db4

5 files changed

Lines changed: 198 additions & 141 deletions

File tree

.github/workflows/lint.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- "**.go"
88
- "go.mod"
99
- "go.sum"
10-
- "Makefile"
10+
- "Taskfile.yaml"
1111
- ".github/workflows/lint.yml"
1212
pull_request:
1313
branches: [ "**" ]
@@ -16,7 +16,7 @@ permissions:
1616
contents: read
1717

1818
jobs:
19-
test:
19+
lint:
2020
runs-on: ubuntu-latest
2121

2222
concurrency:
@@ -43,6 +43,11 @@ jobs:
4343
restore-keys: |
4444
${{ runner.os }}-go-
4545
46+
- name: Install Task
47+
run: |
48+
go install github.com/go-task/task/v3/cmd/task@latest
49+
echo "$HOME/go/bin" >> $GITHUB_PATH
50+
4651
- name: Lint
4752
run: |
48-
make lint
53+
task lint

.github/workflows/security.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- "**.go"
88
- "go.mod"
99
- "go.sum"
10-
- "Makefile"
10+
- "Taskfile.yaml"
1111
- ".github/workflows/security.yml"
1212
pull_request:
1313
branches: [ "**" ]
@@ -16,7 +16,7 @@ permissions:
1616
contents: read
1717

1818
jobs:
19-
test:
19+
security:
2020
runs-on: ubuntu-latest
2121

2222
concurrency:
@@ -43,6 +43,11 @@ jobs:
4343
restore-keys: |
4444
${{ runner.os }}-go-
4545
46+
- name: Install Task
47+
run: |
48+
go install github.com/go-task/task/v3/cmd/task@latest
49+
echo "$HOME/go/bin" >> $GITHUB_PATH
50+
4651
- name: Security
4752
run: |
48-
make security
53+
task security

.github/workflows/test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- "**.go"
88
- "go.mod"
99
- "go.sum"
10-
- "Makefile"
10+
- "Taskfile.yaml"
1111
- ".github/workflows/test.yml"
1212
pull_request:
1313
branches: [ "**" ]
@@ -43,9 +43,14 @@ jobs:
4343
restore-keys: |
4444
${{ runner.os }}-go-
4545
46+
- name: Install Task
47+
run: |
48+
go install github.com/go-task/task/v3/cmd/task@latest
49+
echo "$HOME/go/bin" >> $GITHUB_PATH
50+
4651
- name: Run tests
4752
run: |
48-
make test
53+
task test
4954
5055
- name: Upload coverage reports to Codecov
5156
uses: codecov/codecov-action@v5

Makefile

Lines changed: 0 additions & 133 deletions
This file was deleted.

Taskfile.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
version: '3'
2+
3+
vars:
4+
APP: 'water_system'
5+
DOCKER_COMPOSE: 'COMPOSE_BAKE=true docker compose'
6+
VAULT: 'ansible-vault'
7+
GOLANGCI_LINT_VERSION: 'v2.11.4'
8+
9+
tasks:
10+
default:
11+
desc: Show available tasks
12+
cmds:
13+
- task --list
14+
15+
create-network:
16+
desc: Create Docker network
17+
cmds:
18+
- |
19+
set -euo pipefail
20+
echo "🚀 Creating {{.APP}} network..."
21+
docker network create {{.APP}}
22+
23+
docker-up:
24+
desc: Start services with Docker Compose
25+
cmds:
26+
- |
27+
set -euo pipefail
28+
echo "🚀 Starting services with Docker Compose..."
29+
{{.DOCKER_COMPOSE}} up -d --build
30+
31+
docker-down:
32+
desc: Stop and remove Docker Compose services
33+
cmds:
34+
- |
35+
set -euo pipefail
36+
echo "🛑 Stopping and removing Docker Compose services..."
37+
{{.DOCKER_COMPOSE}} down
38+
39+
docker-ps:
40+
desc: Show active Docker Compose services
41+
cmds:
42+
- |
43+
set -euo pipefail
44+
echo "📋 Active services:"
45+
{{.DOCKER_COMPOSE}} ps
46+
47+
docker-exec:
48+
desc: Open shell inside the app container
49+
cmds:
50+
- |
51+
set -euo pipefail
52+
echo "🔎 Opening shell inside ..."
53+
{{.DOCKER_COMPOSE}} exec {{.APP}} sh
54+
55+
docker-logs:
56+
desc: Follow logs for the app container
57+
cmds:
58+
- |
59+
set -euo pipefail
60+
echo "👀 Showing logs for container {{.APP}} (CTRL+C to exit)..."
61+
docker logs -f {{.APP}}
62+
63+
fmt:
64+
desc: Format code with gofumpt
65+
cmds:
66+
- |
67+
set -euo pipefail
68+
echo "👉 Formatting code with gofumpt..."
69+
go tool gofumpt -w .
70+
71+
fix:
72+
desc: Fix code
73+
cmds:
74+
- |
75+
set -euo pipefail
76+
echo "👉 Fixing code with go fix..."
77+
go fix -v ./...
78+
79+
security:
80+
desc: Check security vulnerabilities
81+
cmds:
82+
- |
83+
set -euo pipefail
84+
echo "👉 Check security"
85+
go tool govulncheck ./...
86+
87+
install-lint:
88+
desc: Install golangci-lint
89+
cmds:
90+
- |
91+
set -euo pipefail
92+
echo "🔧 Installing golangci-lint {{.GOLANGCI_LINT_VERSION}}..."
93+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@{{.GOLANGCI_LINT_VERSION}}
94+
95+
lint:
96+
desc: Run golangci-lint
97+
deps:
98+
- install-lint
99+
cmds:
100+
- |
101+
set -euo pipefail
102+
echo "🚀 Executing golangci-lint..."
103+
golangci-lint run ./...
104+
105+
test:
106+
desc: Run unit tests
107+
cmds:
108+
- |
109+
set -euo pipefail
110+
echo "🧪 Running unit tests (race, JSON → tparse)..."
111+
go test -race ./... -json -cover -coverprofile=coverage.out | go tool tparse -all
112+
113+
test-functional:
114+
desc: Run functional tests
115+
cmds:
116+
- |
117+
set -euo pipefail
118+
echo "🧪 Running functional tests..."
119+
go test -tags=functional ./... -v
120+
121+
check:
122+
desc: Run format, security, lint and tests
123+
cmds:
124+
- task: fmt
125+
- task: fix
126+
- task: security
127+
- task: lint
128+
- task: test
129+
130+
generate-schema:
131+
desc: Generate code from JSON schemas
132+
cmds:
133+
- |
134+
set -euo pipefail
135+
echo "🧪 Generating code from json schemas..."
136+
devops/scripts/import_jsonschema.sh
137+
138+
clean:
139+
desc: Clean local artifacts
140+
cmds:
141+
- |
142+
set -euo pipefail
143+
echo "🧹 Cleaning local artifacts..."
144+
rm -rf bin dist coverage .*cache || true
145+
go clean -testcache
146+
147+
edit-vault:
148+
desc: Edit Ansible vault file
149+
cmds:
150+
- |
151+
set -euo pipefail
152+
echo "🏗️ Editing vault file"
153+
{{.VAULT}} edit devops/ansible/inventories/production/group_vars/raspberry_water_system/vault.yml
154+
155+
build:
156+
desc: Build ARM64 binary for Raspberry Pi
157+
deps:
158+
- clean
159+
cmds:
160+
- |
161+
set -euo pipefail
162+
echo "🏗️ Building ARM64 binary for Raspberry Pi..."
163+
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
164+
go build -a -ldflags "-s -w" -tags prod -buildvcs=false \
165+
-o devops/ansible/assets/server ./cmd/server/
166+
167+
deploy:
168+
desc: Deploy with Ansible
169+
deps:
170+
- build
171+
cmds:
172+
- |
173+
set -euo pipefail
174+
echo "🚚 Deploying with Ansible (production inventory)..."
175+
ansible-playbook -i devops/ansible/inventories/production/hosts devops/ansible/deploy.yml --ask-vault-pass

0 commit comments

Comments
 (0)