Skip to content

Commit

Permalink
Merge pull request #11 from druidfi/2023-tweaks
Browse files Browse the repository at this point in the history
2023 tweaks
  • Loading branch information
back-2-95 authored Nov 27, 2023
2 parents e192347 + 80ca1a4 commit 7e9c65f
Show file tree
Hide file tree
Showing 25 changed files with 329 additions and 309 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['8.0', '8.1', '8.2', '8.3']

steps:

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

Expand All @@ -38,10 +38,10 @@ jobs:

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
test: PHP := 8.0
test: PHP := 8.2
test: vendor
@echo "Run composer test (all tests)"
@docker run --rm -it --volume $$PWD:/app druidfi/drupal:php-$(PHP) composer test

test-%: PHP := 8.0
test-%: PHP := 8.2
test-%: vendor
@echo "Run composer test-$*"
@docker run --rm -it --volume $$PWD:/app druidfi/drupal:php-$(PHP) composer test-$*
Expand Down
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ your project.

Require omen in your composer.json:

```
```console
composer require druidfi/omen
```

Expand Down Expand Up @@ -52,7 +52,7 @@ See the whole example [here](settings.php).
- Loading of setting files and service configurations
- Database connection
- Trusted host pattern(s)
- File paths (public, private, tmp)
- File paths (public, private, temp)
- Hash salt
- Contrib module settings (which are affected by env)
- [Simple Environment Indicator](https://www.drupal.org/project/simplei)
Expand All @@ -68,27 +68,25 @@ Values: `dev`, `test` or `prod` (default: `prod`)

Drupal configuration can be overridden using ENV variables.

| Variable | ENV override | Default value |
|------------------------------------------------|------------------------|--------------------------|
| `$config['system.file']['path']['temporary']` | `DRUPAL_TMP_PATH` | `'/tmp'` |
| `$databases['default']['default']['database']` | `DRUPAL_DB_NAME` | :heavy_multiplication_x: |
| `$databases['default']['default']['driver']` | `DRUPAL_DB_DRIVER` | `'mysql'` |
| `$databases['default']['default']['host']` | `DRUPAL_DB_HOST` | :heavy_multiplication_x: |
| `$databases['default']['default']['password']` | `DRUPAL_DB_PASS` | :heavy_multiplication_x: |
| `$databases['default']['default']['port']` | `DRUPAL_DB_PORT` | `3306` |
| `$databases['default']['default']['username']` | `DRUPAL_DB_USER` | :heavy_multiplication_x: |
| `$settings['file_public_path']` | - | `'sites/default/files'` |
| `$settings['file_private_path']` | `DRUPAL_FILES_PRIVATE` | `FALSE` |
| `$settings['file_temp_path']` | `DRUPAL_TMP_PATH` | `'/tmp'` |
| `$settings['hash_salt']` | `DRUPAL_HASH_SALT` | `'0000000000000000'` |
| Variable | ENV override | Default value |
|------------------------------------------------|--------------------------------|--------------------------|
| `$databases['default']['default']['database']` | `DRUPAL_DB_NAME` | :heavy_multiplication_x: |
| `$databases['default']['default']['driver']` | `DRUPAL_DB_DRIVER` | `'mysql'` |
| `$databases['default']['default']['host']` | `DRUPAL_DB_HOST` | :heavy_multiplication_x: |
| `$databases['default']['default']['password']` | `DRUPAL_DB_PASS` | :heavy_multiplication_x: |
| `$databases['default']['default']['port']` | `DRUPAL_DB_PORT` | `3306` |
| `$databases['default']['default']['username']` | `DRUPAL_DB_USER` | :heavy_multiplication_x: |
| `$settings['config_sync_directory']` | `DRUPAL_CONFIG_SYNC_DIRECTORY` | `'conf/cmi'` |
| `$settings['file_public_path']` | `DRUPAL_FILE_PUBLIC_PATH` | `'sites/default/files'` |
| `$settings['file_private_path']` | `DRUPAL_FILE_PRIVATE_PATH` | `FALSE` |
| `$settings['file_temp_path']` | `DRUPAL_FILE_TEMP_PATH` | `'/tmp'` |
| `$settings['hash_salt']` | `DRUPAL_HASH_SALT` | `'0000000000000000'` |

:heavy_multiplication_x: Detected or required

## Defaults for environment types

- development: see [src/defaults/DevDefaults.php](src/EnvDefaults/DevDefaults.php)
- testing: see [src/defaults/TestDefaults.php](src/EnvDefaults/TestDefaults.php)
- production: see [src/defaults/ProdDefaults.php](src/EnvDefaults/ProdDefaults.php)
See [src/Defaults.php](src/Defaults.php) for values.

See current default values by environment:

Expand Down
16 changes: 11 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
}
},
"require": {
"php": "^7.4 || ^8.0",
"drupal/core-recommended": "^9.4 || ^10.0",
"php": "^8.0",
"drupal/core-recommended": "^10.0",
"ext-json": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17.0",
"phpunit/phpunit": "^9.5"
"friendsofphp/php-cs-fixer": "^2.17 || ^3.15",
"phpunit/phpunit": "^9.6 <10"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand All @@ -42,7 +42,8 @@
"@test-lando",
"@test-pantheon",
"@test-tugboat",
"@test-wodby"
"@test-wodby",
"@test-unknown"
],
"test-lagoon": [
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Lagoon.xml",
Expand Down Expand Up @@ -73,6 +74,11 @@
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Wodby.xml",
"APP_ENV=test phpunit --debug --verbose --configuration tests/Wodby.xml",
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Wodby.xml"
],
"test-unknown": [
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Unknown.xml",
"APP_ENV=test phpunit --debug --verbose --configuration tests/Unknown.xml",
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Unknown.xml"
]
}
}
58 changes: 58 additions & 0 deletions src/Defaults.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Druidfi\Omen;

class Defaults
{
private array $config = [];

private array $settings = [
'config_exclude_modules' => [
'devel',
'stage_file_proxy',
'upgrade_status',
],
];

public function __construct(string $app_env)
{
$this->config['system.logging']['error_level'] = match ($app_env) {
'dev' => 'verbose',
default => 'hide',
};

$this->config['system.performance'] = match ($app_env) {
'dev' => [
'cache' => ['page' => ['max_age' => 0]],
'css' => ['preprocess' => 0],
'js' => ['preprocess' => 0],
],
default => [
'cache' => ['page' => ['max_age' => 900]],
'css' => ['preprocess' => 1],
'js' => ['preprocess' => 1],
],
};

$this->settings['skip_permissions_hardening'] = match ($app_env) {
'dev' => TRUE,
default => FALSE,
};

// Simple Environment Indicator.
$this->settings['simple_environment_indicator'] = match ($app_env) {
'dev' => 'Black Development',
'test' => 'Blue Testing',
'prod' => 'DarkRed Production',
default => FALSE,
};
}

public function getDefaults() : array
{
return [
'config' => $this->config,
'settings' => $this->settings,
];
}
}
26 changes: 0 additions & 26 deletions src/DrupalEnvDetector.php

This file was deleted.

31 changes: 0 additions & 31 deletions src/EnvDefaults/AbstractDefaults.php

This file was deleted.

33 changes: 0 additions & 33 deletions src/EnvDefaults/DevDefaults.php

This file was deleted.

33 changes: 0 additions & 33 deletions src/EnvDefaults/ProdDefaults.php

This file was deleted.

33 changes: 0 additions & 33 deletions src/EnvDefaults/TestDefaults.php

This file was deleted.

10 changes: 0 additions & 10 deletions src/EnvMapping/EnvMappingInterface.php

This file was deleted.

Loading

0 comments on commit 7e9c65f

Please sign in to comment.