Skip to content

Commit

Permalink
Make symfony/clock testable locally
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Jun 19, 2024
1 parent 977e4e0 commit 537f935
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ jobs:
- name: "Composer"
uses: "orisai/github-workflows/.github/actions/setup-composer@v1"

- name: "Extra dependencies"
if: "!startsWith(matrix.php-version, '7') && !startsWith(matrix.php-version, '8.0')"
run: "composer require symfony/clock"

- name: "PHPStan"
uses: "orisai/github-workflows/.github/actions/phpstan@v1"
with:
Expand Down Expand Up @@ -134,10 +130,6 @@ jobs:
with:
command: "composer update --no-interaction --no-progress --prefer-dist ${{ matrix.composer-flags }}"

- name: "Extra dependencies"
if: "!startsWith(matrix.php-version, '7') && !startsWith(matrix.php-version, '8.0')"
run: "composer require symfony/clock"

- name: "PHPUnit"
uses: "orisai/github-workflows/.github/actions/phpunit@v1"
with:
Expand Down Expand Up @@ -206,10 +198,6 @@ jobs:
- name: "Composer"
uses: "orisai/github-workflows/.github/actions/setup-composer@v1"

- name: "Extra dependencies"
if: "!startsWith(matrix.php-version, '7') && !startsWith(matrix.php-version, '8.0')"
run: "composer require symfony/clock"

- name: "PHPUnit"
uses: "orisai/github-workflows/.github/actions/phpunit@v1"
with:
Expand Down
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,13 @@
"infection/extension-installer": true,
"phpstan/extension-installer": true
}
},
"scripts": {
"post-install-cmd": [
"php tests/install-optional-dependencies.php"
],
"post-update-cmd": [
"php tests/install-optional-dependencies.php"
]
}
}
20 changes: 20 additions & 0 deletions tests/install-optional-dependencies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types = 1);

// This is needed because symfony/clock requires newer PHP version than us

$requiredPhpVersion = '8.1.0';
$packageName = 'symfony/clock';

if (version_compare(PHP_VERSION, $requiredPhpVersion, '>=')) {
$tempComposerJson = 'composer.temp.json';
copy('composer.json', $tempComposerJson);

putenv("COMPOSER=$tempComposerJson");

passthru("composer require --dev --no-scripts $packageName");

unlink($tempComposerJson);
unlink('composer.temp.lock');
} else {
echo "Skipping $packageName installation (requires PHP $requiredPhpVersion or higher).\n";
}

0 comments on commit 537f935

Please sign in to comment.