Skip to content

Commit

Permalink
#66: Remove MultiViews from our Apache config + PHP plugin isolation (#…
Browse files Browse the repository at this point in the history
…78)

* #66: Remove MultiViews from our Apache config.

* Include nginx plugin after the great decoupling.

* Refactor plugin to use new builders directory and break out utils.

* Isolate tests for hardcore. Fix pkger missing issue from refactor.

* Install all plugins to get nginx dependency.

* Add install-composer.sh script.

* Update workflows to detach from other services.

* Add php-nginx service to detach from reliance on global nginx.

* Feed linter.

* Include nginx in main php builder as well.

* Update .node-version file.

* More updates to GA tests.

* Debug code.

* Try using explicit type on 5.3 tests.

* New loading scheme for php-nginx.

* Debugging info and get rid of type on custom_nginx 5.3.

* Isolate php extension tests and don't destroy 5.3 for debugging.

* Debugging.

* Docker logs debugging.

* Debug trying depends_on

* Add depends_on for php-fpm universally.

* Isolate PHP Other tests.

* Clean up code.

* Update Changelog and fix issue with composer dependency downloading.

* Feed the linter.
  • Loading branch information
reynoldsalec authored Nov 21, 2023
1 parent 77e0c69 commit 68a0c6a
Show file tree
Hide file tree
Showing 30 changed files with 1,158 additions and 1,057 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/build-php-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ jobs:
# Handle Lando Install to test the images after build
# We are hardcoding the dtaa normally included in the matrix
# due to how this testing is setup
- name: Install node 16
- name: Install node 18
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
registry-url: https://registry.npmjs.org
cache: yarn
- name: Install Yarn dependencies
Expand All @@ -98,12 +98,9 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
config: |
plugins.@lando/php=/home/runner/work/php/php
setup.skipCommonPlugins=true
setup.plugins.@lando/php=/home/runner/work/php/php
telemetry: false
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep php | grep /home/runner/work/php/php || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)

# This block should eventually become use lando/actions-leia@v2
# @NOTE? Do we want a way for our leia-action to configure apparmor since
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-docs-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:
# Install deps and cache
- name: Checkout code
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pr-legacy-php5-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:

- name: Checkout code
Expand All @@ -39,16 +39,16 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
config: |
plugins.@lando/php=/home/runner/work/php/php
setup.skipCommonPlugins=true
setup.plugins.@lando/php=/home/runner/work/php/php
telemetry: false
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep php | grep /home/runner/work/php/php || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)
- name: Run Leia Tests
uses: lando/run-leia-action@v2
with:
leia-test: "./${{ matrix.leia-tests }}/README.md"
cleanup-header: "Destroy tests"
shell: bash
stdin: true
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2
9 changes: 3 additions & 6 deletions .github/workflows/pr-legacy-php7-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:

- name: Checkout code
Expand All @@ -38,12 +38,9 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
config: |
plugins.@lando/php=/home/runner/work/php/php
setup.skipCommonPlugins=true
setup.plugins.@lando/php=/home/runner/work/php/php
telemetry: false
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep php | grep /home/runner/work/php/php || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)
- name: Run Leia Tests
uses: lando/run-leia-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:
# Install deps and cache
- name: Checkout code
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/pr-php-extension-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -35,12 +35,9 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
config: |
plugins.@lando/php=/home/runner/work/php/php
setup.skipCommonPlugins=true
setup.plugins.@lando/php=/home/runner/work/php/php
telemetry: false
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep php | grep /home/runner/work/php/php || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)
- name: Run Leia Tests
uses: lando/run-leia-action@v2
with:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/pr-php-other-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:

- name: Checkout code
Expand All @@ -38,12 +38,9 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
config: |
plugins.@lando/php=/home/runner/work/php/php
setup.skipCommonPlugins=true
setup.plugins.@lando/php=/home/runner/work/php/php
telemetry: false
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep php | grep /home/runner/work/php/php || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)
- name: Run Leia Tests
uses: lando/run-leia-action@v2
with:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/pr-php7-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:

- name: Checkout code
Expand All @@ -37,12 +37,9 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
config: |
plugins.@lando/php=/home/runner/work/php/php
setup.skipCommonPlugins=true
setup.plugins.@lando/php=/home/runner/work/php/php
telemetry: false
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep php | grep /home/runner/work/php/php || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)
- name: Build Local Docker Apache Image
run: |
cd ./images/${{ matrix.php-versions }}-apache
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/pr-php8-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:

