-
Notifications
You must be signed in to change notification settings - Fork 1
169 lines (145 loc) · 6.26 KB
/
test-visor.yml
File metadata and controls
169 lines (145 loc) · 6.26 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
name: 🧪 Test Visor CLI
on:
pull_request:
branches: [ main ]
workflow_dispatch: # Allow manual triggering
jobs:
test-visor:
name: Test Visor Analysis
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: 📦 Install dependencies
run: npm ci
- name: 🏗️ Build Visor
run: npm run build
- name: 🔗 Ensure main branch exists
run: |
# Fetch main branch to enable diff comparisons
git fetch origin main:main || git branch main || echo "main branch already exists"
- name: 🔍 Test CLI Basic Functionality
run: |
chmod +x ./dist/index.js
echo "Testing Visor CLI help..."
./dist/index.js --cli --help
echo "Testing Visor CLI version..."
./dist/index.js --cli --version
- name: 🧪 Create test changes for analysis
run: |
echo "Creating dummy changes for CLI tests..."
echo "test content for CI" > test-file.txt
git add test-file.txt
- name: 🧪 Test JSON Output
run: |
echo "Testing JSON output format..."
./dist/index.js --cli --check security --output json 2>/dev/null | jq '.summary.overallScore' || {
echo "JSON output test failed"
exit 1
}
- name: 🧪 Test SARIF Output
run: |
echo "Testing SARIF output format..."
./dist/index.js --cli --check security --output sarif 2>/dev/null | jq '.version' || {
echo "SARIF output test failed"
exit 1
}
- name: 🧪 Test Markdown Output
run: |
echo "Testing Markdown output format..."
echo "Running: ./dist/index.js --cli --check performance --output markdown"
# Capture output and exit code (disable exit-on-error temporarily)
set +e
OUTPUT=$(./dist/index.js --cli --check performance --output markdown 2>&1)
EXIT_CODE=$?
set -e
echo "Exit code: $EXIT_CODE"
echo ""
echo "=== Output (first 50 lines) ==="
echo "$OUTPUT" | head -50
echo "=== End of output ==="
echo ""
# Check for expected pattern
if echo "$OUTPUT" | grep -qi "analysis results"; then
echo "✅ PASS: Found 'analysis results' in markdown output"
else
echo "❌ FAIL: 'analysis results' not found in markdown output"
echo ""
echo "Searching for alternative patterns:"
echo " - Contains 'Visor': $(echo "$OUTPUT" | grep -c 'Visor' || echo 0)"
echo " - Contains 'Summary': $(echo "$OUTPUT" | grep -c 'Summary' || echo 0)"
echo " - Contains '#': $(echo "$OUTPUT" | grep -c '^#' || echo 0)"
echo ""
echo "=== Full output for debugging ==="
echo "$OUTPUT"
exit 1
fi
- name: 🧪 Test Table Output
run: |
echo "Testing Table output format..."
echo "Running: ./dist/index.js --cli --check architecture --output table"
# Capture output and exit code (disable exit-on-error temporarily)
set +e
OUTPUT=$(./dist/index.js --cli --check architecture --output table 2>&1)
EXIT_CODE=$?
set -e
echo "Exit code: $EXIT_CODE"
echo ""
echo "=== Output (first 50 lines) ==="
echo "$OUTPUT" | head -50
echo "=== End of output ==="
echo ""
# Check for expected pattern
if echo "$OUTPUT" | grep -q "Analysis Summary"; then
echo "✅ PASS: Found 'Analysis Summary' in table output"
else
echo "❌ FAIL: 'Analysis Summary' not found in table output"
echo ""
echo "Searching for alternative patterns:"
echo " - Contains 'Summary': $(echo "$OUTPUT" | grep -c 'Summary' || echo 0)"
echo " - Contains '─': $(echo "$OUTPUT" | grep -c '─' || echo 0)"
echo " - Contains 'Check': $(echo "$OUTPUT" | grep -c 'Check' || echo 0)"
echo ""
echo "=== Full output for debugging ==="
echo "$OUTPUT"
exit 1
fi
- name: 📊 Generate Sample Reports
run: |
# Generate reports in all formats for artifact upload (using mock provider)
./dist/index.js --cli --check all --config .visor.test.yaml --provider mock --output json 2>/dev/null > sample-report.json || echo '{"error": "Mock provider failed"}' > sample-report.json
./dist/index.js --cli --check all --config .visor.test.yaml --provider mock --output sarif 2>/dev/null > sample-report.sarif || echo '{"error": "Mock provider failed"}' > sample-report.sarif
./dist/index.js --cli --check all --config .visor.test.yaml --provider mock --output markdown 2>&1 > sample-report.md || echo "Error: Mock provider failed" > sample-report.md
./dist/index.js --cli --check all --config .visor.test.yaml --provider mock --output table 2>&1 > sample-report.txt || echo "Error: Mock provider failed" > sample-report.txt
- name: 📈 Upload Sample Reports
uses: actions/upload-artifact@v4
with:
name: visor-sample-reports
path: |
sample-report.json
sample-report.sarif
sample-report.md
sample-report.txt
retention-days: 7
- name: 🧹 Clean up test files
run: |
echo "Cleaning up test files..."
git reset HEAD test-file.txt 2>/dev/null || true
rm -f test-file.txt
- name: ✅ Verify Configuration
run: |
echo "Verifying configuration..."
if [ -f ".visor.yaml" ]; then
echo "✅ Custom configuration file found"
# Basic YAML syntax check
python3 -c "import yaml; yaml.safe_load(open('.visor.yaml'))" && echo "✅ YAML syntax valid"
else
echo "✅ Using default configuration from defaults/ folder"
fi