Skip to content

Commit

Permalink
Allow DDEV version to be customised (#85)
Browse files Browse the repository at this point in the history
This also disables the composer cache until ddev/ddev#3697 is released as this command is breaking setups which are using existing environment variables

Additionally adds a test for the Install DDEV GitHub Action
  • Loading branch information
justafish authored Mar 14, 2022
1 parent 8a669c0 commit 531ef9d
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/TestGitHubActions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Test GitHub Actions"

on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
Test-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Prepare Drupal
run: |
mv ${GITHUB_WORKSPACE}/tests/fixtures/drainpipe-test-github-actions/composer.json .
mv ${GITHUB_WORKSPACE}/tests/fixtures/drainpipe-test-github-actions/Taskfile.yml .
mv ${GITHUB_WORKSPACE}/tests/fixtures/drainpipe-test-github-actions/.ddev .
- uses: ./scaffold/github/actions/common/set-env

- name: Install and Start DDEV
uses: ./scaffold/github/actions/common/ddev

- name: Build Project
run: |
ddev composer install
15 changes: 13 additions & 2 deletions scaffold/github/actions/common/ddev/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
composer-cache-dir:
description: "Composer cache directory, relative to the project workspace. Set to false to disable."
required: false
version:
description: "Override the DDEV version .e.g. '1.19.0'"
required: false
runs:
using: "composite"
steps:
Expand All @@ -36,7 +39,14 @@ runs:
fi
chmod 700 .ddev/homeadditions/.ssh
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh && bash install_ddev.sh v1.19.0-rc4
# Download and run the DDEV installer
if [ "${{ inputs.version }}" != "" ]; then
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh && bash install_ddev.sh v${{ inputs.version }}
else
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh && bash install_ddev.sh v1.19.0
fi
rm -f install_ddev.sh
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
if [ "${{ inputs.composer-cache-dir }}" != "false" ]; then
Expand All @@ -45,7 +55,8 @@ runs:
if [ "${{ inputs.composer-cache-dir }}" != "" ]; then
CACHE_DIR="${{ inputs.composer-cache-dir }}"
fi
ddev config --web-environment="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR"
# Composer cache disabled until https://github.com/drud/ddev/pull/3697 is released
# ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR"
fi
ddev start
Expand Down
19 changes: 19 additions & 0 deletions tests/fixtures/drainpipe-test-github-actions/.ddev/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: drupal
type: drupal9
docroot: web
php_version: "8.0"
webserver_type: nginx-fpm
router_http_port: "80"
router_https_port: "443"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
type: mariadb
version: "10.3"
nfs_mount_enabled: false
mutagen_enabled: false
use_dns_when_possible: true
composer_version: "2"
web_environment: []
nodejs_version: "16"
15 changes: 15 additions & 0 deletions tests/fixtures/drainpipe-test-github-actions/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

dotenv: ['.env']

includes:
drupal: ./vendor/lullabot/drainpipe/tasks/drupal.yml
snapshot: ./vendor/lullabot/drainpipe/tasks/snapshot.yml

tasks:
build:
desc: "Production composer install of the project"
deps: [drupal:composer:production]
cmds:
- if [ ! -f "web/index.php" ]; then exit 1; fi
- if [ -f "vendor/lullabot/drainpipe-dev/composer.json" ]; then exit 1; fi
93 changes: 93 additions & 0 deletions tests/fixtures/drainpipe-test-github-actions/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"name": "drupal/recommended-project",
"description": "Project template for Drupal 9 projects with a relocated document root",
"type": "project",
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/drupal",
"support": {
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
"chat": "https://www.drupal.org/node/314178"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"composer/installers": "^1.9",
"drupal/core-composer-scaffold": "^9.3",
"drupal/core-project-message": "^9.3",
"drupal/core-recommended": "^9.3"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "stable",
"prefer-stable": true,
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true
}
},
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
"installer-paths": {
"web/core": [
"type:drupal-core"
],
"web/libraries/{$name}": [
"type:drupal-library"
],
"web/modules/contrib/{$name}": [
"type:drupal-module"
],
"web/profiles/contrib/{$name}": [
"type:drupal-profile"
],
"web/themes/contrib/{$name}": [
"type:drupal-theme"
],
"drush/Commands/contrib/{$name}": [
"type:drupal-drush"
],
"web/modules/custom/{$name}": [
"type:drupal-custom-module"
],
"web/profiles/custom/{$name}": [
"type:drupal-custom-profile"
],
"web/themes/custom/{$name}": [
"type:drupal-custom-theme"
]
},
"drupal-core-project-message": {
"include-keys": [
"homepage",
"support"
],
"post-create-project-cmd-message": [
"<bg=blue;fg=white> </>",
"<bg=blue;fg=white> Congratulations, you’ve installed the Drupal codebase </>",
"<bg=blue;fg=white> from the drupal/recommended-project template! </>",
"<bg=blue;fg=white> </>",
"",
"<bg=yellow;fg=black>Next steps</>:",
" * Install the site: https://www.drupal.org/docs/8/install",
" * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
" * Get support: https://www.drupal.org/support",
" * Get involved with the Drupal community:",
" https://www.drupal.org/getting-involved",
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
}
}
}

0 comments on commit 531ef9d

Please sign in to comment.