Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
feat(Test): Leaner Tests
Browse files Browse the repository at this point in the history
* wip(Leaner Tests): Initial effort

* ci(Leaner Test): Fixes incorrect ENV Variable for Project base path

* fix(Leaner Tests): Fixes bad substitution on Travis CI

\

* CI(Travis): Fixes scripts folder structures. Adds decouple feature by delegating travis tasks to bash functions.

CI(Travis): Removes 'bash -e -x' prefix on scripts invocation.

CI(Travis): Adds missing change directory

* CI(Travis): Changes endpoint from '/jsonapi' to '/api' in test files

* CI(Travis): Changes 'node' expected resource to 'node--tutorial' inside test.

* CI(Travis): Downgrade PHPUnit Version

* CI(Travis): Reverts a few files, leverage composer run-script instead of running scripts directly. Brings back the .env file.

* GIT(Ignore): Ignore .env.local file

* Run phpcbf

* fix(Config): Remove unnecessary files
  • Loading branch information
Carlos Gratacos authored and e0ipso committed Aug 18, 2017
1 parent 836683d commit 7886be8
Show file tree
Hide file tree
Showing 23 changed files with 210 additions and 2,403 deletions.
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
WEB_HOST=127.0.0.1
WEB_PORT=8888
WEB_PORT=8888
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

95 changes: 0 additions & 95 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
/themes/infinite/
.DS_Store
composer.lock
.env.local
/tests/reports
.env.local
39 changes: 14 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,21 @@ branches:
before_install:
# Fixes Composer exhausting the memory when using PHP 5.6.
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- nvm install 6.11.0
- nvm use 6.11.0
# Repo for Yarn
- sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get update -qq
- sudo apt-get install -y -qq yarn
- mkdir $PROJECT_BASE_PATH
# Load .env and .local.env
- source ./scripts/ci/travis/load_env.sh

install:
- yarn install
- composer run-script install-contenta $PROJECT_BASE_PATH --timeout=0

- composer run-script ci:helper setup_anonymous_user "$PROJECT_BASE_PATH" --timeout=0

before_script:
- export DISPLAY=:99.0
# Prevent chrome deadlock when running Nightwatch tests.
# See https://stackoverflow.com/questions/41487659/nightwatch-selenium-socket-hang-up
- export DBUS_SESSION_BUS_ADDRESS=/dev/null
- sh -e /etc/init.d/xvfb start
- sleep 3 # give xvfb some time to start
- composer run-script start-contenta $PROJECT_BASE_PATH --timeout=0 &
- sleep 5 # give web server some time to start
# Start Contenta Local Server
- composer run-script start-contenta $PROJECT_BASE_PATH --timeout=0 &> /dev/null &
- sleep 8 # give web server some time to start

script:
- yarn run nightwatch
- composer run-script ci:helper run_functional_tests "$PROJECT_BASE_PATH" --timeout=0

after_script:
- killall php
Expand All @@ -66,24 +55,24 @@ after_script:
jobs:
include:
# Deployment Stage
# This stage promotes a successful artifact from the deployment branch to Github
# This stage promotes a successful artifact from the deployment branch to GitHub
- stage: Release
php: 7.1
install:
- composer run-script install-contenta $PROJECT_BASE_PATH --timeout=0
install: skip
before_script: skip
script: skip
before_deploy:
# Install Contenta
- composer run-script install-contenta $PROJECT_BASE_PATH --timeout=0
# Set Deployment Variable
- RELEASE_DATE=$( date +%Y-%m-%d)
- TRAVIS_TAG="${PROJECT_NAME}_release-${RELEASE_DATE}_build_${TRAVIS_BUILD_NUMBER}"
# Clean the Contenta Profile Folder
- ./scripts/deployment/travis_before_deploy.sh contentacms_profile_cleanup "$PROJECT_BASE_PATH/web"
- composer run-script ci:before-deploy contentacms_profile_cleanup "$PROJECT_BASE_PATH/web" --timeout=0
# Remove Site files
- ./scripts/deployment/travis_before_deploy.sh rm_site "$PROJECT_BASE_PATH/web"
- composer run-script ci:before-deploy rm_site "$PROJECT_BASE_PATH/web" --timeout=0
# Zip Folder
- ./scripts/deployment/travis_before_deploy.sh zip_folder "$HOME" "$PROJECT_NAME" "$TRAVIS_TAG"

