Skip to content

Commit 7e9c65f

Browse files
authored
Merge pull request #11 from druidfi/2023-tweaks
2023 tweaks
2 parents e192347 + 80ca1a4 commit 7e9c65f

25 files changed

+329
-309
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php-versions: ['7.4', '8.0', '8.1']
21+
php-versions: ['8.0', '8.1', '8.2', '8.3']
2222

2323
steps:
2424

2525
- name: Checkout code
26-
uses: actions/checkout@v2
26+
uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 1
2929

@@ -38,10 +38,10 @@ jobs:
3838

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

4343
- name: Cache composer dependencies
44-
uses: actions/cache@v2
44+
uses: actions/cache@v3
4545
with:
4646
path: ${{ steps.composercache.outputs.dir }}
4747
# Use composer.json for key, if composer.lock is not committed.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
test: PHP := 8.0
1+
test: PHP := 8.2
22
test: vendor
33
@echo "Run composer test (all tests)"
44
@docker run --rm -it --volume $$PWD:/app druidfi/drupal:php-$(PHP) composer test
55

6-
test-%: PHP := 8.0
6+
test-%: PHP := 8.2
77
test-%: vendor
88
@echo "Run composer test-$*"
99
@docker run --rm -it --volume $$PWD:/app druidfi/drupal:php-$(PHP) composer test-$*

README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ your project.
1414

1515
Require omen in your composer.json:
1616

