Skip to content

Commit

Permalink
Lock all dependencies
Browse files Browse the repository at this point in the history
We must have `composer.lock` as part of our repository. Otherwise, the
tools used for development change and break things unexpectedly.

Currently, this is the case with PHPUnit 10 that introduces quite a few
breaking changes. We cannot `composer install` and hope that we will get
a set of compatible dependencies. Instead, we must lock our tools and
upgrade them only when we want/need to upgrade them specifically, in a
dedicated commit, and not part of a totally unrelated work, because it
just so happenned that PHPUnit released something.

`composer.lock` is based on the oldest PHP version that is officially
supported by PHP core. Currently, that is 8.0. This typically gives us
compatibility out of the box for 8.0, 8.1 and 8.2 with a single lock
file.

EOL PHP versions, that we unfortunately keep supporting in PHPWord, are
"the special cases", and as such they will generate a new lock files in
CI, because we cannot have a single lock files that spread over such as
long time (almost 4 years for PHP 7.1) with major breaking change in the
language in between.
  • Loading branch information
PowerKiKi committed May 30, 2023
1 parent 0806448 commit 30c101d
Show file tree
Hide file tree
Showing 4 changed files with 4,938 additions and 6 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.1"
- "7.1.3"
- "7.2"
- "7.3"
- "7.4"
Expand Down Expand Up @@ -39,6 +39,10 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Remove lock for old EOL PHP versions
if: matrix.php-version == '7.1.3' || matrix.php-version == '7.2' || matrix.php-version == '7.3' || matrix.php-version == '7.4'
run: rm composer.lock && composer config platform.php ${{ matrix.php-version }}

- name: Install dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

Expand All @@ -63,7 +67,7 @@ jobs:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: none
tools: cs2pr
Expand All @@ -90,11 +94,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
extensions: ctype, dom, gd, iconv, fileinfo, libxml, mbstring, simplexml, xml, xmlreader, xmlwriter, zip, zlib
coverage: pcov

Expand All @@ -115,5 +121,5 @@ jobs:
- name: Coverage
run: |
./vendor/bin/phpunit --coverage-clover coverage-clover.xml
curl -LO https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage-clover.xml
composer global require scrutinizer/ocular
~/.composer/vendor/bin/ocular code-coverage:upload --format=php-clover coverage-clover.xml
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Desktop.ini
_build
/build
phpunit.xml
composer.lock
composer.phar
vendor
/report
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
"check": "Runs PHP CheckStyle and PHP Mess detector",
"fix": "Fixes issues found by PHP-CS"
},
"config": {
"platform": {
"php": "8.0"
}
},
"require": {
"php": "^7.1|^8.0",
"ext-dom": "*",
Expand Down
Loading

0 comments on commit 30c101d

Please sign in to comment.