Skip to content

Commit

Permalink
Merge pull request #165 from localgovdrupal/3.x
Browse files Browse the repository at this point in the history
3.0.2 release
  • Loading branch information
finnlewis authored Jun 4, 2024
2 parents 34abcc4 + 6eb733f commit 3a4df11
Show file tree
Hide file tree
Showing 30 changed files with 245 additions and 16 deletions.
12 changes: 12 additions & 0 deletions .ddev/commands/host/exec_dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

## Description: Run programs in container, based on current host directory
## Usage: exec_d [args]
## Example: "ddev exec_d yarn"

if [ -z "$1" ]; then
echo "No argument supplied"
exit 1
fi

ddev exec -d /var/www/html/"$(echo "$PWD" | cut -d'/' -f4-)" "$@"
2 changes: 1 addition & 1 deletion .ddev/commands/web/phix
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: phix
## Example: "ddev phix"

/var/www/html/bin/phpcbf $*
/var/www/html/vendor/bin/phpcbf $*
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpcs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: phpcs
## Example: "ddev phpcs"

/var/www/html/bin/phpcs -p $*
/var/www/html/vendor/bin/phpcs -p $*
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpstan
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: phpix
## Example: "ddev phix"

/var/www/html/bin/phpstan $*
/var/www/html/vendor/bin/phpstan $*
2 changes: 1 addition & 1 deletion .ddev/commands/web/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
## Usage: phpunit
## Example: "ddev phpunit"

/var/www/html/bin/phpunit $*
/var/www/html/vendor/bin/phpunit $*
2 changes: 1 addition & 1 deletion .ddev/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: localgov
type: drupal9
type: drupal10
docroot: web
php_version: "8.1"
webserver_type: nginx-fpm
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
php-version:
- '8.1'
- '8.2'
- '8.3'

steps:

Expand Down Expand Up @@ -99,6 +100,7 @@ jobs:
php-version:
- '8.1'
- '8.2'
- '8.3'

steps:

Expand Down Expand Up @@ -135,6 +137,7 @@ jobs:
php-version:
- '8.1'
- '8.2'
- '8.3'

steps:

Expand Down Expand Up @@ -170,6 +173,7 @@ jobs:
php-version:
- '8.1'
- '8.2'
- '8.3'

steps:

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Ignore directories generated by Composer
/bin
/drush/contrib/
/vendor/
/web/core/
Expand Down Expand Up @@ -77,3 +76,7 @@
.ddev/homeadditions/
.ddev/providers/
.ddev/xhprof/

# Ignore macOS DS_Store files
.DS_Store
**/.DS_Store
4 changes: 3 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: drupalpod/drupalpod-gitpod-base:20221216
image: drupalpod/drupalpod-gitpod-base:20240419

# ddev and composer are running as part of the prebuild
# when starting a workspace all docker images are ready
Expand All @@ -8,6 +8,8 @@ tasks:
ddev composer install
ddev drush si localgov -y --account-pass=admin --site-name='localgov_project'
command: |
.gitpod/utils/ddev-in-gitpod-setup.sh
.gitpod/utils/env-setup.sh
ddev start -y
gp ports await 8080 && gp preview $(gp url 8080)
Expand Down
33 changes: 33 additions & 0 deletions .gitpod/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Setting up a new version for DrupalPod

## Build custom Gitpod image

1. Update `.gitpod/images/Dockerfile`:

1. Update `ddev` latest version.
1. Update `minio` latest version.
1. Update `gitui` latest version.
1. Update `lazygit` latest version.

1. Generate new custom docker image:

1. Run `docker login` to authenticate and push new images to docker hub.
1. In `/.gitpod/images` run `./push.sh` command to build and push the new custom docker image.
1. Confirm the process run without errors and that the new custom image gets uploaded to <https://hub.docker.com/r/drupalpod/drupalpod-gitpod-base/tags>.
1. Update `/.gitpod.yml` with the new image file.

1. Push code, and re-open Gitpod workspace, to use latest custom docker image.

