Skip to content

Commit bcfd774

Browse files
authored
refactor: migrate from make to task (#58)
* refactor: migrate from make to task * fix: trimpath argument Signed-off-by: Vladimir Parfenov <parfenov.vladimir.s@gmail.com> --------- Signed-off-by: Vladimir Parfenov <parfenov.vladimir.s@gmail.com>
1 parent a9edf60 commit bcfd774

5 files changed

Lines changed: 126 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
env:
8787
MBVPN_HOLOCRON_URL: ${{ vars.MBVPN_HOLOCRON_URL }}
8888
run: |
89-
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make build-release
89+
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} task build-release
9090
mv mbvpn ${{ env.BINARY_NAME }}
9191
9292
- name: Upload Release Asset

Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
FROM docker.io/golang:1.24
22

33
RUN apt-get update && apt-get install -y \
4+
curl \
5+
sudo \
46
wireguard \
57
iproute2 \
68
iptables \
7-
net-tools \
8-
sudo \
9-
&& rm -rf /var/lib/apt/lists/*
9+
net-tools
10+
11+
RUN curl -1sLf 'https://dl.cloudsmith.io/public/task/task/setup.deb.sh' | sudo -E bash
12+
13+
RUN apt-get update && apt-get install -y task
14+
15+
RUN rm -rf /var/lib/apt/lists/*
1016

1117
WORKDIR /app
1218

@@ -18,6 +24,6 @@ RUN go mod download
1824

1925
COPY . .
2026

21-
RUN make build-debug
27+
RUN task build-debug
2228

2329
CMD ["sh", "-c", "tail -f /dev/null"]

Taskfile.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
version: "3"
2+
3+
dotenv: [".env"]
4+
5+
vars:
6+
BINARY_NAME: mbvpn
7+
GO_PKG: github.com/malwarebytes/mbvpn-linux
8+
VERSION_MAJOR:
9+
sh: echo "${VERSION_MAJOR:-0}"
10+
VERSION_MINOR:
11+
sh: echo "${VERSION_MINOR:-0}"
12+
VERSION_PATCH:
13+
sh: echo "${VERSION_PATCH:-1}"
14+
VERSION_BUILD:
15+
sh: echo "${VERSION_BUILD:-0}"
16+
17+
# Common ldflags
18+
COMMON_LDFLAGS: >-
19+
-X '{{.GO_PKG}}/pkg/config.VersionMajor={{.VERSION_MAJOR}}'
20+
-X '{{.GO_PKG}}/pkg/config.VersionMinor={{.VERSION_MINOR}}'
21+
-X '{{.GO_PKG}}/pkg/config.VersionPatch={{.VERSION_PATCH}}'
22+
-X '{{.GO_PKG}}/pkg/config.VersionBuild={{.VERSION_BUILD}}'
23+
24+
# Environment ldflags
25+
ENV_LDFLAGS: >-
26+
-X '{{.GO_PKG}}/pkg/config.BuildEnv=production'
27+
-X '{{.GO_PKG}}/pkg/config.HolocronUrl={{.MBVPN_HOLOCRON_URL}}'
28+
29+
# Debug flags
30+
DEBUG_LDFLAGS: -X '{{.GO_PKG}}/pkg/config.BuildType=debug'
31+
DEBUG_GCFLAGS: -N -l
32+
33+
# Release flags
34+
RELEASE_LDFLAGS: -X '{{.GO_PKG}}/pkg/config.BuildType=release'
35+
RELEASE_BUILDFLAGS: -trimpath
36+
37+
tasks:
38+
build:
39+
desc: Build release version (default)
40+
cmds:
41+
- task: build-release
42+
43+
build-debug:
44+
desc: Build debug version with debug symbols
45+
cmds:
46+
- >-
47+
go build {{.GOFLAGS}}
48+
-o {{.BINARY_NAME}}
49+
-gcflags="{{.DEBUG_GCFLAGS}}"
50+
-ldflags "{{.COMMON_LDFLAGS}} {{.ENV_LDFLAGS}} {{.DEBUG_LDFLAGS}}"
51+
52+
build-release:
53+
desc: Build release version with optimizations
54+
cmds:
55+
- >-
56+
go build {{.GOFLAGS}}
57+
{{.RELEASE_BUILDFLAGS}}
58+
-o {{.BINARY_NAME}}
59+
-ldflags "{{.COMMON_LDFLAGS}} {{.ENV_LDFLAGS}} {{.RELEASE_LDFLAGS}}"
60+
61+
install:
62+
desc: Install release version (default)
63+
cmds:
64+
- task: install-release
65+
66+
install-debug:
67+
desc: Install debug version with debug symbols
68+
cmds:
69+
- >-
70+
go install
71+
-gcflags="{{.DEBUG_GCFLAGS}}"
72+
-ldflags "{{.COMMON_LDFLAGS}} {{.ENV_LDFLAGS}} {{.DEBUG_LDFLAGS}}"
73+
.
74+
75+
install-release:
76+
desc: Install release version with optimizations
77+
cmds:
78+
- >-
79+
go install
80+
{{.RELEASE_BUILDFLAGS}}
81+
-ldflags "{{.COMMON_LDFLAGS}} {{.ENV_LDFLAGS}} {{.RELEASE_LDFLAGS}}"
82+
.
83+
84+
test:
85+
desc: Run all tests
86+
cmds:
87+
- task: test-unit
88+
- task: test-integration
89+
- task: test-e2e
90+
91+
test-unit:
92+
desc: Run unit tests only
93+
cmds:
94+
- go test ./...
95+
96+
test-integration:
97+
desc: Run integration tests
98+
deps: [build-release]
99+
cmds:
100+
- go test -tags=integration -v ./test/integration/...
101+
102+
test-e2e:
103+
desc: Run end-to-end tests
104+
deps: [build-release]
105+
cmds:
106+
- go test -tags=e2e -v ./test/e2e/...
107+
env:
108+
MBVPN_TEST_LICENSE_KEY: "{{.MBVPN_TEST_LICENSE_KEY}}"
109+
110+
clean:
111+
desc: Clean build artifacts
112+
cmds:
113+
- go clean
114+
- rm -f {{.BINARY_NAME}}

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
- /dev/net/tun:/dev/net/tun
1212
volumes:
1313
- .:/app
14-
# - /lib/modules:/lib/modules
1514
sysctls:
1615
- net.ipv4.conf.all.src_valid_mark=1
1716
stdin_open: true

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
go
2020
wireguard-tools
2121
git
22-
gnumake
22+
go-task
2323
podman
2424
podman-compose
2525
podman-desktop

0 commit comments

Comments
 (0)