-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
221 lines (197 loc) · 6.88 KB
/
Taskfile.yaml
File metadata and controls
221 lines (197 loc) · 6.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
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
version: '3'
vars:
BINARY_NAME: msync
VERSION:
sh: git describe --tags --abbrev=0 2>/dev/null || echo "1.0.0"
BUILD_TIME:
sh: date -u '+%Y-%m-%d_%H:%M:%S'
LDFLAGS: -ldflags "-X main.version={{.VERSION}} -X main.buildTime={{.BUILD_TIME}}"
tasks:
default:
cmds:
- task: build
desc: Default task - build the binary
build:
desc: Build the binary
cmds:
- go build {{.LDFLAGS}} -o {{.BINARY_NAME}} ./cmd
generates:
- "{{.BINARY_NAME}}"
build-all:
desc: Build for multiple platforms
cmds:
- GOOS=linux GOARCH=amd64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-linux-amd64 ./cmd
- GOOS=darwin GOARCH=amd64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-darwin-amd64 ./cmd
- GOOS=darwin GOARCH=arm64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-darwin-arm64 ./cmd
- GOOS=windows GOARCH=amd64 go build {{.LDFLAGS}} -o {{.BINARY_NAME}}-windows-amd64.exe ./cmd
generates:
- "{{.BINARY_NAME}}-linux-amd64"
- "{{.BINARY_NAME}}-darwin-amd64"
- "{{.BINARY_NAME}}-darwin-arm64"
- "{{.BINARY_NAME}}-windows-amd64.exe"
test:
desc: Run unit tests
cmds:
- go test -v ./...
test-coverage:
desc: Run tests with coverage report
cmds:
- go test -v -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
generates:
- coverage.out
- coverage.html
bench:
desc: Run benchmarks
cmds:
- go test -bench=. ./...
fmt:
desc: Format code
cmds:
- go fmt ./...
lint:
desc: Run linter
cmds:
- golangci-lint run ./...
deps:
desc: Install dependencies
cmds:
- go mod download
- go mod tidy
install:
desc: Install binary to /usr/local/bin
deps: [build]
cmds:
- install -m 755 {{.BINARY_NAME}} /usr/local/bin/
clean:
desc: Clean build artifacts
cmds:
- rm -f {{.BINARY_NAME}} {{.BINARY_NAME}}-* coverage.out coverage.html
dev-setup:
desc: Set up development tools
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
integration-test:
desc: Run integration tests
deps: [build]
cmds:
- ./scripts/integration_test.sh
help:
desc: Show available tasks
cmds:
- task --list
silent: true
# TAR and GPG related tasks
test-tar:
desc: Test TAR functionality
cmds:
- go test -v ./pkg/tar/...
gpg-list-keys:
desc: List available GPG keys
cmds:
- gpg --list-keys
gpg-generate-key:
desc: Generate a new GPG key for testing
cmds:
- |
echo "Generating GPG key for msync testing..."
gpg --batch --generate-key <<EOF
Key-Type: RSA
Key-Length: 2048
Subkey-Type: RSA
Subkey-Length: 2048
Name-Real: msync Test User
Name-Email: test@msync.local
Expire-Date: 1y
%no-protection
%commit
EOF
demo-tar-basic:
desc: Demo basic TAR functionality
deps: [build]
cmds:
- mkdir -p demo/source demo/output
- echo "Hello from file1" > demo/source/file1.txt
- echo "Hello from file2" > demo/source/file2.txt
- mkdir -p demo/source/subdir
- echo "Hello from subfile" > demo/source/subdir/file3.txt
- echo "Creating TAR archive from demo/source..."
- ./{{.BINARY_NAME}} demo/source demo/output/archive.tar
- echo "Extracting TAR archive to demo/extracted..."
- ./{{.BINARY_NAME}} demo/output/archive.tar demo/extracted
- echo "Listing contents:"
- find demo/extracted -type f -exec echo {} \; -exec cat {} \;
demo-tar-compressed:
desc: Demo compressed TAR functionality
deps: [build]
cmds:
- mkdir -p demo/source demo/output
- echo "Hello from compressed file1" > demo/source/file1.txt
- echo "Hello from compressed file2" > demo/source/file2.txt
- echo "Creating compressed TAR archive..."
- ./{{.BINARY_NAME}} --tar-compress demo/source demo/output/archive.tar.gz
- echo "Archive size:"
- ls -lh demo/output/archive.tar.gz
- echo "Extracting compressed TAR archive..."
- ./{{.BINARY_NAME}} demo/output/archive.tar.gz demo/extracted-gz
- echo "Extracted contents:"
- find demo/extracted-gz -type f -exec echo {} \; -exec cat {} \;
demo-tar-encrypted:
desc: Demo GPG encrypted TAR functionality (requires GPG key)
deps: [build]
cmds:
- mkdir -p demo/source demo/output
- echo "Secret file content" > demo/source/secret.txt
- echo "Another secret" > demo/source/secret2.txt
- echo "Creating encrypted TAR archive..."
- echo "Note{{":"}} This requires a GPG key. Use 'task gpg-generate-key' first if needed."
- |
KEY_ID=$(gpg --list-keys --with-colons | grep "^pub" | head -1 | cut -d: -f5)
if [ -n "$KEY_ID" ]; then
echo "Using GPG key: $KEY_ID"
./{{.BINARY_NAME}} --gpg-encrypt --gpg-key "$KEY_ID" demo/source demo/output/encrypted.tar.gpg
echo "Encrypted archive created. Size:"
ls -lh demo/output/encrypted.tar.gpg
echo "Extracting encrypted archive..."
./{{.BINARY_NAME}} --gpg-key "$KEY_ID" demo/output/encrypted.tar.gpg demo/extracted-encrypted
echo "Decrypted contents:"
find demo/extracted-encrypted -type f -exec echo {} \; -exec cat {} \;
else
echo "No GPG keys found. Please run 'task gpg-generate-key' first."
fi
demo-tar-signed:
desc: Demo GPG signed TAR functionality (requires GPG key)
deps: [build]
cmds:
- mkdir -p demo/source demo/output
- echo "Signed file content" > demo/source/signed.txt
- echo "Another signed file" > demo/source/signed2.txt
- echo "Creating signed TAR archive..."
- |
KEY_ID=$(gpg --list-keys --with-colons | grep "^pub" | head -1 | cut -d: -f5)
if [ -n "$KEY_ID" ]; then
echo "Using GPG key: $KEY_ID"
./{{.BINARY_NAME}} --gpg-sign --gpg-key "$KEY_ID" demo/source demo/output/signed.tar.gz
echo "Signed archive created. Files:"
ls -lh demo/output/signed.tar.gz*
echo "Extracting and verifying signed archive..."
./{{.BINARY_NAME}} --gpg-key "$KEY_ID" demo/output/signed.tar.gz demo/extracted-signed
echo "Verified contents:"
find demo/extracted-signed -type f -exec echo {} \; -exec cat {} \;
else
echo "No GPG keys found. Please run 'task gpg-generate-key' first."
fi
demo-clean:
desc: Clean demo files
cmds:
- rm -rf demo/
demo-all:
desc: Run all TAR demos
cmds:
- task: demo-clean
- task: demo-tar-basic
- echo "=== Basic TAR demo completed ==="
- task: demo-tar-compressed
- echo "=== Compressed TAR demo completed ==="
- echo "=== GPG demos require GPG keys ==="
- echo "Run 'task gpg-generate-key' first, then 'task demo-tar-encrypted' and 'task demo-tar-signed'"