1. Run manual prebuild (to load ddev's images)

1. Confirm latest setup
1. Open new workspace.
1. Check if there are any updates (ie. DDEV's default settings files).

1. Test various scenarios with DrupalPod browser extension
1. Confirm core issues work as expected.
1. Confirm contrib issue work as expected.

1. Merge PR into `main` branch

1. Confirm `main` branch work as expected 🎉
7 changes: 7 additions & 0 deletions .gitpod/utils/ddev-in-gitpod-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -n "$DEBUG_SCRIPT" ] || [ -n "$GITPOD_HEADLESS" ]; then
set -x
fi

# Misc housekeeping before start
ddev config global --instrumentation-opt-in=true
36 changes: 36 additions & 0 deletions .gitpod/utils/env-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
if [ -n "$DEBUG_SCRIPT" ]; then
set -x
fi

cd "${GITPOD_REPO_ROOT}"/.gitpod/utils/script-templates || exit

# Create a phpstorm command
sudo cp phpstorm.template.sh /usr/local/bin/phpstorm

# Create a preview command
sudo cp preview.template.sh /usr/local/bin/preview

# Create a protect-my-git command
sudo cp protect-my-git.template.sh /usr/local/bin/protect-my-git

# Create php command (run php inside ddev container)
sudo cp ddev-php.template.sh /usr/local/bin/php

# Create drush command (run drush inside ddev container)
sudo cp ddev-drush.template.sh /usr/local/bin/drush

# Create yarn command (run yarn inside ddev container)
sudo cp ddev-yarn.template.sh /usr/local/bin/yarn

# Create composer command (run composer inside ddev container)
sudo cp ddev-composer.template.sh /usr/local/bin/composer

# Create node command (run composer inside ddev container)
sudo cp ddev-node.template.sh /usr/local/bin/node

# Create nvm command (run composer inside ddev container)
sudo cp ddev-nvm.template.sh /usr/local/bin/nvm

# Create npx command (run composer inside ddev container)
sudo cp ddev-npx.template.sh /usr/local/bin/npx
3 changes: 3 additions & 0 deletions .gitpod/utils/script-templates/ddev-composer.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Notice: running 'composer $*' in ddev"
ddev exec_d composer "$@"
3 changes: 3 additions & 0 deletions .gitpod/utils/script-templates/ddev-drush.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Notice: running 'drush $*' in ddev"
ddev exec_d drush "$@"
3 changes: 3 additions & 0 deletions .gitpod/utils/script-templates/ddev-node.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Notice: running 'node $*' in ddev"
ddev exec_d node "$@"
3 changes: 3 additions & 0 deletions .gitpod/utils/script-templates/ddev-npx.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Notice: running 'npx $*' in ddev"
ddev exec_d npx "$@"
3 changes: 3 additions & 0 deletions .gitpod/utils/script-templates/ddev-nvm.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Notice: running 'nvm $*' in ddev"
ddev exec_d nvm "$@"
3 changes: 3 additions & 0 deletions .gitpod/utils/script-templates/ddev-php.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Notice: running 'php $*' in ddev"
ddev exec_d php "$@"
3 changes: 3 additions & 0 deletions .gitpod/utils/script-templates/ddev-yarn.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Notice: running 'yarn $*' in ddev"
ddev exec_d yarn "$@"
14 changes: 14 additions & 0 deletions .gitpod/utils/script-templates/phpstorm.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
if [ -n "$DEBUG_SCRIPT" ]; then
set -x
fi

if [ ! -x ~/.projector/configs/PhpStorm/run.sh ]; then
echo "PhpStorm runner not found" && exit 1
fi

# When port 9999 is ready - open that port in a new browser tab
gp await-port 9999 && gp preview "$(gp url 9999)" --external &

# Run PHPStorm
~/.projector/configs/PhpStorm/run.sh "$GITPOD_REPO_ROOT"
7 changes: 7 additions & 0 deletions .gitpod/utils/script-templates/preview.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -n "$DEBUG_SCRIPT" ]; then
set -x
fi

# Preview port 8080
gp preview "$(gp url 8080)"
7 changes: 7 additions & 0 deletions .gitpod/utils/script-templates/protect-my-git.template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ -n "$DEBUG_SCRIPT" ]; then
set -x
fi

# Remove access to user's Git credentials (restore by restart workspace)
git config --global --unset credential.helper
32 changes: 32 additions & 0 deletions .gitpod/utils/send-a-message-gcs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# Get current user and current branch
branch_user="$GITPOD_GIT_USER_NAME, $(git branch --show-current)"

# Load env vars during prebuild using `gp env` command
if [ -z "$IFTTT_TOKEN" ]; then
eval "$(gp env -e | grep IFTTT_TOKEN)"
fi

# Load env vars during prebuild using `gp env` command
if [ -z "$DP_GOOGLE_ACCESS_KEY" ]; then
eval "$(gp env -e | grep DP_GOOGLE_ACCESS_KEY)"
fi

# Load env vars during prebuild using `gp env` command
if [ -z "$DP_GOOGLE_SECRET" ]; then
eval "$(gp env -e | grep DP_GOOGLE_SECRET)"
fi

# Establish connection with Google Cloud through Minio client
mc config host add gcs https://storage.googleapis.com "$DP_GOOGLE_ACCESS_KEY" "$DP_GOOGLE_SECRET"

