Skip to content

Commit

Permalink
fix: fix dotenv loader to work without request matcher and fix tests (#…
Browse files Browse the repository at this point in the history
…71)

* tests: fix tests to work after updates

* fix: fix dotenv loader to work without request matcher and to support grouping

* Update test-drupal-setup.yml
  • Loading branch information
fago authored Apr 16, 2024
1 parent 8d442cc commit b911452
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test-drupal-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
branches:
- '6.**'
pull_request:
types: [opened, reopened]
types: [opened, reopened, edited]
jobs:
test-drupal-setup:
name: Build and install drupal project
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup PHP
run: |
sudo update-alternatives --set php /usr/bin/php8.1
Expand All @@ -37,6 +37,7 @@ jobs:
- name: Install composer dependencies.
run: |
composer config platform-check false
composer config --no-plugins allow-plugins.phpstan/extension-installer true
composer create-project
composer install
- name: Setup the environment
Expand All @@ -54,4 +55,4 @@ jobs:
docker-compose exec cli phapp install --no-build
- name: Check connection and response of the site
run: |
curl -v http://example.drupal-project.localdev.space | grep "Drupal 9"
curl -v http://example.drupal-project.localdev.space | grep "Drupal 10"
11 changes: 9 additions & 2 deletions dotenv/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ public static function prepareAppEnvironment() {
if (file_exists(__DIR__ . '/sites/all.env')) {
$vars .= file_get_contents(__DIR__ . '/sites/all.env') . "\n";
}
// Support dots in the environment name and load files by prefix.
// This allows grouping environments by host having shared settings.
if (strpos($phapp_env, '.') !== FALSE) {
$parts = explode('.', $phapp_env, 2);
if (file_exists(__DIR__ . '/sites/all.env-' . $parts[0] . '.env')) {
$vars .= file_get_contents(__DIR__ . '/sites/all.env-' . $parts[0] . '.env') . "\n";
}
}
// Support per-environment all.env files.
if (file_exists(__DIR__ . '/sites/all.env-' . $phapp_env . '.env')) {
$vars .= file_get_contents(__DIR__ . '/sites/all.env-' . $phapp_env . '.env') . "\n";
Expand Down Expand Up @@ -209,7 +217,6 @@ public static function getSiteVariables($site = NULL, $site_variant = '') {
$dotenv->populate($dotenv->parse(PhappEnvironmentLoader::prepareDeterminedEnvironment()), TRUE);

// Match the request and prepare site-specific dotenv vars.
$site = drunomics\MultisiteRequestMatcher\RequestMatcher::getInstance()
->match();
$site = PhappEnvironmentLoader::determineActiveSite();
$dotenv->populate($dotenv->parse(PhappEnvironmentLoader::prepareAppEnvironment()), TRUE);
}

0 comments on commit b911452

Please sign in to comment.