Skip to content

Commit

Permalink
Test config (#41)
Browse files Browse the repository at this point in the history
* Add PHP 8.3 support. Add better testing for config defaults.

* Test updates for config.

* Fix critical issue with config not loading.

* Feed the linter.

* Fix nginx test.
  • Loading branch information
reynoldsalec committed Feb 23, 2024
1 parent d246d6d commit 96e5200
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 22 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## v1.2.0 - [February 24, 2024](https://github.com/lando/backdrop/releases/tag/v1.2.0)

### New Features

* Added support for `php:8.3`.
* Added config testing.

### Fixes

* Fixed `CRITICAL` issue with default config files not loading correctly

### Internal

* Updated to `@lando/php@1.2.0`

## v1.0.0 - [December 7, 2023](https://github.com/lando/backdrop/releases/tag/v1.0.0)

* Changed default `php` version to `8.2`
Expand Down
5 changes: 3 additions & 2 deletions builders/backdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ module.exports = {
build_as_root_internal: [],
confSrc: path.resolve(__dirname, '..', 'config'),
composer_version: '2',
defaultFiles: {},
defaultFiles: {
php: 'php.ini',
},
database: 'mariadb:10.6',
drush: '8.4.12',
php: '8.2',
Expand Down Expand Up @@ -59,7 +61,6 @@ module.exports = {

// Rebase on top of any default config we might already have
options.defaultFiles = _.merge({}, require('../utils/get-config-defaults')(_.cloneDeep(options)), options.defaultFiles); // eslint-disable-line max-len

// add relevant build steps for backdrush
if (options.backdrush !== false) options.build.unshift(require('../utils/get-backdrush')(options));
// add relevant build steps for bee
Expand Down
2 changes: 2 additions & 0 deletions config/default.conf.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# LANDOBACKDROPNGINXCONF

server {
listen 80 default_server;
listen 443 ssl;
Expand Down
5 changes: 3 additions & 2 deletions config/mysql.cnf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# The MySQL database server configuration file for Lando
#
# LANDOBACKDROPMYSQLCNF

[mysqld]
#
Expand Down Expand Up @@ -71,7 +72,7 @@ max_binlog_size = 100M
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 100M
innodb_log_file_size = 101M
#innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 0
#innodb_lock_wait_timeout = 50
Expand All @@ -82,7 +83,7 @@ innodb_open_files = 256
innodb_io_capacity = 512
innodb_flush_method = O_DIRECT
innodb_thread_concurrency = 8
innodb_lock_wait_timeout = 120
innodb_lock_wait_timeout = 121
#
# * Security Features
#
Expand Down
5 changes: 3 additions & 2 deletions config/mysql8.cnf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# The MySQL database server configuration file for Lando
#
# LANDOBACKDROPMYSQL8CNF

[mysqld]
#
Expand Down Expand Up @@ -49,7 +50,7 @@ read_buffer_size = 2M
#server-id = 1
#log_bin = /src/.lando/log/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
max_binlog_size = 101M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
Expand Down Expand Up @@ -77,7 +78,7 @@ innodb_open_files = 256
innodb_io_capacity = 512
innodb_flush_method = O_DIRECT
innodb_thread_concurrency = 8
innodb_lock_wait_timeout = 120
innodb_lock_wait_timeout = 127
#
# * Security Features
#
Expand Down
5 changes: 3 additions & 2 deletions config/php.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[PHP]

; LANDOBACKDROPPHPINI
;;;;;;;;;;;;;;;
; PHP Globals ;
;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -36,8 +37,8 @@ xdebug.mode = ${XDEBUG_MODE}

; Globals
expose_php = on
max_execution_time = 90
max_input_time = 900
max_execution_time = 91
max_input_time = 901
max_input_vars = 10000
memory_limit = ${PHP_MEMORY_LIMIT}
upload_max_filesize = 100M
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Lando offers a configurable [recipe](https://docs.lando.dev/core/v3/recipes.html

#### Features of this plugin:

* Configurable `php` version from `5.3` all the way to `8.2`
* Configurable `php` version from `5.3` all the way to `8.3`
* Configurable `webroot`
* Configurable web server (`apache` or `nginx`)
* Configurable database backend (`mariadb` or `mysql`)
Expand Down
2 changes: 1 addition & 1 deletion examples/backdrop-custom/.lando.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: backdrop-custom
recipe: backdrop
config:
php: '7.4'
php: '8.3'
composer_version: '2.0.7'
via: nginx:1.17
webroot: bob
Expand Down
4 changes: 2 additions & 2 deletions examples/backdrop-custom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ lando ssh -s appserver -c "curl -L appserver_nginx" | grep "HI BOB"
lando ssh -s appserver_nginx -c "nginx -v" 2>&1 | grep "nginx version" | grep "nginx/1.17"
lando ssh -s appserver -c "curl -IL appserver_nginx" | grep Server | grep nginx

# Should use php 7.4
lando php -v | grep "PHP 7.4"
# Should use php 8.3
lando php -v | grep "PHP 8.3"

# Should use composer 2.0.7
lando ssh -s appserver -c "/bin/sh -c 'NO_COLOR=1 composer -V'" | grep "Composer version 2.0.7"
Expand Down
6 changes: 6 additions & 0 deletions examples/backdrop-defaults/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ lando bee version | grep "Bee for Backdrop CMS" | grep "1.x-1.x"

# Should use composer 2 by default
lando ssh -s appserver -c "/bin/sh -c 'NO_COLOR=1 composer -V'" | grep "Composer version 2."

# Should use the correct default config files
lando ssh -s appserver -c "cat /usr/local/etc/php/conf.d/zzz-lando-my-custom.ini" | grep "; LANDOBACKDROPPHPINI"
lando ssh -s appserver -c "curl -L http://localhost/info.php" | grep max_execution_time | grep 91
lando ssh -s database -c "cat /opt/bitnami/mariadb/conf/my_custom.cnf" | grep "LANDOBACKDROPMYSQLCNF"
lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 121
```

Destroy tests
Expand Down
4 changes: 4 additions & 0 deletions examples/backdrop-mysql8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ lando mysql -V | grep "mysql"| grep "Ver 8.0.22"

# Should be able to connect to the database with the default creds
lando mysql backdrop -e quit

# Should use the defauly mysql8 config file
lando ssh -s database -c "cat /opt/bitnami/mysql/conf/my_custom.cnf" | grep "LANDOBACKDROPMYSQL8CNF"
lando mysql -u root -e "show variables;" | grep innodb_lock_wait_timeout | grep 127
```

Destroy tests
Expand Down
3 changes: 3 additions & 0 deletions examples/backdrop-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ lando nginx -v 2>&1 | grep "nginx version" | grep "nginx/1.25"

# Should use the php version specified by the user eg 7.4
lando php -v | grep "PHP 7.4"

# Should load the correct default nginx config
lando ssh -s appserver_nginx -c "cat /opt/bitnami/nginx/conf/vhosts/lando.conf" | grep "LANDOBACKDROPNGINXCONF"
```

Destroy tests
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@lando/mssql": "^1.0.0",
"@lando/mysql": "^1.0.0",
"@lando/nginx": "^1.0.0",
"@lando/php": "^1.0.0",
"@lando/php": "^1.2.0",
"@lando/postgres": "^1.0.0",
"lodash": "^4.17.21"
},
Expand Down
5 changes: 4 additions & 1 deletion utils/get-config-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('fs');

module.exports = options => {
// Get the viaconf
if (options.webserver.type === 'nginx') options.defaultFiles.vhosts = 'default.conf.tpl';
if (_.startsWith(options.via, 'nginx')) options.defaultFiles.vhosts = 'default.conf.tpl';

// Get the default db conf
const dbConfig = _.get(options, 'database', 'mysql');
Expand All @@ -26,4 +26,7 @@ module.exports = options => {
delete options.defaultFiles[type];
}
});

// Return
return options.defaultFiles;
};
1 change: 1 addition & 0 deletions utils/get-service-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// Modules
const _ = require('lodash');
const path = require('path');

module.exports = (options, types = ['php', 'server', 'vhosts']) => {
const config = {};
Expand Down

0 comments on commit 96e5200

Please sign in to comment.