66 pull_request :
77 branches : [ main, master, develop ]
88 schedule :
9- - cron : ' 0 0 * * 0' # Weekly on Sunday
9+ - cron : ' 0 0 * * 0'
1010
1111jobs :
12- shellcheck :
13- name : ShellCheck Analysis
12+ lint :
13+ name : ESLint
1414 runs-on : ubuntu-latest
15-
1615 steps :
1716 - name : Checkout code
1817 uses : actions/checkout@v4
19-
20- - name : Run ShellCheck
21- uses : ludeeus/action-shellcheck@master
22- with :
23- scandir : ' .'
24- severity : warning
25- ignore_paths : ' .git node_modules'
26-
27- - name : Upload ShellCheck results
28- if : always()
29- uses : actions/upload-artifact@v3
18+
19+ - name : Setup Node.js
20+ uses : actions/setup-node@v4
3021 with :
31- name : shellcheck-results
32- path : shellcheck.log
22+ node-version : 18
23+ cache : npm
24+
25+ - name : Install dependencies
26+ run : npm ci
3327
34- code-complexity :
35- name : Code Complexity Analysis
28+ - name : Run lint
29+ run : npm run lint
30+
31+ test :
32+ name : Jest Tests
3633 runs-on : ubuntu-latest
37-
34+ needs : lint
3835 steps :
3936 - name : Checkout code
4037 uses : actions/checkout@v4
41-
42- - name : Analyze code complexity
43- run : |
44- echo "# Code Complexity Report" > complexity-report.md
45- echo "" >> complexity-report.md
46-
47- for file in zebrunner.sh lib/*.sh; do
48- if [ -f "$file" ]; then
49- lines=$(wc -l < "$file")
50- functions=$(grep -c "^[a-zA-Z_][a-zA-Z0-9_]*\s*()" "$file" || echo 0)
51- echo "## $file" >> complexity-report.md
52- echo "- Lines: $lines" >> complexity-report.md
53- echo "- Functions: $functions" >> complexity-report.md
54- echo "" >> complexity-report.md
55- fi
56- done
57-
58- cat complexity-report.md
59-
60- - name : Upload complexity report
61- uses : actions/upload-artifact@v4
38+
39+ - name : Setup Node.js
40+ uses : actions/setup-node@v4
6241 with :
63- name : complexity-report
64- path : complexity-report.md
42+ node-version : 18
43+ cache : npm
44+
45+ - name : Install dependencies
46+ run : npm ci
47+
48+ - name : Run tests with coverage
49+ run : npm test -- --coverage
6550
66- test-coverage :
67- name : Test Coverage Analysis
68- runs-on : ubuntu-latest
69-
70- steps :
71- - name : Checkout code
72- uses : actions/checkout@v4
73-
74- - name : Make scripts executable
75- run : |
76- chmod +x tests/*.sh
77- chmod +x zebrunner.sh
78- chmod +x lib/*.sh
79-
80- - name : Run tests with coverage tracking
81- run : |
82- cd tests
83- bash test_runner.sh
84-
85- - name : Generate coverage report
86- run : |
87- echo "# Test Coverage Report" > coverage-report.md
88- echo "" >> coverage-report.md
89-
90- total_functions=0
91- tested_functions=0
92-
93- for lib_file in lib/*.sh; do
94- if [ -f "$lib_file" ]; then
95- lib_name=$(basename "$lib_file" .sh)
96- test_file="tests/test_${lib_name}.sh"
97-
98- functions=$(grep -c "^[a-zA-Z_][a-zA-Z0-9_]*\s*()" "$lib_file" || echo 0)
99- total_functions=$((total_functions + functions))
100-
101- if [ -f "$test_file" ]; then
102- tests=$(grep -c "^test_" "$test_file" || echo 0)
103- tested_functions=$((tested_functions + tests))
104- echo "## $lib_name.sh" >> coverage-report.md
105- echo "- Functions: $functions" >> coverage-report.md
106- echo "- Tests: $tests" >> coverage-report.md
107- echo "- Coverage: $(awk "BEGIN {printf \"%.1f\", ($tests/$functions)*100}")%" >> coverage-report.md
108- else
109- echo "## $lib_name.sh" >> coverage-report.md
110- echo "- Functions: $functions" >> coverage-report.md
111- echo "- Tests: 0" >> coverage-report.md
112- echo "- Coverage: 0%" >> coverage-report.md
113- fi
114- echo "" >> coverage-report.md
115- fi
116- done
117-
118- overall_coverage=$(awk "BEGIN {printf \"%.1f\", ($tested_functions/$total_functions)*100}")
119- echo "## Overall Coverage" >> coverage-report.md
120- echo "- Total Functions: $total_functions" >> coverage-report.md
121- echo "- Tested Functions: $tested_functions" >> coverage-report.md
122- echo "- **Coverage: ${overall_coverage}%**" >> coverage-report.md
123-
124- cat coverage-report.md
125-
12651 - name : Upload coverage report
127- uses : actions/upload-artifact@v3
52+ uses : actions/upload-artifact@v4
12853 with :
12954 name : coverage-report
130- path : coverage-report.md
131-
55+ path : coverage
56+
13257 - name : Coverage summary
58+ if : always()
13359 run : |
13460 echo "## Test Coverage" >> $GITHUB_STEP_SUMMARY
135- cat coverage-report.md >> $GITHUB_STEP_SUMMARY
136-
137- dependency-check :
138- name : Dependency Security Check
139- runs-on : ubuntu-latest
140-
141- steps :
142- - name : Checkout code
143- uses : actions/checkout@v4
144-
145- - name : Check for vulnerable dependencies
146- run : |
147- echo "Checking Docker image versions..."
148- if [ -f docker-compose.yml ]; then
149- grep "image:" docker-compose.yml | while read -r line; do
150- echo "$line"
151- done
152- fi
153-
154- echo "Checking for outdated packages..."
155- # Add specific checks as needed
156-
157- quality-gate :
158- name : Quality Gate
159- runs-on : ubuntu-latest
160- needs : [shellcheck, code-complexity, test-coverage, dependency-check]
161-
162- steps :
163- - name : Quality gate check
164- run : |
165- echo "# Quality Gate Results" >> $GITHUB_STEP_SUMMARY
166- echo "" >> $GITHUB_STEP_SUMMARY
167- echo "✅ All quality checks passed!" >> $GITHUB_STEP_SUMMARY
168- echo "" >> $GITHUB_STEP_SUMMARY
169- echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY
170- echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
171- echo "| ShellCheck | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
172- echo "| Code Complexity | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
173- echo "| Test Coverage | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
174- echo "| Dependency Check | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
61+ if [ -f coverage/lcov.info ]; then
62+ lines=$(grep -m1 'LF:' coverage/lcov.info | cut -d: -f2)
63+ covered=$(grep -m1 'LH:' coverage/lcov.info | cut -d: -f2)
64+ percent=$(awk "BEGIN { if ($lines>0) printf \"%.1f\", ($covered/$lines)*100; else print 0 }")
65+ echo "- Lines covered: ${covered}/${lines} (${percent}%)" >> $GITHUB_STEP_SUMMARY
66+ else
67+ echo "- Coverage report not generated" >> $GITHUB_STEP_SUMMARY
68+ fi
0 commit comments