Skip to content

Commit

Permalink
Merge branch 'main' into doc-test
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjol committed Sep 23, 2024
2 parents 4653592 + 5ba2946 commit fbc76fa
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
code_quality:
strategy:
matrix:
ddev_version: [stable, HEAD]
ddev_version: [stable]
fail-fast: false
runs-on: ubuntu-latest
steps:
Expand All @@ -36,7 +36,7 @@ jobs:
tests:
strategy:
matrix:
ddev_version: [stable, HEAD]
ddev_version: [stable]
fail-fast: false

runs-on: ubuntu-latest
Expand Down
87 changes: 81 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![tests](https://github.com/Metadrop/ddev-aljibe/actions/workflows/tests.yml/badge.svg)](https://github.com/Metadrop/ddev-aljibe/actions/workflows/tests.yml)
[![tests](https://github.com/Metadrop/ddev-aljibe/actions/workflows/tests.yml/badge.svg)](https://github.com/Metadrop/ddev-aljibe/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2024.svg)
![GitHub Release](https://img.shields.io/github/v/release/Metadrop/ddev-aljibe)


Expand All @@ -8,9 +8,6 @@ Aljibe (ddev-aljibe) is an add-on for DDEV for Drupal projects that adds several

Aljibe sits on top of DDEV and adds some containers, configuration and commands to make the development of Drupal projects faster and easier.

> [!WARNING]
> Aljibe is still in Alpha stage!
## Included tools

- Behat: BDD and Acceptance testig
Expand Down Expand Up @@ -43,8 +40,32 @@ Launch Aljibe Assistant. This will guide you throught the basic Drupal site inst

You are ready! you will have a new Drupal project based on Aljibe ready for development.


## Other Aljibe commands
## Migrate legacy projects to DDEV Aljibe

To transform a legacy project to Ddev Aljibe, the following steps must be followed, always taking into account the particularities of each project:

1. Clone the project without install it and remove all docker related files
2. Run basic ddev-config:
- `ddev config --auto`
3. Install Aljibe:
- `ddev get metadrop/ddev-aljibe`
4. Run again ddev config, but this time go throught the assistant to set project type to Drupal, docroot folder, etc...
5. Edit .ddev/config.yml to fine tune the environment.
6. Edit .ddev/aljibe.yml to set deault site name (the folder inside sites) and all themes to be transpiled
7. update .gitignore to look like [this](https://github.com/Metadrop/ddev-aljibe/blob/main/aljibe-kickstart/.gitignore).

If you come from a boilerplate project:

- Remove from settings.local.php database, trusted host patterns and others that can conflict with settings.ddev.php.
- Adapt the drush alias to the new url.
- Review tests folder structure as in aljibe, all tests (behat.yml included) are inside tests folder and replace http://apache or http://nginx by http://web.
- Config also the nodejs_version in .ddev/config.yml with the same as the old project. Old version on .env file, variable **“NODE_TAG”**
- Adapt grumphp changing EXEC_GRUMPHP_COMMAND on grumphp.yml to “ddev exec”
- Launch ddev setup:
- If monosite: `ddev setup`
- If multisite:`ddev setup —all` or `ddev setup --sites=site1`

## Aljibe commands

#### Project setup
Once the project has been created and uploaded to version control, anyone else working with it can clone it and with the following command you can have the project ready to work with.
Expand Down Expand Up @@ -82,6 +103,10 @@ If you use ddev-solr addon and need to sync the solr config from the server, you

ddev solr-sync

#### Power off ddev

ddev poweroff

## Troubleshooting

### Https not working
Expand Down Expand Up @@ -117,3 +142,53 @@ xdebug.profiler_output_name=trace.%c%p%r%u.out
```

Review the php info (/admin/reports/status/php) page to review that the xdebug variables are setup properly after run ddev xdebug on, restart the project if necessary.

## How to develop Aljibe

To work on the development of Aljibe, if we do a lot of tests we can reach the limit of github, so it is convenient to have everything in local. For this we should have a structure like this:

- tests-aljibe <- Here we test the creation of projects with the steps explained below. This folder can have any name you want.
- ddev-addons <- Here are all the addons from Metadrop:
- ddev-aljibe
- ddev-aljibe-assistant
- ddev-backstopjs
- ddev-lighthouse
- ddev-mkdocs
- ddev-pa11y
- ddev-selenium

To have this folder, we can do the following from the folder where we save the projects:

1. Create the folder and got to that folder:
```
mkdir ddev-addons && cd ddev-addons
```

2. Clone the projects:
```
git clone [email protected]:metadrop-group/ddev-aljibe.git
git clone [email protected]:metadrop-group/ddev-aljibe-assistant.git
git clone [email protected]:Metadrop/ddev-backstopjs.git
git clone [email protected]:Metadrop/ddev-lighthouse.git
git clone [email protected]:Metadrop/ddev-mkdocs.git
git clone [email protected]:Metadrop/ddev-pa11y.git
git clone [email protected]:Metadrop/ddev-selenium.git
```
#### Installing Aljibe:

To launch ddev-aljibe, we must go to the test-aljibe folder, or to the folder where we want to install it. Remember that as long as we don't have Aljibe public, this folder must be at the same level as the ‘ddev-addons’ folder. Inside this folder, just launch these 3 commands:

1. Configure a basic ddev project:
```
ddev config --auto
```
2. Install ddev-aljibe from local:
```
ddev get ../ddev-addons/ddev-aljibe
```
3. Launch the Aljibe assistant:
```
ddev aljibe-assistant
```
72 changes: 32 additions & 40 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,59 @@
setup() {
set -eu -o pipefail
export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.."
export TESTDIR=~/tmp/test-addon-backstopjs
mkdir -p $TESTDIR
export PROJNAME=test-addon-backstopjs
export TESTDIR=~/tmp/test-addon-aljibe
mkdir -p "$TESTDIR"
export PROJNAME=test-addon-aljibe
export DDEV_NON_INTERACTIVE=true
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true
cd "${TESTDIR}"
ddev config --project-name=${PROJNAME}
ddev delete -Oy "$PROJNAME" >/dev/null 2>&1 || true
cd "$TESTDIR"
ddev config --project-name="$PROJNAME"
ddev start -y >/dev/null
}

teardown() {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1
[ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR}
cd "$TESTDIR" || { printf "unable to cd to %s\n" "$TESTDIR"; exit 1; }
ddev delete -Oy "$PROJNAME" >/dev/null 2>&1
[ -n "$TESTDIR" ] && rm -rf "$TESTDIR"
}

check_services() {
echo -n "Checking services:"
echo "Checking services:"
INSTALLED_SERVICES=$(ddev get --installed)
echo -n "Checking if Aljibe is installed..."
echo "$INSTALLED_SERVICES" | grep -q "aljibe" | echo " Ok."
echo -n "Checking if Aljibe Assistant is installed..."
echo "$INSTALLED_SERVICES" | grep -q "aljibe-assistant" | echo " Ok."
echo -n "Checking if Adminer is installed..."
echo "$INSTALLED_SERVICES" | grep -q "adminer" | echo " Ok."
echo -n "Checking if BackstopJS is installed..."
echo "$INSTALLED_SERVICES" | grep -q "backstopjs" | echo " Ok."
echo -n "Checking if lighthouse is installed..."
echo "$INSTALLED_SERVICES" | grep -q "lighthouse" | echo " Ok."
echo -n "Checking if mkdocs is installed..."
echo "$INSTALLED_SERVICES" | grep -q "mkdocs" | echo " Ok."
echo -n "Checking if pa11y is installed..."
echo "$INSTALLED_SERVICES" | grep -q "pa11y" | echo " Ok."
echo -n "Checking if redis is installed..."
echo "$INSTALLED_SERVICES" | grep -q "redis" | echo " Ok."
echo -n "Checking if selenium is installed..."
echo "$INSTALLED_SERVICES" | grep -q "selenium" | echo " Ok."
echo -n "Checking if unlighthouse is installed..."
echo "$INSTALLED_SERVICES" | grep -q "unlighthouse" | echo " Ok."

for SERVICE in aljibe aljibe-assistant adminer backstopjs lighthouse mkdocs pa11y redis selenium unlighthouse;
do
if echo "$INSTALLED_SERVICES" | grep -q "$SERVICE"; then
echo "Checking if $SERVICE is installed... Ok."
else
echo "Checking if $SERVICE is installed... Not installed."
fi
done
}

# Check if the project is browsable with wget
check_project_browse() {
echo -n "Checking if the project is browsable..."
curl -s https://${PROJNAME}.ddev.site | grep -q "Welcome"
echo " Ok."
if curl -s "https://${PROJNAME}.ddev.site" | grep -q "Welcome"; then
echo " Ok."
else
echo " Failed."
fi
}

check_drupal_admin_access() {
echo -n "Checking if the Drupal admin is accessible..."
curl -sLb cookies $(ddev drush uli) | grep -q "The email address is not made public"
echo " Ok."
if curl -sLb cookies "$(ddev drush uli)" | grep -q "The email address is not made public"; then
echo " Ok."
else
echo " Failed."
fi
}

@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR}
cd "$TESTDIR"
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev get "${DIR}"
ddev restart >/dev/null
ddev aljibe-assistant --auto

Expand All @@ -75,7 +67,7 @@ check_drupal_admin_access() {

@test "install from release" {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
cd "$TESTDIR" || { printf "unable to cd to %s\n" "$TESTDIR"; exit 1; }
echo "# ddev get metadrop/ddev-aljibe with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get metadrop/ddev-aljibe
ddev restart >/dev/null
Expand All @@ -85,4 +77,4 @@ check_drupal_admin_access() {
check_project_browse >&3
## Todo Make this test work
# check_drupal_admin_access >&3
}
}

0 comments on commit fbc76fa

Please sign in to comment.