-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
193 lines (167 loc) · 8.57 KB
/
Taskfile.yml
File metadata and controls
193 lines (167 loc) · 8.57 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
version: "3"
vars:
APP_NAME: node-manager-plugin
BIN_DIR: build
MAINNET_VERSION: "MAIN.4.2"
BUILDNET_VERSION: "DEVN.29.2"
NODE_MASSA_DIR: "build/node-massa"
tasks:
install:
desc: Install development dependencies (swagger, mockery, gofumpt, golangci-lint)
cmds:
- cmd: go install github.com/go-swagger/go-swagger/cmd/swagger@latest
- cmd: go install github.com/vektra/mockery/v3@v3.5.0
- cmd: go install mvdan.cc/gofumpt@v0.8.0
- cmd: go install github.com/daixiang0/gci@v0.13.4
- cmd: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.0
generate:
desc: Generate code and mocks
cmds:
- cmd: go generate -x -v ./...
- task: generate-mocks
- task: setup-node-folder
generate-mocks:
desc: Generate mock files using mockery
cmds:
- cmd: mockery
generate-test-data:
desc: Generate test data for database tests
cmds:
- cmd: go run int/db/test_data/generate_test_data.go
setup-node-folder:
desc: Setup node binaries for different platforms (mainnet and buildnet)
cmds:
- cmd: scripts/setup-node-unix.sh {{.MAINNET_VERSION}} {{.BUILDNET_VERSION}} {{.MAINNET_NODEBIN}} {{.BUILDNET_NODEBIN}} {{.NODE_MASSA_DIR}}
platforms: [linux, darwin]
# window
## create the NODE_MASSA_DIR directory inside the BIN_DIR directory
- cmd: powershell -Command "New-Item -Path '{{.NODE_MASSA_DIR}}' -ItemType Directory -Force"
platforms: [windows]
## handle mainnet
### extract the mainnet node binary zip file and remove the zip file
- cmd: curl.exe -Ls -o {{.MAINNET_NODEBIN}} https://github.com/massalabs/massa/releases/download/{{.MAINNET_VERSION}}/{{.MAINNET_NODEBIN}}
platforms: [windows]
### "mv <mainnetDir>/massa/* <mainnetDir>/" and remove the <mainnetDir>/massa/ directory
- cmd: powershell -Command "New-Item -Path '{{.MAINNET_VERSION}}' -ItemType Directory -Force; Expand-Archive -Path '{{.MAINNET_NODEBIN}}' -DestinationPath '{{.MAINNET_VERSION}}'; Remove-Item '{{.MAINNET_NODEBIN}}'"
platforms: [windows]
### "mv <mainnetDir>/massa/* <mainnetDir>/" and remove the <mainnetDir>/massa/ directory
- cmd: powershell -Command "Move-Item -Path '{{.MAINNET_VERSION}}\massa\*' -Destination '{{.MAINNET_VERSION}}'; Remove-Item -Path '{{.MAINNET_VERSION}}\massa' -Recurse -Force"
platforms: [windows]
## handle buildnet
### download the buildnet node binary zip file
- cmd: curl.exe -Ls -o {{.BUILDNET_NODEBIN}} https://github.com/massalabs/massa/releases/download/{{.BUILDNET_VERSION}}/{{.BUILDNET_NODEBIN}}
platforms: [windows]
### extract the buildnet node binary zip file and remove the zip file
- cmd: powershell -Command "New-Item -Path '{{.BUILDNET_VERSION}}' -ItemType Directory -Force; Expand-Archive -Path '{{.BUILDNET_NODEBIN}}' -DestinationPath '{{.BUILDNET_VERSION}}'; Remove-Item '{{.BUILDNET_NODEBIN}}'"
platforms: [windows]
### "mv <buildnetDir>/massa/* <buildnetDir>/" and remove the <buildnetDir>/massa/ directory
- cmd: powershell -Command "Move-Item -Path '{{.BUILDNET_VERSION}}\massa\*' -Destination '{{.BUILDNET_VERSION}}'; Remove-Item -Path '{{.BUILDNET_VERSION}}\massa' -Recurse -Force"
platforms: [windows]
# move buildnet and mainnet folder into the NODE_MASSA_DIR directory.
- cmd: powershell -Command "Remove-Item -Path '{{.NODE_MASSA_DIR}}\*' -Recurse -Force; Move-Item -Path '{{.BUILDNET_VERSION}}' -Destination '{{.NODE_MASSA_DIR}}'; Move-Item -Path '{{.MAINNET_VERSION}}' -Destination '{{.NODE_MASSA_DIR}}'"
platforms: [windows]
vars:
OS_NAME: '{{if eq OS "darwin"}}{{if or (eq .ARCH "arm64") (eq ARCH "arm64")}}macos_aarch64{{else}}macos{{end}}{{else}}{{OS}}{{end}}'
ARCHIVE_EXT: '{{if eq OS "windows"}}zip{{else}}tar.gz{{end}}'
MAINNET_NODEBIN: "massa_{{.MAINNET_VERSION}}_release_{{.OS_NAME}}.{{.ARCHIVE_EXT}}"
BUILDNET_NODEBIN: "massa_{{.BUILDNET_VERSION}}_release_{{.OS_NAME}}.{{.ARCHIVE_EXT}}"
# This task is used to setup windows node binaries in linux environment.
# It is used in github action workflow ci
ci-setup-windows-node-with-unix:
desc: Setup Windows node binaries in Linux CI environment
platforms: [linux]
cmds:
- cmd: scripts/ci-setup-node-from-linux.sh {{.MAINNET_VERSION}} {{.BUILDNET_VERSION}} {{.NODE_MASSA_DIR}}
vars:
MAINNET_NODEBIN: "massa_{{.MAINNET_VERSION}}_release_windows.zip"
BUILDNET_NODEBIN: "massa_{{.BUILDNET_VERSION}}_release_windows.zip"
run:
desc: Run the built application in standalone mode
cmds:
- cmd: ./build/node-manager-plugin
env:
STANDALONE: 1
LOG_LEVEL: DEBUG
build-backend:
desc: Internal build task
cmds:
- cmd: 'echo Building node-manager {{.APP_NAME}} for $GOOS/$GOARCH'
silent: true
- cmd: 'echo Mode: {{if eq .PRODUCTION "true"}}Production{{else}}Development{{end}}'
silent: true
- cmd: 'echo Version: {{.VERSION | default "Development"}}'
silent: true
- cmd: go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}{{.BIN_EXT}} ./main.go
vars:
PRODUCTION: '{{if ne .VERSION nil}}{{if ne .VERSION ""}}true{{end}}{{end}}'
VERSION_FLAG: '{{if ne .VERSION nil}}{{if ne .VERSION ""}}-X github.com/massalabs/node-manager-plugin/int/config.Version={{.VERSION}}{{end}}{{end}}'
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production {{end}}-ldflags="{{.VERSION_FLAG}}{{if eq .PRODUCTION "true"}} -w -s{{end}}"'
BIN_EXT: '{{if eq .OS "windows"}}.exe{{end}}'
env:
GOOS: "{{if eq .OS \"Windows_NT\"}}windows{{else}}{{.OS | default OS}}{{end}}"
GOARCH: "{{.ARCH | default ARCH}}"
VERSION: "{{.VERSION | default nil}}"
build-frontend:
desc: Build the web frontend
dir: web
cmds:
- cmd: npm run build{{.BUILD_MODE}}
vars:
BUILD_MODE: '{{if eq .STANDALONE 1}}:standalone{{end}}'
build:
desc: Build both frontend and backend
cmds:
- task: build-frontend
- task: build-backend
build-standalone:
desc: Build in standalone mode (frontend and backend)
cmds:
- task: build-frontend
vars:
STANDALONE: 1
- task: build-backend
clean:
desc: Clean build artifacts, node_modules and generated files
cmds:
- cmd: rm -rf build && rm -rf web/node_modules && rm -rf int/api/html/dist
install-plugin:
desc: Install the plugin to MassaStation (platform-specific paths)
cmds:
- cmd: mkdir -p /usr/local/share/massastation/plugins/node-manager-plugin
platforms: [linux, darwin]
- cmd: cp build/node-manager-plugin /usr/local/share/massastation/plugins/node-manager-plugin
platforms: [linux, darwin]
- cmd: cp web/public/favicon.svg /usr/local/share/massastation/plugins/node-manager-plugin
platforms: [linux, darwin]
- cmd: cp manifest.json /usr/local/share/massastation/plugins/node-manager-plugin
platforms: [linux, darwin]
- cmd: cp -r build/node-massa /usr/local/share/massastation/plugins/node-manager-plugin
platforms: [linux, darwin]
- cmd: powershell -Command "New-Item -Path 'C:/Program Files (x86)/MassaStation/plugins/node-manager-plugin' -ItemType Directory -Force"
platforms: [windows]
- cmd: powershell -Command "Copy-Item -Path 'build/node-manager-plugin.exe' -Destination 'C:/Program Files (x86)/MassaStation/plugins/node-manager-plugin' -Force"
platforms: [windows]
- cmd: powershell -Command "Copy-Item -Path 'web/public/favicon.svg' -Destination 'C:/Program Files (x86)/MassaStation/plugins/node-manager-plugin' -Force"
platforms: [windows]
- cmd: powershell -Command "Copy-Item -Path 'manifest.json' -Destination 'C:/Program Files (x86)/MassaStation/plugins/node-manager-plugin' -Force"
platforms: [windows]
- cmd: powershell -Command "Copy-Item -Path 'build/node-massa' -Destination 'C:/Program Files (x86)/MassaStation/plugins/node-manager-plugin/node-massa' -Recurse -Force"
platforms: [windows]
test:
desc: Run Go tests for all packages
cmds:
- cmd: go test ./...
- cmd: cd web && npm run test
lint:
desc: Run golangci-lint for code quality checks
cmds:
- cmd: gofumpt -l -d -e .
- cmd: golangci-lint run
fmt:
desc: Format code (go mod tidy, gofumpt, gci, lint --fix, npm fmt)
cmds:
- cmd: go mod tidy
- cmd: gofumpt -l -w .
- cmd: gci write . --skip-generated
- cmd: golangci-lint run --fix
- cmd: cd web && npm run fmt