Created
May 27, 2020 08:03
-
-
Save jamiehollern/d68241cdc2211ec12a72074653a3d329 to your computer and use it in GitHub Desktop.
Develop Drupal contrib and emulate Travis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Delete everything we don't need. | |
ls | egrep -v 'AmazeeLabs|patches|down.sh|up.sh' | xargs rm -rf | |
# Kill any D8 router processes. | |
PID=$(ps -ef | grep d8-rs-router.php | grep -v grep | awk '{print $2}') | |
echo $PID | |
if [ "$PID" ]; then | |
kill $PID | |
fi | |
# Clear the Composer cache so we get the latest patches etc. | |
COMPOSER_MEMORY_LIMIT=-1 composer clear-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set some variables. | |
DRUPAL_TEST_DB_URL=sqlite://localhost/sites/default/files/test.sqlite | |
SIMPLETEST_DB=sqlite://localhost/sites/default/files/test.sqlite | |
DRUPAL_TEST_BASE_URL=http://localhost:8888 | |
TRAVIS_BUILD_DIR_RELATIVE=AmazeeLabs/$MODULE_NAME | |
TRAVIS_BUILD_DIR=$(realpath $TRAVIS_BUILD_DIR_RELATIVE) | |
DRUPAL_VERSION=8.8.5 | |
DRUPAL_BUILD_DIR=$TRAVIS_BUILD_DIR/../drupal-$DRUPAL_VERSION | |
PATH=$PATH:$DRUPAL_BUILD_DIR/vendor/bin | |
MODULE_NAME="delivery" | |
# before_install: | |
# Download and unpack Drupal | |
curl -O https://ftp.drupal.org/files/projects/drupal-$DRUPAL_VERSION.tar.gz | |
tar -xf drupal-$DRUPAL_VERSION.tar.gz -C $TRAVIS_BUILD_DIR/../ | |
# install: | |
cd $DRUPAL_BUILD_DIR | |
php -r "\$json = json_decode(file_get_contents('composer.json'), TRUE); \$json['repositories'][] = ['type' => 'path', 'url' => '$TRAVIS_BUILD_DIR' ]; \$json['extra']['enable-patching'] = TRUE; file_put_contents('composer.json', json_encode(\$json, JSON_PRETTY_PRINT));" | |
# Install Composer Patches. | |
COMPOSER_MEMORY_LIMIT=-1 composer --working-dir=$DRUPAL_BUILD_DIR require cweagans/composer-patches | |
# Install Drupal development dependencies. | |
COMPOSER_MEMORY_LIMIT=-1 composer --working-dir=$DRUPAL_BUILD_DIR install | |
# Install Drush. | |
COMPOSER_MEMORY_LIMIT=-1 composer --working-dir=$DRUPAL_BUILD_DIR require drush/drush:^10 alchemy/zippy | |
# Upgrade phpunit to work with PHP 7. | |
COMPOSER_MEMORY_LIMIT=-1 composer --working-dir=$DRUPAL_BUILD_DIR require phpunit/phpunit:^7 symfony/phpunit-bridge phpspec/prophecy sebastian/global-state:^2 sebastian/environment:^3.1 phpunit/php-code-coverage:^6 mikey179/vfsstream | |
# Install static analysis tools. | |
COMPOSER_MEMORY_LIMIT=-1 composer --working-dir=$DRUPAL_BUILD_DIR require phpstan/phpstan phpstan/extension-installer mglaman/phpstan-drupal phpstan/phpstan-deprecation-rules | |
# script: | |
COMPOSER_MEMORY_LIMIT=-1 composer require "drupal/$MODULE_NAME" | |
# Do a minimal Drupal installation. Required for Drush. | |
php core/scripts/drupal install -q minimal | |
# Run a simple HTTP server on port 8888. | |
./vendor/bin/drush serve -q & DRUSH_SERVE_PID=$! | |
# Run PHPStan. | |
./vendor/bin/phpstan analyse $TRAVIS_BUILD_DIR | |
# Run Drupal Unit tests in this module. | |
SIMPLETEST_DB=sqlite://localhost/sites/default/files/test.sqlite ./vendor/bin/phpunit -c core/phpunit.xml.dist $TRAVIS_BUILD_DIR | |
kill $DRUSH_SERVE_PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment