-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTaskfile.yml
More file actions
226 lines (202 loc) · 6.27 KB
/
Copy pathTaskfile.yml
File metadata and controls
226 lines (202 loc) · 6.27 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
---
version: "3"
vars:
GOLANG_CODE_PATH: "cmd"
includes:
fwci:
taskfile: .firmwareci/Taskfile.yml
dir: .firmwareci
optional: true
tasks:
#==========================
# Compilation and building
#==========================
build:
desc: Build all binaries
cmds:
- task: build:dutctl
- task: build:remotelab-server
build:dutctl:
desc: Build dutctl CLI binary
cmds:
- go build -o bin/dutctl ./cmd/dutctl/
env:
CGO_ENABLED: 0
sources:
- ./cmd/dutctl/**/*.go
generates:
- ./bin/dutctl
build:remotelab-server:
desc: Build remotelab-server binary
cmds:
- go build -o bin/remotelab-server ./cmd/remotelab-server/
env:
CGO_ENABLED: 0
sources:
- ./cmd/remotelab-server/**/*.go
generates:
- ./bin/remotelab-server
goreleaser:build:
desc: Use goreleaser to build the project
cmds:
- goreleaser build --auto-snapshot --clean
goreleaser:check:
desc: Checks if goreleaser configuration is valid
cmds:
- goreleaser check
goreleaser:release-test:
desc: Use goreleaser to test release the project
cmds:
- goreleaser release --draft --snapshot --clean
sources:
- .goreleaser.yaml
- cmds/**/*.go
- go.mod
- go.sum
- internal/**/*.go
- pkg/**/*.go
- protobuf/**/*.go
- protobuf/**/*.proto
- scripts/*
env:
GITHUB_TOKEN: "dummy"
#========================
# Formatting and linting
#========================
format:
desc: Run gofumt (fork of gofmt, stricter)
cmds:
- gofumpt -w '{{.GOLANG_CODE_PATH}}'
- gofumpt -w 'pkg'
lint:
desc: Run the linters
cmds:
- revive ./...
- go vet ./...
- staticcheck -fail "" ./...
- golangci-lint run --issues-exit-code 0 ./...
#=========
# Testing
#=========
fwci:validate:
desc: Validate FWCI files
cmds:
- fwci validate
fwci:sync:
desc: Synchronize the repository with the CI
cmds:
- yes | fwci sync --force
sources:
- ./.firmwareci/**/*.yaml
- ./.firmwareci/**/Taskfile.yml
- ./Taskfile.yml
fwci:job:
desc: Submit a job
deps:
- fwci:sync
vars:
DUTCTL_PATH:
sh: ls ./bin/dutctl_linux_amd64_*/dutctl
DUTCTL_PKG_PATH:
sh: ls ./bin/dutctl_*_arm64.deb
CONFIG: ./contrib/dutagent-cfg-example.yaml
cmds:
- fwci job --workflow="test-dutctl" "DUTCTL={{.DUTCTL_PATH}}" "REMOTE_PKG={{.DUTCTL_PKG_PATH}}" "CONFIG={{.CONFIG}}" "DUMMY_SPI_FLASH_ROM=.firmwareci/dummy_binary.rom" "TASKFILE=.firmwareci/Taskfile.yml"
#sources:
# - ./.firmwareci/**/*.yaml
# - ./.firmwareci/**/Taskfile.yml
# - ./Taskfile.yml
# - ./bin/*.deb
# - ./bin/dutctl_linux_amd64_v1/dutctl
test:
desc: Run tests
env:
LC_ALL: C
vars:
TEST_OPTIONS: '{{default "" .TEST_OPTIONS}}'
SOURCE_FILES: '{{default "./..." .SOURCE_FILES}}'
TEST_PATTERN: '{{default "." .TEST_PATTERN}}'
cmds:
- go test $(go list ./... | grep -v /integration/) {{.TEST_OPTIONS}} -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt {{.SOURCE_FILES}} -run {{.TEST_PATTERN}} -timeout=5m
test:integration:
desc: Setup environment and run integration tests
dir: integration
cmds:
# Setup integration environment
- ./integration.sh
# Spin up docker
- docker-compose up -d remotelab-server
- docker-compose up dutctl
# Shutdown
- docker-compose down
#================
# Manual testing
#================
test:manual-prep:
desc: Prepare the RPI manually
deps:
- goreleaser:release-test
vars:
DUTCTL:
sh: ls ./bin/dutctl_linux_amd64_*/dutctl
REMOTE_PKG:
sh: ls ./bin/dutctl_*_arm64.deb
#CONFIG: ./test/test-dutagent-cfg.yaml
CONFIG: ./contrib/dutagent-cfg-example.yaml
DUMMY_SPI_FLASH_ROM: ./.firmwareci/dummy_binary.rom
TASKFILE: .firmwareci/Taskfile.yml
RPI: fwci-dutctl-tester.firmwareci.9e.network
DUTCTL_CONFIG_FILE: /etc/dutctl.yaml
cmds:
- echo "{{.DUTCTL}}"
- echo "{{.REMOTE_PKG}}"
# Copy over and install the DEB package
- scp "{{.REMOTE_PKG}}" root@{{.RPI}}:/dutctl.deb
- ssh root@{{.RPI}} dpkg -i /dutctl.deb
# Copy over the testing config
- scp "{{.CONFIG}}" root@{{.RPI}}:{{.DUTCTL_CONFIG_FILE}}
- ssh root@{{.RPI}} chmod 644 {{.DUTCTL_CONFIG_FILE}}
# Start fake serial
- ssh root@{{.RPI}} bash -c "socat -x pty,rawer,icanon=0,nonblock,link=/home/oscar/ttyS1 pty,rawer,icanon=0,nonblock,link=/home/oscar/ttyS2 & disown"
# Systemd
- ssh root@{{.RPI}} systemctl daemon-reload
- ssh root@{{.RPI}} systemctl start dutagent.service
test:manual-unprep:
desc: UN-Prepare the RPI manually
vars:
DUTCTL:
sh: ls ./bin/dutctl_linux_amd64_*/dutctl
REMOTE_PKG:
sh: ls ./bin/dutctl_*_arm64.deb
CONFIG: ./test/test-dutagent-cfg.yaml
DUMMY_SPI_FLASH_ROM: ./.firmwareci/dummy_binary.rom
TASKFILE: .firmwareci/Taskfile.yml
RPI: fwci-dutctl-tester.firmwareci.9e.network
DUTCTL_CONFIG_FILE: /etc/dutctl.yaml
cmds:
# Debug
- echo "{{.DUTCTL}}"
- echo "{{.REMOTE_PKG}}"
# Cleanup - use 'defer' so that all commands get executed, even if some fail
- defer: ssh root@{{.RPI}} systemctl stop dutagent.service
- defer: ssh root@{{.RPI}} apt remove --assume-yes dutctl
- defer: ssh root@{{.RPI}} rm /etc/dutctl.yaml
- defer: ssh root@{{.RPI}} rm /dutctl.deb
- defer: ssh root@{{.RPI}} pkill socat
test:reload-config:
desc: Upload new dutctl config and restart the service
vars:
DUTCTL:
sh: ls ./bin/dutctl_linux_amd64_*/dutctl
REMOTE_PKG:
sh: ls ./bin/dutctl_*_arm64.deb
CONFIG: ./test/test-dutagent-cfg.yaml
DUMMY_SPI_FLASH_ROM: ./.firmwareci/dummy_binary.rom
TASKFILE: .firmwareci/Taskfile.yml
RPI: fwci-dutctl-tester.firmwareci.9e.network
DUTCTL_CONFIG_FILE: /etc/dutctl.yaml
cmds:
- scp "{{.CONFIG}}" root@{{.RPI}}:{{.DUTCTL_CONFIG_FILE}}
- ssh root@{{.RPI}} chmod 644 {{.DUTCTL_CONFIG_FILE}}
- ssh root@{{.RPI}} systemctl daemon-reload
- ssh root@{{.RPI}} systemctl restart dutagent.service