-
-
Notifications
You must be signed in to change notification settings - Fork 0
430 lines (375 loc) · 13.7 KB
/
integration-test.yml
File metadata and controls
430 lines (375 loc) · 13.7 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
name: Integration Tests
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'tests/**'
- '.github/workflows/integration-test.yml'
pull_request:
branches: [ main ]
paths:
- 'src/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'tests/**'
- '.github/workflows/integration-test.yml'
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
integration-test:
name: E2E Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
binary: rnr
shell: bash
- os: macos-latest
binary: rnr
shell: bash
- os: windows-latest
binary: rnr.exe
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build release binary
run: cargo build --release
- name: Copy binary to test location
shell: bash
run: |
cp target/release/${{ matrix.binary }} tests/
# ==================== Basic Tests ====================
- name: "Test: --help"
shell: bash
working-directory: tests
run: |
echo "## --help output" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./${{ matrix.binary }} --help >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: "Test: --version"
shell: bash
working-directory: tests
run: |
./${{ matrix.binary }} --version
- name: "Test: --list (basic fixture)"
shell: bash
working-directory: tests/fixtures/basic
run: |
echo "## --list output (basic)" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
../../${{ matrix.binary }} --list >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# ==================== Basic Task Execution ====================
- name: "Test: shorthand task"
shell: bash
working-directory: tests/fixtures/basic
run: |
OUTPUT=$(../../${{ matrix.binary }} hello 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Hello, World!"; then
echo "ERROR: Expected 'Hello, World!' in output"
exit 1
fi
echo "✅ Shorthand task passed"
- name: "Test: full task with description"
shell: bash
working-directory: tests/fixtures/basic
run: |
OUTPUT=$(../../${{ matrix.binary }} build 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Building project"; then
echo "ERROR: Expected 'Building project' in output"
exit 1
fi
echo "✅ Full task passed"
- name: "Test: task with environment variables"
shell: bash
working-directory: tests/fixtures/basic
run: |
OUTPUT=$(../../${{ matrix.binary }} with-env 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Environment variables are set"; then
echo "ERROR: Expected 'Environment variables are set' in output"
exit 1
fi
echo "✅ Environment variables task passed"
# ==================== Steps Tests ====================
- name: "Test: sequential steps"
shell: bash
working-directory: tests/fixtures/steps
run: |
OUTPUT=$(../../${{ matrix.binary }} sequential 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Step 1"; then
echo "ERROR: Expected 'Step 1' in output"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "Step 2"; then
echo "ERROR: Expected 'Step 2' in output"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "Step 3"; then
echo "ERROR: Expected 'Step 3' in output"
exit 1
fi
echo "✅ Sequential steps passed"
- name: "Test: task delegation in steps"
shell: bash
working-directory: tests/fixtures/steps
run: |
OUTPUT=$(../../${{ matrix.binary }} delegate 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Running step A"; then
echo "ERROR: Expected 'Running step A' in output"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "Running step B"; then
echo "ERROR: Expected 'Running step B' in output"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "Running step C"; then
echo "ERROR: Expected 'Running step C' in output"
exit 1
fi
echo "✅ Task delegation passed"
- name: "Test: mixed sequential and parallel"
shell: bash
working-directory: tests/fixtures/steps
run: |
OUTPUT=$(../../${{ matrix.binary }} mixed 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Starting"; then
echo "ERROR: Expected 'Starting' in output"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "Parallel task 1"; then
echo "ERROR: Expected 'Parallel task 1' in output"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "Parallel task 2"; then
echo "ERROR: Expected 'Parallel task 2' in output"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "Done"; then
echo "ERROR: Expected 'Done' in output"
exit 1
fi
echo "✅ Mixed steps passed"
# ==================== Nested Task Tests ====================
- name: "Test: command in subdirectory"
shell: bash
working-directory: tests/fixtures/nested
run: |
OUTPUT=$(../../${{ matrix.binary }} run-in-subdir 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Running in subproject directory"; then
echo "ERROR: Expected 'Running in subproject directory' in output"
exit 1
fi
echo "✅ Command in subdirectory passed"
- name: "Test: nested task delegation"
shell: bash
working-directory: tests/fixtures/nested
run: |
OUTPUT=$(../../${{ matrix.binary }} build-subproject 2>&1)
echo "$OUTPUT"
if ! echo "$OUTPUT" | grep -q "Building subproject"; then
echo "ERROR: Expected 'Building subproject' in output"
exit 1
fi
echo "✅ Nested task delegation passed"
# ==================== Init Command Tests ====================
- name: "Test: init --current-platform-only"
shell: bash
run: |
INIT_DIR=$(mktemp -d)
cd "$INIT_DIR"
git init
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --current-platform-only
# Verify files were created
if [ ! -f ".rnr/config.yaml" ]; then
echo "ERROR: .rnr/config.yaml not created"
exit 1
fi
if [ ! -d ".rnr/bin" ]; then
echo "ERROR: .rnr/bin directory not created"
exit 1
fi
if [ ! -f "rnr.yaml" ]; then
echo "ERROR: rnr.yaml not created"
exit 1
fi
if [ ! -f "rnr" ]; then
echo "ERROR: rnr wrapper not created"
exit 1
fi
if [ ! -f "rnr.cmd" ]; then
echo "ERROR: rnr.cmd wrapper not created"
exit 1
fi
# Verify config has exactly one platform
PLATFORM_COUNT=$(grep -c "^-" .rnr/config.yaml || echo "0")
if [ "$PLATFORM_COUNT" != "1" ]; then
echo "ERROR: Expected 1 platform, got $PLATFORM_COUNT"
exit 1
fi
echo "✅ init --current-platform-only passed"
rm -rf "$INIT_DIR"
- name: "Test: init --platforms with multiple platforms"
shell: bash
run: |
INIT_DIR=$(mktemp -d)
cd "$INIT_DIR"
git init
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64,macos-arm64,windows-amd64
# Verify config has the right platforms
if ! grep -q "linux-amd64" .rnr/config.yaml; then
echo "ERROR: linux-amd64 not in config"
exit 1
fi
if ! grep -q "macos-arm64" .rnr/config.yaml; then
echo "ERROR: macos-arm64 not in config"
exit 1
fi
if ! grep -q "windows-amd64" .rnr/config.yaml; then
echo "ERROR: windows-amd64 not in config"
exit 1
fi
# Verify binaries exist
if [ ! -f ".rnr/bin/rnr-linux-amd64" ]; then
echo "ERROR: rnr-linux-amd64 binary not created"
exit 1
fi
if [ ! -f ".rnr/bin/rnr-macos-arm64" ]; then
echo "ERROR: rnr-macos-arm64 binary not created"
exit 1
fi
if [ ! -f ".rnr/bin/rnr-windows-amd64.exe" ]; then
echo "ERROR: rnr-windows-amd64.exe binary not created"
exit 1
fi
echo "✅ init --platforms passed"
rm -rf "$INIT_DIR"
- name: "Test: init --add-platform and --remove-platform"
shell: bash
run: |
INIT_DIR=$(mktemp -d)
cd "$INIT_DIR"
git init
# First init with one platform
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64
# Add a platform
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --add-platform macos-arm64
if ! grep -q "macos-arm64" .rnr/config.yaml; then
echo "ERROR: macos-arm64 not added to config"
exit 1
fi
if [ ! -f ".rnr/bin/rnr-macos-arm64" ]; then
echo "ERROR: rnr-macos-arm64 binary not created"
exit 1
fi
# Remove a platform
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --remove-platform linux-amd64
if grep -q "linux-amd64" .rnr/config.yaml; then
echo "ERROR: linux-amd64 should have been removed from config"
exit 1
fi
if [ -f ".rnr/bin/rnr-linux-amd64" ]; then
echo "ERROR: rnr-linux-amd64 binary should have been removed"
exit 1
fi
echo "✅ init --add-platform and --remove-platform passed"
rm -rf "$INIT_DIR"
- name: "Test: init --show-platforms"
shell: bash
run: |
INIT_DIR=$(mktemp -d)
cd "$INIT_DIR"
git init
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64,windows-amd64
OUTPUT=$($GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --show-platforms 2>&1)
if ! echo "$OUTPUT" | grep -q "linux-amd64"; then
echo "ERROR: --show-platforms should list linux-amd64"
exit 1
fi
if ! echo "$OUTPUT" | grep -q "windows-amd64"; then
echo "ERROR: --show-platforms should list windows-amd64"
exit 1
fi
echo "✅ init --show-platforms passed"
rm -rf "$INIT_DIR"
- name: "Test: init refuses to remove last platform"
shell: bash
run: |
INIT_DIR=$(mktemp -d)
cd "$INIT_DIR"
git init
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --platforms linux-amd64
# Try to remove the only platform - should fail
if $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --remove-platform linux-amd64 2>&1; then
echo "ERROR: Should not be able to remove last platform"
exit 1
fi
echo "✅ init correctly refuses to remove last platform"
rm -rf "$INIT_DIR"
- name: "Test: init --force skips git repo check"
shell: bash
run: |
INIT_DIR=$(mktemp -d)
cd "$INIT_DIR"
# Do NOT run git init - this is intentionally not a git repo
# Without --force, should fail
if $GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --current-platform-only 2>&1; then
echo "ERROR: init should fail without --force in non-git directory"
exit 1
fi
# With --force, should succeed
$GITHUB_WORKSPACE/tests/${{ matrix.binary }} init --current-platform-only --force
# Verify files were created
if [ ! -f ".rnr/config.yaml" ]; then
echo "ERROR: .rnr/config.yaml not created with --force"
exit 1
fi
echo "✅ init --force correctly skips git repo check"
rm -rf "$INIT_DIR"
# ==================== Error Cases ====================
- name: "Test: nonexistent task (should fail)"
shell: bash
working-directory: tests/fixtures/basic
run: |
if ../../${{ matrix.binary }} nonexistent 2>&1; then
echo "ERROR: Expected nonexistent task to fail"
exit 1
fi
echo "✅ Nonexistent task correctly failed"
# ==================== Summary ====================
- name: Generate test summary
if: always()
shell: bash
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Integration Test Results - ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ All integration tests completed" >> $GITHUB_STEP_SUMMARY