You are here

make-fixture.sh in Lightning Layout 8

#!/usr/bin/env bash

BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ $BRANCH != release/* ]]; then
    echo "Fixtures can only be generated on branches of the format 'release/n.n.n'."
    exit
fi

VERSION=${BRANCH#release/}
MAJOR_VERSION=${VERSION%%.*}
# Ask git for the most recent semantic version tag, and use it as the version
# from which to update.
FROM=$(git tag $MAJOR_VERSION.* --list --sort -creatordate | head -n 1 | grep -E '^(\d+.?){3}')

./install-drupal.sh

# Destroy the database and import the fixture from which to update.
echo "Replacing database with $FROM snapshot..."
drush sql:drop --yes
cd docroot
php core/scripts/db-tools.php import ../tests/fixtures/$FROM.php.gz
cd ..

# Run updates.
drush updatedb --yes
drush update:lightning --no-interaction

# Export the database.
cd docroot
php core/scripts/db-tools.php dump-database-d8-mysql --schema-only='' | gzip -9 > ../tests/fixtures/$VERSION.php.gz
cd ..

File

make-fixture.sh
View source
  1. #!/usr/bin/env bash
  2. BRANCH=$(git rev-parse --abbrev-ref HEAD)
  3. if [[ $BRANCH != release/* ]]; then
  4. echo "Fixtures can only be generated on branches of the format 'release/n.n.n'."
  5. exit
  6. fi
  7. VERSION=${BRANCH#release/}
  8. MAJOR_VERSION=${VERSION%%.*}
  9. # Ask git for the most recent semantic version tag, and use it as the version
  10. # from which to update.
  11. FROM=$(git tag $MAJOR_VERSION.* --list --sort -creatordate | head -n 1 | grep -E '^(\d+.?){3}')
  12. ./install-drupal.sh
  13. # Destroy the database and import the fixture from which to update.
  14. echo "Replacing database with $FROM snapshot..."
  15. drush sql:drop --yes
  16. cd docroot
  17. php core/scripts/db-tools.php import ../tests/fixtures/$FROM.php.gz
  18. cd ..
  19. # Run updates.
  20. drush updatedb --yes
  21. drush update:lightning --no-interaction
  22. # Export the database.
  23. cd docroot
  24. php core/scripts/db-tools.php dump-database-d8-mysql --schema-only='' | gzip -9 > ../tests/fixtures/$VERSION.php.gz
  25. cd ..