- name: Checkout code
Expand All @@ -38,12 +38,9 @@ jobs:
with:
lando-version: ${{ matrix.lando-version }}
config: |
plugins.@lando/php=/home/runner/work/php/php
setup.skipCommonPlugins=true
setup.plugins.@lando/php=/home/runner/work/php/php
telemetry: false
- name: Verify Lando works and we are dogfooding this plugin for tests
run: |
lando version
lando config --path plugins | grep php | grep /home/runner/work/php/php || (echo "::error:: Not dogfooding this plugin correctly! " && exit 1)
- name: Build Local Docker Apache Image
run: |
cd ./images/${{ matrix.php-versions }}-apache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- ubuntu-22.04
- macos-12
node-version:
- '16'
- '18'
steps:
# Install deps and cache
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
os:
- ubuntu-22.04
node-version:
- '16'
- '18'
steps:
# Install deps and cache
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.10.0 - [November 21, 2023](https://github.com/lando/php/releases/tag/v0.10.0)
* Removed MultiViews from Apache config. [#66](https://github.com/lando/php/issues/66)
* Isolated PHP to work as a standalone service. [#78](https://github.com/lando/php/pull/78)

## v0.9.0 - [July 3, 2023](https://github.com/lando/php/releases/tag/v0.9.0)
* Removed bundle-dependencies and version-bump-prompt from plugin.
* Updated package to use prepare-release-action.
Expand Down
15 changes: 15 additions & 0 deletions builders/php-nginx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const _ = require('lodash');
const LandoNginx = require('./../node_modules/@lando/nginx/builders/nginx.js');

// Builder
module.exports = {
name: 'php-nginx',
parent: '_webserver',
builder: (parent, config) => class PhpNginx extends LandoNginx.builder(parent, LandoNginx.config) {
constructor(id, options = {}) {
super(id, options, {services: _.set({}, options.name)});
};
},
};
28 changes: 17 additions & 11 deletions services/php/builder.js → builders/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
const _ = require('lodash');
const path = require('path');
const semver = require('semver');
const utils = require('./../../lib/utils');

const addBuildStep = require('./../utils/add-build-step');
/*
* Helper to get nginx config
*/
Expand All @@ -18,11 +17,11 @@ const nginxConfig = options => ({
info: {managed: true},
home: options.home,
name: `${options.name}_nginx`,
overrides: utils.cloneOverrides(options.overrides),
overrides: require('../utils/clone-overrides')(options.overrides),
project: options.project,
root: options.root,
ssl: options.nginxSsl,
type: 'nginx',
type: 'php-nginx',
userConfRoot: options.userConfRoot,
webroot: options.webroot,
version: options.via.split(':')[1],
Expand Down Expand Up @@ -108,7 +107,7 @@ module.exports = {
'/var/www/.composer/vendor/bin',
'/helpers',
],
confSrc: __dirname,
confSrc: path.resolve(__dirname, '..', 'config'),
command: ['sh -c \'a2enmod rewrite && apache2-foreground\''],
composer_version: '2.2.18',
image: 'apache',
Expand Down Expand Up @@ -171,34 +170,41 @@ module.exports = {

// Add our composer things to run step
if (!_.isEmpty(options.composer)) {
const commands = utils.getInstallCommands(options.composer, pkger, ['composer', 'global', 'require', '-n']);
utils.addBuildStep(commands, options._app, options.name, 'build_internal');
const commands =
require('../utils/get-install-commands')(options.composer, pkger, ['composer', 'global', 'require', '-n']);
addBuildStep(commands, options._app, options.name, 'build_internal');
}

// Add activate steps for xdebug
if (options.xdebug) {
utils.addBuildStep(['docker-php-ext-enable xdebug'], options._app, options.name, 'build_as_root_internal');
addBuildStep(['docker-php-ext-enable xdebug'], options._app, options.name, 'build_as_root_internal');
}

// Install the desired composer version
if (options.composer_version) {
const commands = [`/helpers/install-composer.sh ${options.composer_version}`];
utils.addBuildStep(commands, options._app, options.name, 'build_internal', true);
addBuildStep(commands, options._app, options.name, 'build_internal', true);
}

// Add in nginx if we need to
if (_.startsWith(options.via, 'nginx')) {
// Set another lando service we can pass down the stream
const nginxOpts = nginxConfig(options);

// Merge in any user specifified
const LandoNginx = factory.get('nginx');
const data = new LandoNginx(nginxOpts.name, nginxOpts);
const PhpNginx = factory.get('php-nginx');
const data = new PhpNginx(nginxOpts.name, nginxOpts);
// If the user has overriden this service lets make sure we include that as well
const userOverrides = _.get(options, `_app.config.services.${nginxOpts.name}.overrides`, {});
data.data.push({
services: _.set({}, nginxOpts.name, userOverrides),
version: _.get(data, 'data[0].version'),
});
// Add a depends_on to make sure nginx waits for php-fpm to be up.
data.data.push({
services: _.set({}, nginxOpts.name, {'depends_on': [options.name]}),
version: _.get(data, 'data[0].version'),
});
// This is a trick to basically replicate what happens upstream
options._app.add(data);
options._app.info.push(data.info);
Expand Down
4 changes: 2 additions & 2 deletions services/php/default-ssl.conf → config/default-ssl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ServerAdmin webmaster@localhost
DocumentRoot ${LANDO_WEBROOT}
<Directory />
Options Indexes FollowSymLinks MultiViews
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Expand Down Expand Up @@ -48,7 +48,7 @@

DocumentRoot ${LANDO_WEBROOT}
<Directory />
Options Indexes FollowSymLinks MultiViews
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion services/php/default.conf → config/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ServerAdmin webmaster@localhost
DocumentRoot ${LANDO_WEBROOT}
<Directory />
Options Indexes FollowSymLinks MultiViews
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/5.3/.lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ tooling:
# This is important because it lets lando know to test against the plugin in this repo
# DO NOT REMOVE THIS!
plugins:
"@lando/php": ./../../
"@lando/php": ./../../
5 changes: 2 additions & 3 deletions examples/5.3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ Destroy tests
Run the following commands to trash this app like nothing ever happened.

```bash
# Should be destroyed with success
lando destroy -y
lando poweroff
# Should print out docker logs
docker logs landophp53_custom_nginx_1
```
Loading

0 comments on commit 68a0c6a

Please sign in to comment.