17-
```
17+
```console
1818
composer require druidfi/omen
1919
```
2020

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

6969
Drupal configuration can be overridden using ENV variables.
7070

71-
| Variable | ENV override | Default value |
72-
|------------------------------------------------|------------------------|--------------------------|
73-
| `$config['system.file']['path']['temporary']` | `DRUPAL_TMP_PATH` | `'/tmp'` |
74-
| `$databases['default']['default']['database']` | `DRUPAL_DB_NAME` | :heavy_multiplication_x: |
75-
| `$databases['default']['default']['driver']` | `DRUPAL_DB_DRIVER` | `'mysql'` |
76-
| `$databases['default']['default']['host']` | `DRUPAL_DB_HOST` | :heavy_multiplication_x: |
77-
| `$databases['default']['default']['password']` | `DRUPAL_DB_PASS` | :heavy_multiplication_x: |
78-
| `$databases['default']['default']['port']` | `DRUPAL_DB_PORT` | `3306` |
79-
| `$databases['default']['default']['username']` | `DRUPAL_DB_USER` | :heavy_multiplication_x: |
80-
| `$settings['file_public_path']` | - | `'sites/default/files'` |
81-
| `$settings['file_private_path']` | `DRUPAL_FILES_PRIVATE` | `FALSE` |
82-
| `$settings['file_temp_path']` | `DRUPAL_TMP_PATH` | `'/tmp'` |
83-
| `$settings['hash_salt']` | `DRUPAL_HASH_SALT` | `'0000000000000000'` |
71+
| Variable | ENV override | Default value |
72+
|------------------------------------------------|--------------------------------|--------------------------|
73+
| `$databases['default']['default']['database']` | `DRUPAL_DB_NAME` | :heavy_multiplication_x: |
74+
| `$databases['default']['default']['driver']` | `DRUPAL_DB_DRIVER` | `'mysql'` |
75+
| `$databases['default']['default']['host']` | `DRUPAL_DB_HOST` | :heavy_multiplication_x: |
76+
| `$databases['default']['default']['password']` | `DRUPAL_DB_PASS` | :heavy_multiplication_x: |
77+
| `$databases['default']['default']['port']` | `DRUPAL_DB_PORT` | `3306` |
78+
| `$databases['default']['default']['username']` | `DRUPAL_DB_USER` | :heavy_multiplication_x: |
79+
| `$settings['config_sync_directory']` | `DRUPAL_CONFIG_SYNC_DIRECTORY` | `'conf/cmi'` |
80+
| `$settings['file_public_path']` | `DRUPAL_FILE_PUBLIC_PATH` | `'sites/default/files'` |
81+
| `$settings['file_private_path']` | `DRUPAL_FILE_PRIVATE_PATH` | `FALSE` |
82+
| `$settings['file_temp_path']` | `DRUPAL_FILE_TEMP_PATH` | `'/tmp'` |
83+
| `$settings['hash_salt']` | `DRUPAL_HASH_SALT` | `'0000000000000000'` |
8484

8585
:heavy_multiplication_x: Detected or required
8686

8787
## Defaults for environment types
8888

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

9391
See current default values by environment:
9492

composer.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
}
2626
},
2727
"require": {
28-
"php": "^7.4 || ^8.0",
29-
"drupal/core-recommended": "^9.4 || ^10.0",
28+
"php": "^8.0",
29+
"drupal/core-recommended": "^10.0",
3030
"ext-json": "*"
3131
},
3232
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "^2.17.0",
34-
"phpunit/phpunit": "^9.5"
33+
"friendsofphp/php-cs-fixer": "^2.17 || ^3.15",
34+
"phpunit/phpunit": "^9.6 <10"
3535
},
3636
"minimum-stability": "dev",
3737
"prefer-stable": true,
@@ -42,7 +42,8 @@
4242
"@test-lando",
4343
"@test-pantheon",
4444
"@test-tugboat",
45-
"@test-wodby"
45+
"@test-wodby",
46+
"@test-unknown"
4647
],
4748
"test-lagoon": [
4849
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Lagoon.xml",
@@ -73,6 +74,11 @@
7374
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Wodby.xml",
7475
"APP_ENV=test phpunit --debug --verbose --configuration tests/Wodby.xml",
7576
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Wodby.xml"
77+
],
78+
"test-unknown": [
79+
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Unknown.xml",
80+
"APP_ENV=test phpunit --debug --verbose --configuration tests/Unknown.xml",
81+
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Unknown.xml"
7682
]
7783
}
7884
}

src/Defaults.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Druidfi\Omen;
4+
5+
class Defaults
6+
{
7+
private array $config = [];
8+
9+
private array $settings = [
10+
'config_exclude_modules' => [
11+
'devel',
12+
'stage_file_proxy',
13+
'upgrade_status',
14+
],
15+
];
16+
17+
public function __construct(string $app_env)
18+
{
19+
$this->config['system.logging']['error_level'] = match ($app_env) {
20+
'dev' => 'verbose',
21+
default => 'hide',
22+
};
23+
24+
$this->config['system.performance'] = match ($app_env) {
25+
'dev' => [
26+
'cache' => ['page' => ['max_age' => 0]],
27+
'css' => ['preprocess' => 0],
28+
'js' => ['preprocess' => 0],
29+
],
30+
default => [
31+
'cache' => ['page' => ['max_age' => 900]],
32+
'css' => ['preprocess' => 1],
33+
'js' => ['preprocess' => 1],
34+
],
35+
};
36+
37+
$this->settings['skip_permissions_hardening'] = match ($app_env) {
38+
'dev' => TRUE,
39+
default => FALSE,
40+
};
41+
42+
// Simple Environment Indicator.
43+
$this->settings['simple_environment_indicator'] = match ($app_env) {
44+
'dev' => 'Black Development',
45+
'test' => 'Blue Testing',
46+
'prod' => 'DarkRed Production',
47+
default => FALSE,
48+
};
49+
}
50+
51+
public function getDefaults() : array
52+
{
53+
return [
54+
'config' => $this->config,
55+
'settings' => $this->settings,
56+
];
57+
}
58+
}

src/DrupalEnvDetector.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/EnvDefaults/AbstractDefaults.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/EnvDefaults/DevDefaults.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/EnvDefaults/ProdDefaults.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/EnvDefaults/TestDefaults.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)