Skip to content

Commit ea5356c

Browse files
committed
GH Actions: split PHAR build test from other tests
As things were in the CI script, the `phpcs` and `phpcbf` Phars would be build against each supported PHP version and the tests run with the `phpcs` Phar would use the Phar as build on the same PHP version as the test was being run on. This test was not representative of the reality as with each release, only one `phpcs` and one `phpcbf` phar is released. The changes in this commit: * Split the building of the Phar off from the main test script. * This new `build` job: - Tests building the Phar against all supported PHP versions as an early detection system for problems in the Phar extension/Phar building script. - Uploads both phars as build against PHP 7.4. The uploaded Phars match the Phars as would be included on a release as they are build against the same PHP version as used for releases. These Phars will now also be available for PRs and merges to `master` to allow for easier testing of change proposals by issue reporters who may not have a git clone of the repo. The uploaded Phars will be available for 28 days (default 90). - Does a cursory test with both the `phpcs.phar` as well as the `phpcbf.phar` to test that the build phar files are functional. * In the `test` job, which now depends on the `build` job, the Phar will now no longer be build, but the Phar as uploaded in the `build` job - i.e. the Phar build against the same PHP version as used when releasing Phars - is downloaded and used to run the Phar test. The uploaded Phar files can be found on the "Summary" page of the `test` workflow after the build has finished for each build run.
1 parent 5e4e715 commit ea5356c

File tree

1 file changed

+60
-6
lines changed

1 file changed

+60
-6
lines changed

.github/workflows/test.yml

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,60 @@ on:
1313
workflow_dispatch:
1414

1515
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
22+
23+
name: "Build Phar on PHP: ${{ matrix.php }}"
24+
25+
continue-on-error: ${{ matrix.php == '8.2' }}
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v2
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php }}
35+
coverage: none
36+
ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On
37+
38+
- name: Build the phar
39+
run: php scripts/build-phar.php
40+
41+
- name: Upload the PHPCS phar
42+
uses: actions/upload-artifact@v2
43+
if: ${{ success() && matrix.php == '7.4' }}
44+
with:
45+
name: phpcs-phar
46+
path: ./phpcs.phar
47+
if-no-files-found: error
48+
retention-days: 28
49+
50+
- name: Upload the PHPCBF phar
51+
uses: actions/upload-artifact@v2
52+
if: ${{ success() && matrix.php == '7.4' }}
53+
with:
54+
name: phpcbf-phar
55+
path: ./phpcbf.phar
56+
if-no-files-found: error
57+
retention-days: 28
58+
59+
# Both the below only check a few files which are rarely changed and therefore unlikely to have issues.
60+
# This test is about testing that the phars are functional, *not* about whether the code style complies.
61+
- name: 'PHPCS: check code style using the Phar file to test the Phar is functional'
62+
run: php phpcs.phar ./scripts
63+
64+
- name: 'PHPCBF: fix code style using the Phar file to test the Phar is functional'
65+
run: php phpcbf.phar ./scripts
66+
1667
test:
1768
runs-on: ubuntu-latest
69+
needs: build
1870

1971
strategy:
2072
# Keys:
@@ -45,11 +97,11 @@ jobs:
4597
# Set the "short_open_tag" ini to make sure specific conditions are tested.
4698
# Also turn on error_reporting to ensure all notices are shown.
4799
if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.5' ]]; then
48-
echo '::set-output name=PHP_INI::phar.readonly=Off, error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On'
100+
echo '::set-output name=PHP_INI::error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On'
49101
elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.0' ]]; then
50-
echo '::set-output name=PHP_INI::phar.readonly=Off, error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On'
102+
echo '::set-output name=PHP_INI::error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On'
51103
else
52-
echo '::set-output name=PHP_INI::phar.readonly=Off, error_reporting=-1, display_errors=On'
104+
echo '::set-output name=PHP_INI::error_reporting=-1, display_errors=On'
53105
fi
54106
55107
- name: Install PHP
@@ -106,10 +158,12 @@ jobs:
106158
if: ${{ matrix.custom_ini == false }}
107159
run: composer validate --no-check-all --strict
108160

109-
- name: Build the phar
110-
if: ${{ matrix.custom_ini == false }}
111-
run: php scripts/build-phar.php
161+
- name: Download the PHPCS phar
162+
uses: actions/download-artifact@v2
163+
with:
164+
name: phpcs-phar
112165

166+
# This test specifically tests that the Phar which will be released works correctly on all PHP versions.
113167
- name: 'PHPCS: check code style using the Phar file'
114168
if: ${{ matrix.custom_ini == false }}
115169
run: php phpcs.phar

0 commit comments

Comments
 (0)