@@ -10,88 +10,99 @@ jobs:
1010 test :
1111 name : PHP Tests - ${{ matrix.os }}
1212 runs-on : ${{ matrix.os }}
13+ permissions :
14+ contents : read
1315
1416 strategy :
1517 fail-fast : false
1618 matrix :
1719 os : [ubuntu-latest, windows-latest, macos-latest]
1820
19- steps :
20- - uses : actions/checkout@v4
21-
22- # PHP installation and setup using built-in tools
23- - name : Setup PHP (Ubuntu)
24- if : matrix.os == 'ubuntu-latest'
25- run : |
26- sudo add-apt-repository ppa:ondrej/php
27- sudo apt-get update
28- sudo apt-get install -y php8.2 php8.2-cli php8.2-xml php8.2-curl php8.2-mbstring
29- php -v
30- shell : bash
31-
32- - name : Setup PHP (macOS)
33- if : matrix.os == 'macos-latest'
34- run : |
35- 36- brew link [email protected] --force 37- php -v
38- shell : bash
39-
40- - name : Setup PHP (Windows)
41- if : matrix.os == 'windows-latest'
42- run : |
43- choco install php --version=8.2 --params '"/ExtensionList:mbstring,curl,openssl,xml"'
44- refreshenv
45- php -v
46- shell : pwsh
47-
48- - name : Install dependencies (Windows)
49- if : matrix.os == 'windows-latest'
50- run : composer install --prefer-dist --no-progress --ignore-platform-req=ext-pcntl
51- shell : bash
52-
53- - name : Install Composer (Unix)
54- if : matrix.os != 'windows-latest'
55- run : |
56- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
57- sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
58- php -r "unlink('composer-setup.php');"
59- shell : bash
60-
61- - name : Validate composer.json
62- run : composer validate
63- shell : bash
64-
65- - name : Cache Composer packages
66- uses : actions/cache@v3
67- with :
68- path : vendor
69- key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
70- restore-keys : |
71- ${{ runner.os }}-php-
72-
73- - name : Install dependencies
74- run : composer install --prefer-dist --no-progress
75- shell : bash
76-
77- - name : Run test suite
78- run : vendor/bin/phpunit
79- shell : bash
80-
81- - name : Verify binary installation
82- run : |
83- php -r "require 'vendor/autoload.php'; new VoltTest\Platform();"
84- shell : bash
85-
86- - name : Upload test artifacts
87- if : always()
88- uses : actions/upload-artifact@v3
89- with :
90- name : test-results-${{ matrix.os }}
91- path : |
92- ./build/logs
93- ./phpunit.xml
94- ./coverage.xml
21+ steps :
22+ - uses : actions/checkout@v4
23+
24+ # PHP installation and setup using built-in tools
25+ - name : Setup PHP (Ubuntu)
26+ if : matrix.os == 'ubuntu-latest'
27+ run : |
28+ sudo add-apt-repository ppa:ondrej/php
29+ sudo apt-get update
30+ sudo apt-get install -y php8.2 php8.2-cli php8.2-xml php8.2-curl php8.2-mbstring
31+ php -v
32+ shell : bash
33+
34+ - name : Setup PHP (macOS)
35+ if : matrix.os == 'macos-latest'
36+ run : |
37+ 38+ brew link [email protected] --force 39+ php -v
40+ shell : bash
41+
42+ - name : Setup PHP (Windows)
43+ if : matrix.os == 'windows-latest'
44+ run : |
45+ choco install php --version=8.2 --params '"/ExtensionList:mbstring,curl,openssl,xml"'
46+ refreshenv
47+ php -v
48+ shell : pwsh
49+
50+ - name : Install Composer (Windows)
51+ if : matrix.os == 'windows-latest'
52+ run : |
53+ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
54+ php composer-setup.php
55+ php -r "unlink('composer-setup.php');"
56+ mkdir -p C:\tools\composer
57+ move composer.phar C:\tools\composer\composer
58+ echo "C:\tools\composer" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
59+ shell : pwsh
60+
61+ - name : Install Composer (Unix)
62+ if : matrix.os != 'windows-latest'
63+ run : |
64+ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
65+ sudo chmod +x /usr/local/bin/composer
66+ mkdir -p ~/.composer
67+ sudo chown -R $USER:$USER ~/.composer
68+ shell : bash
69+
70+ - name : Get Composer Cache Directory
71+ id : composer-cache
72+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
73+ shell : bash
74+
75+ - name : Cache Composer packages
76+ uses : actions/cache@v3
77+ with :
78+ path : ${{ steps.composer-cache.outputs.dir }}
79+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
80+ restore-keys : |
81+ ${{ runner.os }}-composer-
82+
83+ - name : Install dependencies (Windows)
84+ if : matrix.os == 'windows-latest'
85+ run : composer install --prefer-dist --no-progress --ignore-platform-req=ext-pcntl
86+ shell : bash
87+
88+ - name : Install dependencies (Unix)
89+ if : matrix.os != 'windows-latest'
90+ run : composer install --prefer-dist --no-progress
91+ shell : bash
92+
93+ - name : Run test suite
94+ run : vendor/bin/phpunit
95+ shell : bash
96+
97+ - name : Upload test artifacts
98+ if : always()
99+ uses : actions/upload-artifact@v3
100+ with :
101+ name : test-results-${{ matrix.os }}
102+ path : |
103+ ./build/logs
104+ ./phpunit.xml
105+ ./coverage.xml
95106
96107 static-analysis :
97108 name : Static Analysis
@@ -160,20 +171,44 @@ jobs:
160171 code-style :
161172 name : Code Style
162173 runs-on : ubuntu-latest
174+ permissions :
175+ contents : read
163176
164177 steps :
165178 - uses : actions/checkout@v4
166179
167- - name : Setup PHP and tools
180+ - name : Setup PHP
168181 run : |
169182 sudo add-apt-repository ppa:ondrej/php
170183 sudo apt-get update
171184 sudo apt-get install -y php8.2 php8.2-cli php8.2-xml php8.2-mbstring
185+ shell : bash
186+
187+ - name : Install Composer
188+ run : |
172189 curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
190+ sudo chmod +x /usr/local/bin/composer
191+ mkdir -p ~/.composer
192+ sudo chown -R $USER:$USER ~/.composer
193+ shell : bash
173194
174- - name : Install PHP CS Fixer
195+ - name : Get Composer Cache Directory
196+ id : composer-cache
197+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
198+
199+ - name : Cache Composer packages
200+ uses : actions/cache@v3
201+ with :
202+ path : ${{ steps.composer-cache.outputs.dir }}
203+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
204+ restore-keys : |
205+ ${{ runner.os }}-composer-
206+
207+ - name : Install Dependencies
175208 run : |
176- composer require --dev friendsofphp/php-cs-fixer
209+ composer install --prefer-dist --no-progress
210+ composer require --dev friendsofphp/php-cs-fixer --with-all-dependencies
211+ shell : bash
177212
178213 - name : Create PHP CS Fixer config
179214 run : |
0 commit comments