-
Notifications
You must be signed in to change notification settings - Fork 314
262 lines (225 loc) · 7.74 KB
/
cli-test.yaml
File metadata and controls
262 lines (225 loc) · 7.74 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: CLI Test
on:
push:
branches:
- dev
paths:
- 'src/client/acontext-cli/**'
- '.github/workflows/cli-test.yaml'
pull_request:
branches:
- dev
paths:
- 'src/client/acontext-cli/**'
- '.github/workflows/cli-test.yaml'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: src/client/acontext-cli
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
with:
go-version-file: src/client/acontext-cli/go.mod
cache: true
cache-dependency-path: src/client/acontext-cli/go.sum
- name: Download dependencies
run: go mod download
- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...
- name: Upload coverage
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2
with:
file: ./coverage.out
flags: unittests
name: codecov-cli
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: src/client/acontext-cli
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
with:
go-version-file: src/client/acontext-cli/go.mod
cache: true
cache-dependency-path: src/client/acontext-cli/go.sum
- name: Tidy dependencies
run: go mod tidy
- name: Verify build works
run: go build ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20
with:
version: latest
working-directory: src/client/acontext-cli
args: --timeout=5m ./...
only-new-issues: ${{ github.event_name == 'pull_request' }}
build:
name: Build
needs: [test, lint]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
defaults:
run:
working-directory: src/client/acontext-cli
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
with:
go-version-file: src/client/acontext-cli/go.mod
cache: true
cache-dependency-path: src/client/acontext-cli/go.sum
- name: Download dependencies
run: go mod download
- name: Build
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
go build -ldflags "-X main.cliVersion=dev" -o acontext-cli.exe main.go
else
go build -ldflags "-X main.cliVersion=dev" -o acontext-cli main.go
fi
- name: Test binary
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
./acontext-cli.exe version
else
./acontext-cli version
fi
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
if: ${{ !cancelled() }}
with:
name: acontext-cli-${{ matrix.os }}
path: |
${{ matrix.os == 'windows-latest' && 'src/client/acontext-cli/acontext-cli.exe' || 'src/client/acontext-cli/acontext-cli' }}
retention-days: 30
test-install-script:
name: Test Install Script on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
defaults:
run:
working-directory: src/client/acontext-cli
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c
with:
go-version-file: src/client/acontext-cli/go.mod
cache: true
cache-dependency-path: src/client/acontext-cli/go.sum
- name: Test install script syntax
run: |
sh -n install.sh
echo "✓ Install script syntax is valid"
- name: Test install script help
run: |
sh install.sh --help
- name: Test platform detection logic
run: |
# Test that the script can detect the platform correctly
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
echo "Detected OS: $OS"
echo "Detected ARCH: $ARCH"
# Verify the script handles the platform correctly
case "$ARCH" in
x86_64)
EXPECTED_ARCH="amd64"
;;
aarch64|arm64)
EXPECTED_ARCH="arm64"
;;
*)
echo "✗ Unsupported architecture: $ARCH"
exit 1
;;
esac
case "$OS" in
linux|darwin)
echo "✓ Platform $OS/$EXPECTED_ARCH is supported"
;;
*)
echo "✗ Platform $OS is not supported"
exit 1
;;
esac
- name: Test dependency checks
run: |
# The script should check for curl/wget and tar/unzip
# These should be available on GitHub Actions runners
if command -v curl >/dev/null 2>&1 || command -v wget >/dev/null 2>&1; then
echo "✓ HTTP client (curl/wget) is available"
else
echo "✗ HTTP client is missing"
exit 1
fi
if command -v tar >/dev/null 2>&1 || command -v unzip >/dev/null 2>&1; then
echo "✓ Archive tool (tar/unzip) is available"
else
echo "✗ Archive tool is missing"
exit 1
fi
- name: Build test binary
run: |
go build -ldflags "-X main.cliVersion=dev" -o acontext-cli main.go
chmod +x acontext-cli
./acontext-cli version
- name: Test install script argument parsing
run: |
# Test that the script correctly parses --version argument
# We can't fully test installation without sudo, but we can test argument parsing
OUTPUT=$(sh install.sh --version dev 2>&1 || true)
if echo "$OUTPUT" | grep -q "Using specified version: vdev"; then
echo "✓ Install script correctly parses --version argument"
else
echo "✗ Install script failed to parse --version argument"
echo "Output: $OUTPUT"
exit 1
fi
- name: Test install script error handling
run: |
# Test that the script handles invalid arguments correctly
if sh install.sh --invalid-arg 2>&1 | grep -q "Unknown option"; then
echo "✓ Install script correctly handles invalid arguments"
else
echo "✗ Install script failed to handle invalid arguments"
exit 1
fi
# Test that --version without value shows error
if sh install.sh --version 2>&1 | grep -q "Version number required"; then
echo "✓ Install script correctly validates --version argument"
else
echo "✗ Install script failed to validate --version argument"
exit 1
fi