# If there's a problem send the error code
if mc find gcs/drupalpod/ready-made-envs.tar.gz; then
message="Success: Google Cloud is ready"
else
message="Error: Envs file wasn't found, it will be recreated"
fi

# Send a message through IFTTT
curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$branch_user\",\"value2\":\"$message\"}" https://maker.ifttt.com/trigger/drupalpod_prebuild_initiated/with/key/"$IFTTT_TOKEN"
28 changes: 28 additions & 0 deletions .gitpod/utils/send-a-message-gitpod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Get current user and current branch
branch_user="$GITPOD_GIT_USER_NAME, $(git branch --show-current)"

# Load env vars during prebuild using `gp env` command
if [ -z "$DP_READY_MADE_ENVS_URL" ]; then
eval "$(gp env -e | grep DP_READY_MADE_ENVS_URL)"
fi

# Load env vars during prebuild using `gp env` command
if [ -z "$IFTTT_TOKEN" ]; then
eval "$(gp env -e | grep IFTTT_TOKEN)"
fi

# Check the status of ready-made envs file
# https://stackoverflow.com/a/53358157/5754049
url_status=$(wget --server-response --spider --quiet "${DP_READY_MADE_ENVS_URL}" 2>&1 | awk 'NR==1{print $2}')

# If there's a problem send the error code
if [ "$url_status" = '200' ]; then
message="100%"
else
message="Error: $url_status - $DP_READY_MADE_ENVS_URL"
fi

# Send a message through IFTTT
curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$branch_user\",\"value2\":\"$message\"}" https://maker.ifttt.com/trigger/drupalpod_prebuild_initiated/with/key/"$IFTTT_TOKEN"
11 changes: 11 additions & 0 deletions .gitpod/utils/set-base-environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
if [ -n "$DEBUG_SCRIPT" ]; then
set -x
fi

# Load default envs
# export "$(grep -v '^#' "$GITPOD_REPO_ROOT"/.env | xargs -d '\n')"

# Clone Drupal core repo
mkdir -p "${GITPOD_REPO_ROOT}"/repos
cd "${GITPOD_REPO_ROOT}"/repos && time git clone https://git.drupalcode.org/project/drupal.git
17 changes: 11 additions & 6 deletions .lando.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ proxy:
- 'solr-sitewide.localgov.lndo.site:8983'
services:
appserver:
scanner:
retry: 5
xdebug: true
build_as_root:
# This disables Xdebug during build, but puts all dependencies in place
Expand Down Expand Up @@ -71,24 +73,27 @@ services:
config:
dir: .lando/solr/localgov_sitewide_solr
tooling:
composer:
service: appserver
cmd: /usr/local/bin/composer
deprecated:
service: appserver
cmd: 'bash -c "/app/bin/phpstan analyse -c /app/phpstan.neon /app/web/profiles/contrib/localgov* /app/web/modules/contrib/localgov* /app/web/themes/contrib/localgov*"'
cmd: 'bash -c "/app/vendor/bin/phpstan analyse -c /app/phpstan.neon /app/web/profiles/contrib/localgov* /app/web/modules/contrib/localgov* /app/web/themes/contrib/localgov*"'
drush:
service: appserver
cmd: '/app/bin/drush'
cmd: '/app/vendor/bin/drush'
phpcs:
service: appserver
cmd: '/app/bin/phpcs -p'
cmd: '/app/vendor/bin/phpcs -p'
phix:
service: appserver
cmd: '/app/bin/phpcbf'
cmd: '/app/vendor/bin/phpcbf'
phpstan:
service: appserver
cmd: '/app/bin/phpstan'
cmd: '/app/vendor/bin/phpstan'
phpunit:
service: appserver
cmd: '/app/bin/phpunit --testdox'
cmd: '/app/vendor/bin/phpunit --testdox'
xdebug-on:
service: appserver
description: Enable Xdebug for Apache.
Expand Down
2 changes: 1 addition & 1 deletion assets/composer/settings.lando.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @see https://wiki.php.net/rfc/expectations
*/
assert_options(ASSERT_ACTIVE, TRUE);
\Drupal\Component\Assertion\Handle::register();
assert_options(ASSERT_EXCEPTION, TRUE);

/**
* Enable local development services.
Expand Down
1 change: 1 addition & 0 deletions bin
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"prefer-stable": true,
"config": {
"sort-packages": true,
"bin-dir": "bin/",
"allow-plugins": {
"composer/installers": true,
"cweagans/composer-patches": true,
Expand All @@ -48,6 +47,9 @@
},
"extra": {
"enable-patching": true,
"patchLevel": {
"drupal/core": "-p2"
},
"drupal-scaffold": {
"locations": {
"web-root": "web/"
Expand Down
Loading

0 comments on commit 3a4df11

Please sign in to comment.