Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable Travis CI #45

Open
wants to merge 21 commits into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/composer.lock
/vendor/

.DS_Store
.idea
.idea
140 changes: 54 additions & 86 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,103 +1,71 @@
language: php
sudo: true

php:
- 5.5
- 5.6
- 7.0

matrix:
allow_failures:
- php: 7.0
- 5.6
- 7.0
#- 7.1
#- 7.2

env:
global:
- MESSAGE_MODULE='message'
- MESSAGE_REPO='https://github.com/Gizra/message.git'
- MESSAGE_VERSION='8.x-1.x'
- MESSAGE_NOTIFY_MODULE='message_notify'
- MESSAGE_NOTIFY_REPO='https://github.com/Gizra/message_notify.git'
- MESSAGE_NOTIFY_VERSION='8.x-1.x'
- MESSAGE_UI_MODULE='message_ui'
- MESSAGE_UI_REPO='https://github.com/mccrodp/message_ui.git'
- MESSAGE_UI_VERSION='8.x-1.x'
- MODULE_NAME='message_private'
- MODULE_TEST_GROUP='Message Private'
- DRUPAL_REPO='git://drupalcode.org/project/drupal.git'
- DRUPAL_VERSION='8.0.5'
- PHPCS_VERSION='2.0.*@dev'
- CODER_VERSION='8.2.0-beta1'

before_install:
# Ensure we have the latest sources.
- sudo apt-get -y update

# Composer.
- sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc
- source $HOME/.bashrc
# - composer self-update

# Drush.
- composer global require "youngj/httpserver:dev-master#41dd2b7"
- composer global require drush/drush:~8

# Codesniffer.
- composer global require squizlabs/php_codesniffer:$PHPCS_VERSION

# Coder.
- composer global require drupal/coder:$CODER_VERSION
- ln -s ~/.composer/vendor/drupal/coder/coder_sniffer/Drupal ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/
- COMPOSER_MEMORY_LIMIT=2G
- DRUPAL_DIR=${TRAVIS_BUILD_DIR}/../build
- MODULES_DIR=${DRUPAL_DIR}/modules/contrib
- MODULE_DIR=${MODULES_DIR}/message_private
matrix:
- TEST_SUITE=PHP_CodeSniffer
- TEST_SUITE=8.5.x
# - TEST_SUITE=8.6.x
# - TEST_SUITE=8.7.x

# Only run the coding standards check once.
matrix:
exclude:
- php: 5.6
env: TEST_SUITE=PHP_CodeSniffer
# - php: 7.0
# env: TEST_SUITE=PHP_CodeSniffer
# - php: 7.1
# env: TEST_SUITE=PHP_CodeSniffer

mysql:
database: message_private
username: root
encoding: utf8

# Ensure the PHP environment is ready.
- phpenv rehash
before_script:
# Remove Xdebug as we don't need it and it causes "PHP Fatal error: Maximum
# function nesting level of '256' reached."
# We also don't care if that file exists or not on PHP 7.
- phpenv config-rm xdebug.ini || true

install:
# Basic PHP packages.
- sudo apt-get install -y --force-yes php5-cgi php5-mysql
# Require the version of Drupal 8 core under test.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || composer require --no-update drupal/core:$TEST_SUITE webflo/drupal-core-require-dev:$TEST_SUITE

# Move the checked out module into the correct structure.
- mkdir /tmp/$MODULE_NAME
- mv * /tmp/$MODULE_NAME/
- git clone --branch $DRUPAL_VERSION $DRUPAL_REPO drupal --depth 1
- mv /tmp/$MODULE_NAME drupal/modules/
- cd drupal/modules
- git clone --branch $MESSAGE_VERSION $MESSAGE_REPO
- git clone --branch $MESSAGE_NOTIFY_VERSION $MESSAGE_NOTIFY_REPO
- git clone --branch $MESSAGE_UI_VERSION $MESSAGE_UI_REPO
- cd ../
# PHPUnit 6 is required when running tests on PHP 7.x.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || test ${TRAVIS_PHP_VERSION:0:3} == "5.6" || composer require --no-update --update-with-dependencies --dev phpunit/phpunit:~6

before_script:
# Install dependencies.
- composer install

# Install Composer dependencies.
- composer self-update && composer install
# Create database.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || mysql -e 'CREATE DATABASE message_private'

# This fixes a fail when install Drupal.
- echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
# Symlink the module into the Drupal site.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || mkdir -p $MODULES_DIR
- test ${TEST_SUITE} == "PHP_CodeSniffer" || ln -s $TRAVIS_BUILD_DIR $MODULE_DIR

# Mysql might time out for long tests, increase the wait timeout.
- mysql -e 'SET @@GLOBAL.wait_timeout=1200'
# Start a web server on port 8888 in the background.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || nohup php -S localhost:8888 --docroot $DRUPAL_DIR > /dev/null 2>&1 &

# Install Drupal and enable the required modules (including this one).
- mysql -e 'create database drupal;'
- cd $TRAVIS_BUILD_DIR/drupal && drush --yes site-install testing --db-url="mysql://[email protected]/drupal"
- cd $TRAVIS_BUILD_DIR/drupal && drush --yes en $MODULE_NAME
- cd $TRAVIS_BUILD_DIR/drupal && drush --yes en simpletest
# Wait until the web server is responding.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || until curl -s localhost:8888; do true; done > /dev/null