- composer run-script ci:before-deploy zip_folder "$HOME" "$PROJECT_NAME" "$TRAVIS_TAG" --timeout=0
deploy:
provider: releases
api_key:
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"scripts": {
"install-contenta": "scripts/development/build-contenta_jsonapi.sh",
"start-contenta": "scripts/development/start-contenta_jsonapi.sh",
"ci:helper": "scripts/ci/travis/tests/contenta_ci_tests_helper.sh",
"ci:before-deploy": "scripts/ci/travis/before_deploy.sh",
"post-package-install": [
"Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
],
Expand All @@ -87,6 +89,7 @@
"burdamagazinorg/thunder-dev-tools": "dev-master",
"drupal/config_inspector": "1.x-dev",
"drupal/coder": "^8.2",
"drupal/features": "^3.5"
"drupal/features": "^3.5",
"guzzlehttp/guzzle": "~6.0"
}
}
27 changes: 14 additions & 13 deletions config/sync/material_admin.settings.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
features:
node_user_picture: 1
comment_user_picture: 1
comment_user_verification: 1
favicon: 1
logo:
use_default: 0
path: profiles/contrib/contenta_jsonapi/modules/contenta_enhancements/logo.svg
favicon:
use_default: 0
use_default: false
path: profiles/contrib/contenta_jsonapi/modules/contenta_enhancements/favicon.ico
mimetype: image/vnd.microsoft.icon
material_admin_node_actions: 0
material_admin_message_length: '88'
_core:
default_config_hash: 5_yz7HdXL2SBVGN_T99xcCs6PiGxgVfcXwQD-E8s-i4
features:
comment_user_picture: true
comment_user_verification: true
favicon: true
node_user_picture: false
logo:
path: profiles/contrib/contenta_jsonapi/modules/contenta_enhancements/logo.svg
use_default: false
material_admin_node_actions: false
material_admin_message_length: 88
material_admin_portal_login: true
material_admin_jqueryui_dialog_background: true
material_admin_jqueryui_dialog_close: true
19 changes: 11 additions & 8 deletions contenta_jsonapi.install
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ function contenta_jsonapi_install() {
/** @var \Drupal\Core\DrupalKernelInterface $drupal_kernel */
$drupal_kernel = \Drupal::service('kernel');
$file_path = $drupal_kernel->getAppRoot() . '/' . $drupal_kernel->getSitePath();
$services_yml = file_get_contents($file_path . '/default.services.yml');
$filename = $file_path . '/default.services.yml';
if (file_exists($filename)) {
$services_yml = file_get_contents($filename);

$yml_data = Yaml::decode($services_yml);
if (empty($yml_data['parameters']['cors.config']['enabled'])) {
$yml_data['parameters']['cors.config']['enabled'] = TRUE;
$yml_data['parameters']['cors.config']['allowedHeaders'] = ['*'];
$yml_data['parameters']['cors.config']['allowedMethods'] = ['*'];
$yml_data['parameters']['cors.config']['allowedOrigins'] = ['localhost:*'];
$yml_data = Yaml::decode($services_yml);
if (empty($yml_data['parameters']['cors.config']['enabled'])) {
$yml_data['parameters']['cors.config']['enabled'] = TRUE;
$yml_data['parameters']['cors.config']['allowedHeaders'] = ['*'];
$yml_data['parameters']['cors.config']['allowedMethods'] = ['*'];
$yml_data['parameters']['cors.config']['allowedOrigins'] = ['localhost:*'];

file_put_contents($file_path . '/services.yml', Yaml::encode($yml_data));
file_put_contents($filename, Yaml::encode($yml_data));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
path_prefix: api
dependencies:
enforced:
module:
- recipes_magazin_contenta
43 changes: 0 additions & 43 deletions nightwatch.json

This file was deleted.

18 changes: 0 additions & 18 deletions package.json

This file was deleted.

25 changes: 25 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit
convertErrorsToExceptions="true"
colors="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
stopOnFailure="true"
>
<php>
<ini name="memory_limit" value="-1" />
<env name="WEB_HOST" value="127.0.0.1" />
<env name="WEB_HOST" value="8888" />

</php>
<testsuites>
<testsuite name="ContentaFunctional">
<directory suffix="Test.php">tests/src/Functional/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>tests/src/</directory>
</whitelist>
</filter>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,16 @@ validate_env_var() {
contentacms_files_to_delete_list() {
list=(
'.circleci'
'.babelrc'
'CODE_OF_CONDUCT.md'
'.editorconfig'
'.eslintignore'
'.eslintrc'
'.git'
'.github'
'.gitignore'
'installer.sh'
'nightwatch.json'
'package.json'
'tests'
'.travis.yml'
'yarn.lock'
'node_modules'
'.mkdocks.yml'
'phpunit.xml'
)

echo ${list[*]}
Expand Down
Loading

0 comments on commit 7886be8

Please sign in to comment.