Skip to content

Commit

Permalink
add github actions test
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Sep 12, 2024
1 parent 9042f92 commit d02e193
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/drupal-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Drupal test routine

on:
push:
branches:
- 'main'
- 'dev'
pull_request:
branches:
- 'main'

jobs:
test-suite:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Pull all images
run: |
docker compose pull --ignore-pull-failures
- name: Install test harness
run: |
yarn add leia-parser mocha chai@4 command-line-test
- name: Generate test files
run: |
yarn leia "TESTING*.md" test -r 2 -s 'Start up tests' -t 'Verification commands' -c 'Destroy tests' --split-file
- name: Run docker compose tests
run: |
yarn mocha --timeout 900000 test/*compose*.func.js
96 changes: 96 additions & 0 deletions TESTING_dockercompose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Docker Compose Drupal base - php8, nginx, mariadb
=================================================

This is a docker compose version of the Lando example tests:

Start up tests
--------------

Run the following commands to get up and running with this example.

```bash
# Should remove any previous runs and poweroff
sed -i -e "/###/d" docker-compose.yml
docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network
docker compose down

# Should start up our Lagoon Drupal site successfully
docker compose build && docker compose up -d

# Ensure mariadb pod is ready to connect
docker compose exec cli bash -c 'wait-for mariadb:3306'
```

Verification commands
---------------------

Run the following commands to validate things are rolling as they should.

```bash
# Should be able to site install via Drush
docker compose exec -T cli bash -c "drush si -y"
docker compose exec -T cli bash -c "drush cr -y"
docker compose exec -T cli bash -c "drush status" | grep "Drupal bootstrap" | grep "Successful"

# Should have all the services we expect
docker ps --filter label=com.docker.compose.project=drupal-cms-example | grep Up | grep drupal-cms-example-nginx-1
docker ps --filter label=com.docker.compose.project=drupal-cms-example | grep Up | grep drupal-cms-example-mariadb-1
docker ps --filter label=com.docker.compose.project=drupal-cms-example | grep Up | grep drupal-cms-example-php-1
docker ps --filter label=com.docker.compose.project=drupal-cms-example | grep Up | grep drupal-cms-example-cli-1

# Should ssh against the cli container by default
docker compose exec -T cli bash -c "env | grep LAGOON=" | grep cli-drupal

# Should have the correct environment set
docker compose exec -T cli bash -c "env" | grep LAGOON_ROUTE | grep drupal-cms-example.localhost
docker compose exec -T cli bash -c "env" | grep LAGOON_ENVIRONMENT_TYPE | grep development

# Should be running PHP 8
docker compose exec -T cli bash -c "php -v" | grep "PHP 8"

# Should have composer
docker compose exec -T cli bash -c "composer --version"

# Should have php cli
docker compose exec -T cli bash -c "php --version"

# Should have drush
docker compose exec -T cli bash -c "drush --version"

# Should have npm
docker compose exec -T cli bash -c "npm --version"

# Should have node
docker compose exec -T cli bash -c "node --version"

# Should have yarn
docker compose exec -T cli bash -c "yarn --version"

# Should have a running Drupal site served by nginx on port 8080
docker compose exec -T cli bash -c "curl -kL http://nginx:8080" | grep "Drush Site-Install"

# Should be able to db-export and db-import the database
docker compose exec -T cli bash -c "drush sql-dump --result-file /app/test.sql"
docker compose exec -T cli bash -c "drush sql-drop -y"
docker compose exec -T cli bash -c "drush sql-cli < /app/test.sql"
docker compose exec -T cli bash -c "rm test.sql*"

# Should be able to show the drupal tables
docker compose exec -T cli bash -c "echo U0hPVyBUQUJMRVM7 | base64 -d > /app/showtables.sql"
docker compose exec -T cli bash -c "drush sqlq --file /app/showtables.sql" | grep users

# Should be able to rebuild and persist the database
docker compose build && docker compose up -d
docker compose exec -T cli bash -c "echo U0hPVyBUQUJMRVM7 | base64 -d > /app/showtables.sql"
docker compose exec -T cli bash -c "drush sqlq --file /app/showtables.sql" | grep users
```

Destroy tests
-------------

Run the following commands to trash this app like nothing ever happened.

```bash
# Should be able to destroy our Drupal site with success
docker compose down --volumes --remove-orphans
```

0 comments on commit d02e193

Please sign in to comment.