# Start a web server.
- drush runserver 127.0.0.1:8080 &
- until netstat -an 2>/dev/null | grep '8080.*LISTEN'; do true; done
# Export web server URL for browser tests.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || export SIMPLETEST_BASE_URL=http://localhost:8888

script:
# Run code sniffer.
- phpcs --report=full --standard=Drupal $TRAVIS_BUILD_DIR/drupal/modules/$MODULE_NAME
# Export database variable for kernel tests.
- test ${TEST_SUITE} == "PHP_CodeSniffer" || export SIMPLETEST_DB=mysql://root:@127.0.0.1/message_private

# Run the tests
- php $TRAVIS_BUILD_DIR/drupal/core/scripts/run-tests.sh --verbose --color --php `which php` --url http://127.0.0.1:8080 "$MODULE_TEST_GROUP" | tee /tmp/test.txt; TEST_EXIT=${PIPESTATUS[0]}; echo $TEST_EXIT
# Check if we had fails in the run-tests.sh script
# Exit with the inverted value, because if there are no fails found, it will
# exit with 1 and for us that is a good thing so invert it to 0. Travis has
# some issues with the exclamation mark in front so we have to fiddle a bit.
# Also make the grep case insensitive and fail on run-tests.sh regular fails
# as well on fatal errors.
- TEST_OUTPUT=$(! egrep -i "([0-9]+ fails)|(PHP Fatal error)|([0-9]+ exceptions)" /tmp/test.txt > /dev/null)$?; echo $TEST_OUTPUT
# Exit the build
- if [ $TEST_EXIT -eq 0 ] && [ $TEST_OUTPUT -eq 0 ]; then exit 0; else exit 1; fi
script: ${TRAVIS_BUILD_DIR}/scripts/travis-ci/run-tests.sh ${TEST_SUITE}
17 changes: 0 additions & 17 deletions .travis/apache-vhost.conf

This file was deleted.

18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ CONTENTS OF THIS FILE
INTRODUCTION
------------
A message template and entity reference fields, enabling sending and receiving
private messages using The Message Stack. Messages of template "Private Message" can
be sent by creating the private_message message instance with fields referencing
user entities.
private messages using The Message Stack. Messages of template "Private Message"
can be sent by creating the private_message message instance with fields
referencing user entities.

The message_private module includes the following.
+ A message template "Private Message" with entity reference field referencing users
+ A message view, message_private for "User Messages"
The message_private module includes the following:
* A message template "Private Message" with entity reference field referencing
users
* A message view, message_private for "User Messages"


DEPENDENCIES
Expand All @@ -39,8 +40,9 @@ INSTALLATION

CONFIGURATION
-------------
Show notification boolean on user form fields: /admin/config/people/accounts/form-display
This will be addressed automatically in a hook later.
Show notification boolean on user form fields:
`/admin/config/people/accounts/form-display`. This will be addressed
automatically in a hook later.


HOW TO USE
Expand Down
31 changes: 29 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
{
"name": "drupal/message_private",
"description": "Message Private",
"description": "Private messaging module based on Message stack.",
"type": "drupal-module",
"license": "GPL-2.0+",
"minimum-stability": "dev",
"require": {}
"prefer-stable": true,
"homepage": "https://www.drupal.org/project/message_private",
"require": {
"php": "^5.6|^7.0",
"drupal/core": "^8.6",
"drupal/message": "^1.0",
"drupal/message_notify": "^1.0",
"drupal/message_ui": "^1.0"
},
"require-dev": {
"composer/installers": "^1.2",
"drupal-composer/drupal-scaffold": "^2.5",
"drupal/coder": "^8.3.1",
"webflo/drupal-core-require-dev": "~8.5"
},
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"extra": {
"installer-paths": {
"../build/core": ["type:drupal-core"],
"../build/modules/contrib/{$name}": ["type:drupal-module"],
"../build/themes/contrib/{$name}": ["type:drupal-theme"]
}
}
}
2 changes: 1 addition & 1 deletion config/optional/message_private.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ message_private_message_limit: 0
email_notify: 1
message_add_local_action: 1
default_limit: 0
default_interval: 0
default_interval: 0
9 changes: 5 additions & 4 deletions message_private.install
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php

/**
* @file
* Message Private un-installer.
*/

/**
* Implements hook_uninstall.
* Implements hook_uninstall().
*
* Remove the field_message_private_usr_notify field.
*/
function message_private_uninstall() {
$properties = array(
$properties = [
'entity_type' => 'user',
'bundle' => 'user',
'include_deleted' => TRUE,
);
];

// Get the fields based on the above properties.
$fields = \Drupal::entityManager()->getStorage('field_config')->loadByProperties($properties);
Expand All @@ -23,7 +24,7 @@ function message_private_uninstall() {
foreach ($fields as $field) {
/* @var \Drupal\Core\Field\FieldConfigBase $field */
// If we have the user notify field, purge the data and remove.
if(!empty($field->getName() == 'field_message_private_usr_notify')) {
if (!empty($field->getName() == 'field_message_private_usr_notify')) {
// Purge previously deleted field tables for entity type.
Drupal::entityManager()->getStorage($field->getTargetEntityTypeId())->purgeFieldData($field, 100);
field_cron();
Expand Down
1 change: 0 additions & 1 deletion message_private.links.task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ message_private.messages.sent:
# Provide dynamic local tasks.
message_private.messages:
deriver: 'Drupal\message_private\Plugin\Derivative\DynamicLocalTasks'

Loading