Skip to content

Commit

Permalink
Merge branch '5.0' into issue-372
Browse files Browse the repository at this point in the history
Signed-off-by: arhimede <[email protected]>
  • Loading branch information
arhimede authored Dec 18, 2024
2 parents 5c21e54 + 7868cc9 commit 89ee3fa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
env:
COMPOSER_DEV_MODE=1
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Collect code coverage with PHPUnit
Expand Down
3 changes: 1 addition & 2 deletions .laminas-ci/pre-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ JOB=$3
PHP_VERSION=$4
COMMAND=$(echo "${JOB}" | jq -r '.command')

echo "Running $COMMAND"
echo "Running pre-run $COMMAND"

if [[ ${COMMAND} =~ phpunit ]];then

apt-get install php"${PHP_VERSION}"-sqlite3

cp config/autoload/local.php.dist config/autoload/local.php
cp config/autoload/mail.global.php.dist config/autoload/mail.global.php
cp config/autoload/local.test.php.dist config/autoload/local.test.php

fi
35 changes: 29 additions & 6 deletions bin/composer-post-install-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,57 @@

declare(strict_types=1);

require_once 'vendor/autoload.php';

const ENVIRONMENT_DEVELOPMENT = 'development';
const ENVIRONMENT_PRODUCTION = 'production';

// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols

function copyFile(array $file): void
{
if (! in_array(getEnvironment(), $file['environment'])) {
echo "Skipping the copy of {$file['source']} due to environment settings." . PHP_EOL;
return;
}

if (is_readable($file['destination'])) {
echo "File {$file['destination']} already exists." . PHP_EOL;
echo "File {$file['destination']} already exists. Skipping..." . PHP_EOL;
return;
}

if (! copy($file['source'], $file['destination'])) {
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
} else {
if (! copy($file['source'], $file['destination'])) {
echo "Cannot copy {$file['source']} file to {$file['destination']}" . PHP_EOL;
} else {
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
}
echo "File {$file['source']} copied successfully to {$file['destination']}." . PHP_EOL;
}
}

function getEnvironment(): string
{
return getenv('COMPOSER_DEV_MODE') === '1' ? ENVIRONMENT_DEVELOPMENT : ENVIRONMENT_PRODUCTION;
}

// when adding files to the below array the `source` and `destination` paths must be relative to the project root folder
// the `environment` key will indicate on what environments the file will be copied,
$files = [
[
'source' => 'config/autoload/local.php.dist',
'destination' => 'config/autoload/local.php',
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
],
[
'source' => 'config/autoload/local.test.php.dist',
'destination' => 'config/autoload/local.test.php',
'environment' => [ENVIRONMENT_DEVELOPMENT],
],
[
'source' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist',
'destination' => 'config/autoload/mail.global.php',
'environment' => [ENVIRONMENT_DEVELOPMENT, ENVIRONMENT_PRODUCTION],
],
];

echo "Using environment setting: " . getEnvironment() . PHP_EOL;

array_walk($files, 'copyFile');

0 comments on commit 89ee3fa

Please sign in to comment.