1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+
13+ strategy :
14+ matrix :
15+ php-version : ['8.0', '8.1', '8.2', '8.3']
16+
17+ name : PHP ${{ matrix.php-version }}
18+
19+ steps :
20+ - uses : actions/checkout@v4
21+
22+ - name : Setup PHP
23+ uses : shivammathur/setup-php@v2
24+ with :
25+ php-version : ${{ matrix.php-version }}
26+ extensions : mbstring, json
27+ coverage : xdebug
28+
29+ - name : Validate composer.json and composer.lock
30+ run : composer validate --strict
31+
32+ - name : Cache Composer packages
33+ id : composer-cache
34+ uses : actions/cache@v3
35+ with :
36+ path : vendor
37+ key : ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
38+ restore-keys : |
39+ ${{ runner.os }}-php-${{ matrix.php-version }}-
40+
41+ - name : Install dependencies
42+ run : composer install --prefer-dist --no-progress --no-dev
43+
44+ - name : Check PHP syntax
45+ run : find src -name "*.php" -exec php -l {} \;
46+
47+ - name : Test basic functionality
48+ run : php -r "require 'vendor/autoload.php'; use ProjectStructureViewer\ProjectStructureViewer; \$viewer = ProjectStructureViewer::create(); echo 'Basic functionality test passed';"
49+
50+ - name : Test HTML output
51+ run : php -r "require 'vendor/autoload.php'; use ProjectStructureViewer\ProjectStructureViewer; \$viewer = ProjectStructureViewer::create(); \$html = \$viewer->toHtml('Test'); if (strlen(\$html) > 100) echo 'HTML output test passed'; else exit(1);"
52+
53+ - name : Test JSON output
54+ run : php -r "require 'vendor/autoload.php'; use ProjectStructureViewer\ProjectStructureViewer; \$viewer = ProjectStructureViewer::create(); \$json = \$viewer->toJson(); if (json_decode(\$json)) echo 'JSON output test passed'; else exit(1);"
55+
56+ security :
57+ runs-on : ubuntu-latest
58+ name : Security Check
59+
60+ steps :
61+ - uses : actions/checkout@v4
62+
63+ - name : Setup PHP
64+ uses : shivammathur/setup-php@v2
65+ with :
66+ php-version : ' 8.1'
67+ extensions : mbstring, json
68+
69+ - name : Install dependencies
70+ run : composer install --prefer-dist --no-progress --no-dev
71+
72+ - name : Security check
73+ run : |
74+ # Check for common security issues
75+ if grep -r "eval(" src/; then echo "Security issue: eval() found" && exit 1; fi
76+ if grep -r "exec(" src/; then echo "Security issue: exec() found" && exit 1; fi
77+ if grep -r "system(" src/; then echo "Security issue: system() found" && exit 1; fi
78+ if grep -r "shell_exec(" src/; then echo "Security issue: shell_exec() found" && exit 1; fi
79+ echo "Security check passed"
80+
81+ package-test :
82+ runs-on : ubuntu-latest
83+ name : Package Installation Test
84+
85+ steps :
86+ - uses : actions/checkout@v4
87+
88+ - name : Setup PHP
89+ uses : shivammathur/setup-php@v2
90+ with :
91+ php-version : ' 8.1'
92+ extensions : mbstring, json
93+
94+ - name : Create test project
95+ run : |
96+ mkdir test-project
97+ cd test-project
98+ composer init --name="test/project" --no-interaction
99+
100+ - name : Install package locally
101+ run : |
102+ cd test-project
103+ composer config repositories.local path ../
104+ composer require arcanisgk/project-structure-viewer:@dev --no-interaction
105+
106+ - name : Test installation
107+ run : |
108+ cd test-project
109+ php -r "require 'vendor/autoload.php'; use ProjectStructureViewer\ProjectStructureViewer; \$viewer = ProjectStructureViewer::create(); echo 'Package installation test passed';"
0 commit comments