-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (85 loc) · 3.55 KB
/
ci.yml
File metadata and controls
109 lines (85 loc) · 3.55 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
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.0', '8.1', '8.2', '8.3']
name: PHP ${{ matrix.php-version }}
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, json
coverage: xdebug
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-dev
- name: Check PHP syntax
run: find src -name "*.php" -exec php -l {} \;
- name: Test basic functionality
run: php -r "require 'vendor/autoload.php'; use ProjectStructureViewer\ProjectStructureViewer; \$viewer = ProjectStructureViewer::create(); echo 'Basic functionality test passed';"
- name: Test HTML output
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);"
- name: Test JSON output
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);"
security:
runs-on: ubuntu-latest
name: Security Check
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, json
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-dev
- name: Security check
run: |
# Check for common security issues
if grep -r "eval(" src/; then echo "Security issue: eval() found" && exit 1; fi
if grep -r "exec(" src/; then echo "Security issue: exec() found" && exit 1; fi
if grep -r "system(" src/; then echo "Security issue: system() found" && exit 1; fi
if grep -r "shell_exec(" src/; then echo "Security issue: shell_exec() found" && exit 1; fi
echo "Security check passed"
package-test:
runs-on: ubuntu-latest
name: Package Installation Test
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, json
- name: Create test project
run: |
mkdir test-project
cd test-project
composer init --name="test/project" --no-interaction
- name: Install package locally
run: |
cd test-project
composer config repositories.local path ../
composer require arcanisgk/project-structure-viewer:@dev --no-interaction
- name: Test installation
run: |
cd test-project
php -r "require 'vendor/autoload.php'; use ProjectStructureViewer\ProjectStructureViewer; \$viewer = ProjectStructureViewer::create(); echo 'Package installation test passed';"