-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an integration test for the composer install
- Loading branch information
Showing
4 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
|
||
integration-test-composer: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.3 | ||
tools: composer:v2 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# Github doesn't seem to like a working-directory arg for a custom action | ||
# and I ideally want to test this works as expected in the root | ||
- name: Copy test files to root | ||
run: cp test/cached-composer-install/composer.* . | ||
|
||
- name: Install with dev dependencies | ||
uses: ./cached-composer-install | ||
|
||
- name: Check all packages installed | ||
env: | ||
EXPECT_DEV_PACKAGES: installed | ||
run: php test/cached-composer-install/check-installed.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
$expect_installed = match (getenv('EXPECT_DEV_PACKAGES')) { | ||
'installed' => [ | ||
'psr/log' => true, | ||
'psr/cache' => true, | ||
], | ||
'not-installed' => [ | ||
'psr/log' => true, | ||
'psr/cache' => false, | ||
], | ||
default => throw new InvalidArgumentException('Define EXPECT_DEV_PACKAGES as installed|not-installed') | ||
}; | ||
|
||
require_once './vendor/autoload.php'; | ||
|
||
$actual = [ | ||
'psr/log' => interface_exists(\Psr\Log\LoggerInterface::class), | ||
'psr/cache' => interface_exists(\Psr\Cache\CacheItemPoolInterface::class), | ||
]; | ||
|
||
if ($actual === $expect_installed) { | ||
echo "Correct packages were installed: "; | ||
print_r($actual); | ||
exit; | ||
} | ||
|
||
print "Installed packages: "; | ||
print_r($actual); | ||
print "Did not match expected: "; | ||
print_r($expect_installed); | ||
exit(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"require": { | ||
"psr/log": "^3.0" | ||
}, | ||
"require-dev": { | ||
"psr/cache": "^3.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.