Skip to content

Commit daa8a6a

Browse files
authored
ci: add integration tests for CLI command patterns (#81)
1 parent 2a5b3b7 commit daa8a6a

4 files changed

Lines changed: 119 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,80 @@ jobs:
8787

8888
- name: Build
8989
run: go build -v ./...
90+
91+
integration-test:
92+
name: Integration Test
93+
runs-on: ubuntu-latest
94+
needs: [build]
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- name: Set up Go
99+
uses: actions/setup-go@v5
100+
with:
101+
go-version: '1.24'
102+
103+
- name: Build binary
104+
run: go build -o raptor ./cmd/raptor
105+
106+
- name: Test - No arguments (shows help)
107+
run: |
108+
OUTPUT=$(./raptor 2>&1) || true
109+
echo "$OUTPUT"
110+
echo "$OUTPUT" | grep -q "Usage: raptor"
111+
112+
- name: Test - help command
113+
run: |
114+
./raptor help | grep -q "Usage: raptor"
115+
116+
- name: Test - -h flag
117+
run: |
118+
./raptor -h | grep -q "Usage: raptor"
119+
120+
- name: Test - --help flag
121+
run: |
122+
./raptor --help | grep -q "Usage: raptor"
123+
124+
- name: Test - version command
125+
run: |
126+
./raptor version | grep -q "raptor"
127+
128+
- name: Test - -v flag
129+
run: |
130+
./raptor -v | grep -q "raptor"
131+
132+
- name: Test - --version flag
133+
run: |
134+
./raptor --version | grep -q "raptor"
135+
136+
- name: Test - unknown command (should fail)
137+
run: |
138+
if ./raptor unknown-command 2>&1; then
139+
echo "Expected failure but got success"
140+
exit 1
141+
fi
142+
./raptor unknown-command 2>&1 | grep -q "unknown command"
143+
144+
- name: Test - dry-run mode (without run command)
145+
run: |
146+
./raptor -w testdata/workflows/simple.yml 2>&1 | grep -q -E "(dry-run|Dry-run|DRY)"
147+
148+
- name: Test - run with dry-run flag
149+
run: |
150+
./raptor run -w testdata/workflows/simple.yml -n 2>&1
151+
152+
- name: Test - run with --dry-run flag
153+
run: |
154+
./raptor run -w testdata/workflows/simple.yml --dry-run 2>&1
155+
156+
- name: Test - run specific job with dry-run
157+
run: |
158+
./raptor run -w testdata/workflows/multi-job.yml -j build -n 2>&1
159+
160+
- name: Test - missing workflow flag (should fail)
161+
run: |
162+
if ./raptor run 2>&1; then
163+
echo "Expected failure but got success"
164+
exit 1
165+
fi
166+
./raptor run 2>&1 | grep -q -E "(workflow|required)"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# Binaries for programs and plugins
55
bin/
6+
raptor
67
*.exe
78
*.exe~
89
*.dll

testdata/workflows/multi-job.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Multi Job Workflow
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Build step
12+
run: echo "Building..."
13+
14+
test:
15+
runs-on: ubuntu-latest
16+
needs: [build]
17+
steps:
18+
- name: Test step
19+
run: echo "Testing..."
20+
21+
deploy:
22+
runs-on: ubuntu-latest
23+
needs: [test]
24+
steps:
25+
- name: Deploy step
26+
run: echo "Deploying..."

testdata/workflows/simple.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Simple Test Workflow
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Echo hello
12+
run: echo "Hello, World!"
13+
14+
- name: Show date
15+
run: date

0 commit comments

Comments
 (0)