Browse Source

Migrate upgrade testing to GH actions and remove Travis integration

8.x-4.x
Christian Fritsch GitHub 4 months ago
parent
commit
f75039327b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 98 additions and 649 deletions
  1. +3
    -0
      .github/labels.yml
  2. +84
    -20
      .github/workflows/test.yml
  3. +0
    -86
      .travis.yml
  4. +1
    -2
      README.md
  5. +3
    -2
      composer.json
  6. +7
    -10
      docs/development.md
  7. +0
    -111
      docs/pull-screenshots-from-travis-ci.md
  8. +0
    -19
      scripts/development/build-thunder.sh
  9. +0
    -7
      scripts/travis/00-keep-travis-running.sh
  10. +0
    -37
      scripts/travis/01-setup-environment.sh
  11. +0
    -20
      scripts/travis/02-before-install.sh
  12. +0
    -26
      scripts/travis/03-build-thunder-composer.sh
  13. +0
    -21
      scripts/travis/03-build-thunder-drush.sh
  14. +0
    -10
      scripts/travis/03-build-thunder2.sh
  15. +0
    -13
      scripts/travis/03-use-thunder-artifact.sh
  16. +0
    -49
      scripts/travis/04-install-thunder.sh
  17. +0
    -14
      scripts/travis/04-use-database-artifact.sh
  18. +0
    -30
      scripts/travis/05-setup-tests.sh
  19. +0
    -36
      scripts/travis/05-update-2-3.sh
  20. +0
    -8
      scripts/travis/06-run-config-tests.sh
  21. +0
    -25
      scripts/travis/06-run-tests.sh
  22. +0
    -23
      scripts/travis/06-test-source-code.sh
  23. +0
    -33
      scripts/travis/07-upload-artifacts-to-s3.sh
  24. +0
    -47
      scripts/travis/08-build-docker-performance-image.sh

+ 3
- 0
.github/labels.yml View File

@@ -13,3 +13,6 @@
- name: test-performance
description: Triggers the performance testing
color: c2e0c6
- name: test-upgrade
description: Triggers the upgrade path testing
color: 8e36db

+ 84
- 20
.github/workflows/test.yml View File

@@ -14,7 +14,7 @@ env:
DRUPAL_TESTING_COMPOSER_PROJECT: thunder/thunder-project
DRUPAL_TESTING_DATABASE_USER: root
DRUPAL_TESTING_DATABASE_PASSWORD: root
DRUPAL_TESTING_TEST_DUMP_FILE: dump.sql
DRUPAL_TESTING_TEST_DUMP_FILE: db-dump.php
DRUPAL_TESTING_DATABASE_ENGINE: mysql
DRUPAL_TESTING_TEST_CODING_STYLES: false
DRUPAL_TESTING_TEST_PROFILE: thunder
@@ -48,10 +48,6 @@ jobs:
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-cache-

- name: Setup environment variables
run: |
echo "::add-path::$HOME/.composer/vendor/bin"

- name: Get build environment
run: |
composer self-update
@@ -111,10 +107,6 @@ jobs:
run: |
sudo /etc/init.d/mysql start

- name: Setup environment variables
run: |
echo "::add-path::$HOME/.composer/vendor/bin"

- name: Get build environment
run: composer global require thunder/drupal-testing

@@ -137,6 +129,89 @@ jobs:
RIDDLE_TOKEN: ${{ secrets.RIDDLE_TOKEN }}
run: test-drupal-project run_tests

test-upgrade:

runs-on: ubuntu-latest

if: ${{ contains(github.event.pull_request.labels.*.name, 'test-upgrade') || github.event_name == 'schedule' }}

env:
DRUPAL_TESTING_TEST_DEPRECATION: false
DRUPAL_TESTING_COMPOSER_PROJECT_VERSION: 2.x-dev
DRUPAL_TESTING_COMPOSER_PROJECT: BurdaMagazinOrg/thunder-project
DRUPAL_TESTING_TEST_GROUP: "Thunder --exclude-group NoUpdate"

steps:
- uses: actions/[email protected]

- uses: shivammathur/[email protected]
with:
coverage: none
php-version: '7.3'
extensions: Imagick

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Start MySql service
run: sudo /etc/init.d/mysql start

- name: Cache composer dependencies
uses: actions/[email protected]
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-cache-

- name: Get build environment
run: composer global require thunder/drupal-testing

- name: Prepare the build
run: test-drupal-project prepare_build

- name: Use Thunder 2 lockfile
run: |
touch /tmp/test/thunder/finished-stages/build
cp ${GITHUB_WORKSPACE}/tests/fixtures/thunder2.composer.lock composer.lock
composer install
composer drupal-scaffold
working-directory: /tmp/test/thunder/install

- name: Install drupal
run: test-drupal-project install

- name: Update the docroot
run: |
composer remove thunder/testsite_builder --dev --no-update
composer require drupal/paragraphs:1.10 drupal/core:~8.7.0 --no-update
composer update
vendor/bin/drush updb -y
composer remove drupal/paragraphs --no-update
composer update
composer require burdamagazinorg/thunder:~8.2.51 --no-update
composer update
vendor/bin/drush updb -y
composer remove burdamagazinorg/thunder
composer require "thunder/thunder-distribution:*" drupal/core:~8.9.0 --no-update
composer update
composer require "thunder/thunder_testing_demo:3.x-dev" "drupal/media_entity:^2.0-beta4" "drupal/video_embed_field:^2.2" "drupal/media_entity_image" "drupal/riddle_marketplace:^3.0-beta2"
vendor/bin/drush updb -y
vendor/bin/drush en vem_migrate_oembed -y
vendor/bin/drush vem:migrate_oembed
vendor/bin/drush cr
cd docroot
php core/scripts/db-tools.php dump-database-d8-mysql > db-dump.php
working-directory: /tmp/test/thunder/install

- name: Run tests suite
env:
PUSHER_CREDENTIALS: ${{ secrets.PUSHER_CREDENTIALS }}
RIDDLE_TOKEN: ${{ secrets.RIDDLE_TOKEN }}
run: test-drupal-project run_tests

test-min:

runs-on: ubuntu-latest
@@ -173,10 +248,6 @@ jobs:
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-cache-

- name: Setup environment variables
run: |
echo "::add-path::$HOME/.composer/vendor/bin"

- name: Get build environment
run: |
composer self-update
@@ -223,13 +294,6 @@ jobs:
php-version: '7.3'
extensions: Imagick

- name: Setup environment variables
run: |
echo "::add-path::$HOME/.composer/vendor/bin"

- name: Get build environment
run: composer global require thunder/drupal-testing

- name: Download build
uses: actions/[email protected]
with:


+ 0
- 86
.travis.yml View File

@@ -1,86 +0,0 @@
language: php
cache:
directories:
- "$HOME/.composer/cache"
- "$HOME/.drush/cache"

php:
- 7.3

dist: bionic

services:
- mysql

branches:
only:
- /^8\.x\-[0-9]+\.x$/

addons:
artifacts:
region: eu-west-1
paths:
- /tmp/thunder-travis-ci

stages:
- sanity checks
- test

env:
global:
- THUNDER_ADMIN_BRANCH=8.x-3.x
- ADDITIONAL_COMPOSER_PARAMETERS=""
- ADDITIONAL_PHPUNIT_PARAMETERS=""

jobs:
allow_failures:
- stage: performance test

include:
- stage: sanity checks
name: Check config for drush_make build
install:
- bash -x -e ./scripts/travis/03-build-thunder-drush.sh
script:
- bash -x -e ./scripts/travis/06-run-config-tests.sh
if: commit_message =~ \[(TEST_DRUSH_MAKE|TEST_EVERYTHING)\] OR type = cron OR head_branch =~ ^release

- stage: test
name: Run tests with drush_make build
install:
- bash -x -e ./scripts/travis/03-build-thunder-drush.sh
if: commit_message =~ \[(TEST_DRUSH_MAKE|TEST_EVERYTHING)\] OR type = cron OR head_branch =~ ^release

- stage: test
name: Run upgrade test
env: ADDITIONAL_PHPUNIT_PARAMETERS="--exclude-group NoUpdate"
install:
- bash -x -e ./scripts/travis/03-build-thunder2.sh
script:
- bash -x -e ./scripts/travis/05-update-2-3.sh
- bash -x -e ./scripts/travis/06-run-tests.sh
php: 7.2
if: commit_message =~ \[(TEST_UPGRADE|TEST_EVERYTHING)\] OR type = cron

# In the Thunder 8.x-3.x branch we have to wait for an actual releases to be able to test updates. That is why we
# currently disable those tests. TODO: re-enable them after release of Thunder 3
# - stage: test
# name: Run update test
# env: TEST_UPDATE=true
# if: commit_message =~ \[TEST_UPDATE\] OR type = cron

# The main functionality is divided into different scripts, each is prefixed by a number which
# indicates the execution order
before_install:
- bash -e ./scripts/travis/00-keep-travis-running.sh &
- source ./scripts/travis/01-setup-environment.sh
- bash -x -e ./scripts/travis/02-before-install.sh

install:
- bash -x -e ./scripts/travis/03-use-thunder-artifact.sh

before_script:
- bash -x -e ./scripts/travis/04-install-thunder.sh

script:
- bash -x -e ./scripts/travis/06-run-tests.sh

+ 1
- 2
README.md View File

@@ -1,10 +1,9 @@
# <img src="./files/images/thunder.svg?sanitize=true" alt="Thunder" width="4%"/> Thunder [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=I%20just%20tried%20ThunderCMS.%20The%20CMS%20for%20professional%20publishing!&url=https://www.thunder.org&via=ThunderCoreTeam&hashtags=drupal8,publishing,ThunderCMS)

[![Build Status](https://travis-ci.com/thunder/thunder-distribution.svg?branch=8.x-4.x)](https://travis-ci.com/thunder/thunder-distribution)
[![Build Status](https://github.com/thunder/thunder-distribution/workflows/.github/workflows/test.yml/badge.svg)](https://github.com/thunder/thunder-distribution/actions)

Thunder is a Drupal 8 distribution for professional publishers. It consists of the current Drupal 8 functionality, lots of useful modules from publishers and industry partners, and an environment which makes it easy to install, deploy and add new functionality.


## Installing Thunder
Instructions on how to install Thunder can be found at the [installation guide](https://thunder.github.io/thunder-documentation/quick-install).



+ 3
- 2
composer.json View File

@@ -107,7 +107,7 @@
"drupal/length_indicator": "^1.0-rc2",
"drupal/libraries": "^3.0-alpha1",
"drupal/linkit": "^5.0-beta9",
"drupal/liveblog": "^1.2-alpha14",
"drupal/liveblog": "^1.3-alpha15",
"drupal/media_entity_instagram": "^2.0-alpha1",
"drupal/media_entity_pinterest": "^2.0",
"drupal/media_entity_slideshow": "^2.0-alpha1",
@@ -137,7 +137,8 @@
"npm-asset/blazy": "^1.8",
"npm-asset/slick-carousel": "^1.8",
"npm-asset/shariff": "^3.1.1",
"npm-asset/select2": "^4.0.7"
"npm-asset/select2": "^4.0.7",
"pusher/pusher-php-server": "^3.0.3 || ^4.1.1"
},
"suggest": {
"drupal/riddle_marketplace": "Riddle marketplace integration",


+ 7
- 10
docs/development.md View File

@@ -129,7 +129,7 @@ After you have running chrome in docker, you have also to change environment var
DRUPAL_TEST_WEBDRIVER_PORT=4444
DRUPAL_TEST_WEBDRIVER_PATH_PREFIX=/wd/hub
DRUPAL_TEST_CHROMEDRIVER_AUTOSTART=false
```
```
You can copy/paste this section to the bottom of your `.env` file.

----------
@@ -140,17 +140,14 @@ Documentation how to check your code for coding style issues can be found [here]

----------

## Thunder Travis CI

All Thunder pull requests are execute on [Travis CI](https://travis-ci.com/thunder/thunder-distribution). On every pull request tests will be executed (or when new commits are pushed into pull request branch). Tests are executed against PHP version 7.3 (with drush make install and with composer install). All code will be checked against coding style.
## Thunder GitHub actions

We support some test execution options. They can be provided in commit message in square brackets []. Here is list of options supported:
- TEST_UPDATE - this option will execute custom test path, where update (including execution of update hooks) from latest released version will be tested. This option should be used in case of pull request with update hooks or module update.
All Thunder pull requests are execute on [GitHub actions](https://github.com/thunder/thunder-distribution/actions). On every pull request tests will be executed (or when new commits are pushed into pull request branch). All code will be checked against coding style.

Example to execute update test path:
```
git commit -m "[TEST_UPDATE] Trigger update test path"
```
We support some test execution options. They can be provided by pull request labels. Here is list of supported labels:
- test-upgrade - this option will execute a custom test path, where an update (including execution of update hooks) from Thunder 2 will be tested. This option should be used in case of a pull request with update hooks or module updates.
- test-min - this options installs the pull request version of Thunder with the oldest possible dependencies and executes the test suite.
- test-performance - this option pushed the code base to our performance testing infrastructure. A successful test-max build is the required for this.

----------



+ 0
- 111
docs/pull-screenshots-from-travis-ci.md View File

@@ -1,111 +0,0 @@
## How to pull screenshots from Travis CI

When some layout is changed and screenshots for tests have to be updated, then the screenshots have to be fetched from Travis CI.
Other solution is to have a local docker Travis CI environment to create new screenshots.

#### 1. Start Travis CI debug sessions

To start a Travis CI job in debug mode ([more information here](https://docs.travis-ci.com/user/running-build-in-debug-mode/#Restarting-a-job-in-debug-mode-via-API)), the following command should be executed (with providing token and Travis CI job id):

```
$ curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token <TRAVIS_CI_TOKEN>" \
-d '{ "quiet": true }' \
https://api.travis-ci.com/job/<TRAVIS_CI_JOB_ID>/debug
```

After that Travis CI job will run in debug mode and in log output on travis.com, it will provide a ssh link to access it.
It looks like: ssh <SOME_HASH>@ny2.tmate.io

Copy that command and execute it in the console, that will make a connection to `tmux` for Travis CI debug session.

#### 2. Execute `.travis.yml` steps

To execute the usual Travis CI steps, run the following commands:

```
$ travis_run_before_install
$ travis_run_install
$ travis_run_before_script
```

#### 3. Prepare run tests script

Open a new bash session in `tmux` (Ctrl-b c).

Then edit the script for running of tests:
```
$ vi scripts/travis/06-run-tests.sh
```

Prepend the line that executes tests with `generateMode=true`, that flag is used to create screenshots during the test execution. The line in the script should look like this: ```generateMode=true thunderDumpFile=thunder.php.gz php ${TEST_DIR}/docroot/core/scripts/run-tests.sh --php `which php` --verbose --color --url http://localhost:8080 Thunder```

(optional) The Speed-Up solution is to add additional filtering. In that way it's possible to run only the tests that should be updated, then the generation of the screenshots will be execute faster.
For example: ```generateMode=true thunderDumpFile=thunder.php.gz php ${TEST_DIR}/docroot/core/scripts/run-tests.sh --php `which php` --verbose --color --url http://localhost:8080 --class "Drupal\Tests\thunder\FunctionalJavascript\Update\ThunderMediaTest"```

#### 4. Run tests

Go back to default bash session (Ctrl-b 0) and execute the script to run the tests.
```
$ bash -x -e ./scripts/travis/06-run-tests.sh
```

They have to finish successfully.

#### 5. Serve screenshots

Start a new bash session in `tmux` (Ctrl-b c) and go to the `screenshots` directory.

```
$ cd ../test-dir/docroot/profiles/contrib/thunder/tests/fixtures/screenshots/
```
or for `drush make` build:
```
$ cd ../test-dir/docroot/profiles/thunder/tests/fixtures/screenshots/
```

And run a HTTP server to serve files from that folder.
```
$ python -m SimpleHTTPServer 8001
```

#### 6. `ngrok` (to pull them all)

Start a new bash session in `tmux` (Ctrl-b c).
Download `ngrok` Linux 64-Bit version from [https://ngrok.com/download](https://ngrok.com/download) and start it.

```
$ wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
$ unzip ngrok-stable-linux-amd64.zip
$ ./ngrok http 8001
```

That will create a `ngrok` url, that you can use to access the served screenshots directory.

#### 7. Fetch screenshots

When `ngrok` url is opened in the browser, a list of all screenshots should be available for download.

#### 8. (optional) Verify that screenshots are correct

Go to bash session (Ctrl-b 1).
And remove `generateMode=true` from the test execution line in the script that runs the tests.

So open file:
```
$ vi scripts/travis/06-run-tests.sh
```

And set something like this: ```thunderDumpFile=thunder.php.gz php ${TEST_DIR}/docroot/core/scripts/run-tests.sh --php `which php` --verbose --color --url http://localhost:8080 Thunder```

Save and switch to the default bash session (Ctrl-b 0), where the tests should be executed.
```
$ bash -x -e ./scripts/travis/06-run-tests.sh
```

#### 9. Finish Travis CI debug session

After everything is finished, all `tmux` sessions should be closed to finish the Travis CI debug session.

+ 0
- 19
scripts/development/build-thunder.sh View File

@@ -1,19 +0,0 @@
#!/usr/bin/env bash

BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../.."

DEST_DIR="$BASE_DIR/../thunder"

if [ $1 ] ; then
DEST_DIR="$1"
fi

composer create-project thunder/thunder-project:3.x ${DEST_DIR} --stability dev --no-interaction --no-install

cd ${DEST_DIR}
composer config repositories.thunder path ${BASE_DIR}
composer config repositories.thunder_admin git https://github.com/BurdaMagazinOrg/theme-thunder-admin.git

composer require "thunder/thunder-distribution:*" "phpunit/phpunit:~4.8" "behat/mink-selenium2-driver" "behat/mink-goutte-driver" "mikey179/vfsStream" "burdamagazinorg/thunder-dev-tools:*" "burdamagazinorg/robo:*" --no-progress

echo "<?php use Thunder\Robo\RoboFileBase; class RoboFile extends RoboFileBase {}" > RoboFile.php

+ 0
- 7
scripts/travis/00-keep-travis-running.sh View File

@@ -1,7 +0,0 @@
#!/bin/bash

while true
do
echo "Still testing...."
sleep 300
done

+ 0
- 37
scripts/travis/01-setup-environment.sh View File

@@ -1,37 +0,0 @@
#!/usr/bin/env bash

## Setup environment
# add composer's global bin directory to the path
# see: https://github.com/drush-ops/drush#install---composer
export THUNDER_DIST_DIR=`echo $(pwd -P)`
export TEST_DIR=`echo ${THUNDER_DIST_DIR}"/../test-dir"`
export PATH="$TEST_DIR/vendor/bin:$TEST_DIR/docroot/vendor/bin:$HOME/.composer/vendor/bin:$PATH"
export MINK_DRIVER_ARGS_WEBDRIVER='["chrome", null, "http://localhost:4444/wd/hub"]'
export COMPOSER_MEMORY_LIMIT=-1
export SIMPLETEST_BASE_URL=http://localhost:8080
export SYMFONY_DEPRECATIONS_HELPER=disabled

# base path for update tests
export UPDATE_BASE_PATH=${TEST_DIR}-update-base

# Set version of imagick
export PHP_IMAGICK_VERSION="3.4.3"

# Set version for Yaml PHP library
export PHP_YAML_VERSION="2.0.4"

# Database dump for deployment testing
export DEPLOYMENT_DUMP_FILE="${TEST_DIR}/dump_thunder_test_deployment.sql"

# Provide environment variables for AWS Cli
export AWS_ACCESS_KEY_ID="${ARTIFACTS_KEY}"
export AWS_SECRET_ACCESS_KEY="${ARTIFACTS_SECRET}"

# Artifact names and files for AWS S3 backup and reuse
export DB_ARTIFACT_FILE_NAME="${TRAVIS_BUILD_ID}-db-dump.gz"
export DB_ARTIFACT_FILE="${THUNDER_DIST_DIR}/../${DB_ARTIFACT_FILE_NAME}"
export PROJECT_ARTIFACT_FILE_NAME="${TRAVIS_BUILD_ID}-thunder.tar.gz"
export PROJECT_ARTIFACT_FILE="${THUNDER_DIST_DIR}/../${PROJECT_ARTIFACT_FILE_NAME}"

# Branch name related to Travis CI job
export BRANCH_NAME=$([[ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]] && echo "${TRAVIS_PULL_REQUEST_BRANCH}" || echo "${TRAVIS_BRANCH}")

+ 0
- 20
scripts/travis/02-before-install.sh View File

@@ -1,20 +0,0 @@
#!/usr/bin/env bash

# Disable xdebug.
echo "" > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
# Stop drush from sending email
echo "sendmail_path = /bin/true" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
phpenv rehash

# Install AWS CLI
pip install --user awscli

# Prepare test directory
cd $TRAVIS_BUILD_DIR
mkdir -p ${TEST_DIR}

# Install Drush
composer global require drush/drush:^8.1

# Clear drush release history cache, to pick up new releases.
rm -f ~/.drush/cache/download/*---updates.drupal.org-release-history-*

+ 0
- 26
scripts/travis/03-build-thunder-composer.sh View File

@@ -1,26 +0,0 @@
#!/usr/bin/env bash

# Download latest Thunder release for update
if [[ ${TEST_UPDATE} == "true" ]]; then
# Download latest release from drupal.org
mkdir -p $UPDATE_BASE_PATH
cd $UPDATE_BASE_PATH
drush dl thunder --drupal-project-rename="docroot" -y
composer install --working-dir=${UPDATE_BASE_PATH}/docroot
fi

cd ${THUNDER_DIST_DIR}
composer create-project thunder/thunder-project:3.x ${TEST_DIR} --stability dev --no-interaction --no-install

cd ${TEST_DIR}

if [[ ${TEST_UPDATE} == "true" ]]; then
sed -i 's/docroot\/profiles\/contrib/docroot\/profiles/g' composer.json
fi

composer config repositories.thunder path ${THUNDER_DIST_DIR}
composer require "thunder/thunder-distribution:*" "thunder/thunder_testing_demo:3.x-dev" "phpunit/phpunit:^6.5" "composer/composer:^1.9.0" "mglaman/phpstan-drupal:~0.12.0" "phpstan/phpstan-deprecation-rules:~0.12.0" "drupal/riddle_marketplace:^3.0-beta2" "drupal/nexx_integration:^1.0" "valiton/harbourmaster:~8.1" --no-progress ${ADDITIONAL_COMPOSER_PARAMETERS}

# Get custom branch of Thunder Admin theme
rm -rf ${TEST_DIR}/docroot/themes/contrib/thunder_admin
git clone --depth 1 --single-branch --branch ${THUNDER_ADMIN_BRANCH} https://github.com/BurdaMagazinOrg/theme-thunder-admin.git ${TEST_DIR}/docroot/themes/contrib/thunder_admin

+ 0
- 21
scripts/travis/03-build-thunder-drush.sh View File

@@ -1,21 +0,0 @@
#!/usr/bin/env bash

cd ${THUNDER_DIST_DIR}

# Build drupal + thunder from makefile
drush make --concurrency=5 drupal-org-core.make ${TEST_DIR}/docroot -y
mkdir ${TEST_DIR}/docroot/profiles/thunder
shopt -s extglob
rsync -a . ${TEST_DIR}/docroot/profiles/thunder --exclude docroot

drush make -y --no-core ${TEST_DIR}/docroot/profiles/thunder/drupal-org.make ${TEST_DIR}/docroot/profiles/thunder

# Get development branch of Thunder Admin theme (to use same admin theme as for composer build)
rm -rf ${TEST_DIR}/docroot/profiles/thunder/themes/thunder_admin
git clone --depth 1 --single-branch --branch ${THUNDER_ADMIN_BRANCH} https://github.com/BurdaMagazinOrg/theme-thunder-admin.git ${TEST_DIR}/docroot/profiles/thunder/themes/thunder_admin

composer install --working-dir=${TEST_DIR}/docroot

# require development packages needed for testing
composer config minimum-stability dev --working-dir ${TEST_DIR}/docroot
COMPOSER_ROOT_VERSION=8.8.x-dev composer require "drupal/core-dev:^8.8.0" "thunder/thunder_testing_demo:3.x-dev" "lullabot/amp" "pusher/pusher-php-server:^3.0.0" --no-progress --working-dir ${TEST_DIR}/docroot

+ 0
- 10
scripts/travis/03-build-thunder2.sh View File

@@ -1,10 +0,0 @@
#!/usr/bin/env bash

cd ${THUNDER_DIST_DIR}
composer create-project BurdaMagazinOrg/thunder-project:2.x ${TEST_DIR} --stability dev --no-interaction --no-install

cd ${TEST_DIR}

cp ${THUNDER_DIST_DIR}/tests/fixtures/thunder2.composer.lock composer.lock
composer install
composer drupal-scaffold

+ 0
- 13
scripts/travis/03-use-thunder-artifact.sh View File

@@ -1,13 +0,0 @@
#!/usr/bin/env bash
#
# Download stored project artifact on S3 and export it

# Download project artifact from S3
aws s3 cp "s3://thunder-builds/${PROJECT_ARTIFACT_FILE_NAME}" "${PROJECT_ARTIFACT_FILE}"

# Extract files to test directory
tar -zxf "${PROJECT_ARTIFACT_FILE}" -C "${TEST_DIR}"

# Install development dependencies
cd "${TEST_DIR}"
composer install --dev

+ 0
- 49
scripts/travis/04-install-thunder.sh View File

@@ -1,49 +0,0 @@
#!/usr/bin/env bash

# Install thunder and enable Test module
# in provided folder
install_thunder() {
cd $1

/usr/bin/env PHP_OPTIONS="-d sendmail_path=`which true`" drush si thunder --db-url=mysql://[email protected]/drupal -y thunder_module_configure_form.install_modules_thunder_demo
drush en simpletest -y

drush -y sql-dump --result-file=${DEPLOYMENT_DUMP_FILE}
}

# Mock update process for deployment workflow
update_thunder_mock_deployment() {
# Enable optional modules
drush -y en password_policy

drush -y cex sync
drush -y sql-drop
drush -y sql-cli < ${DEPLOYMENT_DUMP_FILE}
drush cr
drush -y updatedb
drush -y cim sync
}

# Update thunder to current test version
update_thunder() {
# Link sites folder from initial installation
mv ${TEST_DIR}/docroot/sites ${TEST_DIR}/docroot/_sites
ln -s ${UPDATE_BASE_PATH}/docroot/sites ${TEST_DIR}/docroot/sites

cd ${TEST_DIR}/docroot

# Execute all required updates
drush cr
drush updatedb -y

update_thunder_mock_deployment
}

# Install Thunder
if [[ ${TEST_UPDATE} == "true" ]]; then
# Install last drupal org version and update to currently tested version
install_thunder ${UPDATE_BASE_PATH}/docroot
update_thunder
else
install_thunder ${TEST_DIR}/docroot
fi

+ 0
- 14
scripts/travis/04-use-database-artifact.sh View File

@@ -1,14 +0,0 @@
#!/usr/bin/env bash
#
# Download stored database dump from S3 and import it

# Download project artifact from S3
aws s3 cp "s3://thunder-builds/${DB_ARTIFACT_FILE_NAME}" "${DB_ARTIFACT_FILE}"

# Unzip to deployment file. Deployment file should be provided for other scripts to work properly.
gunzip < "${DB_ARTIFACT_FILE}" > "${DEPLOYMENT_DUMP_FILE}"

# Import database
cd "${TEST_DIR}/docroot"
drush -y sql-create
drush -y sql-cli < "${DEPLOYMENT_DUMP_FILE}"

+ 0
- 30
scripts/travis/05-setup-tests.sh View File

@@ -1,30 +0,0 @@
#!/usr/bin/env bash

# install image magick
wget -q https://github.com/mkoppanen/imagick/archive/$PHP_IMAGICK_VERSION.tar.gz -O php-imagick-LATEST.tar.gz
yes '' | pecl -q install -f php-imagick-LATEST.tar.gz

# Build and install the YAML extension for strict parsing.
wget -q https://github.com/php/pecl-file_formats-yaml/archive/$PHP_YAML_VERSION.tar.gz -O php-yaml-LATEST.tar.gz
tar -C /tmp -zxf php-yaml-LATEST.tar.gz
cd /tmp/pecl-file_formats-yaml-$PHP_YAML_VERSION
phpize
# Silence configure
./configure > /dev/null
make -s
make -s install
echo "extension = yaml.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
phpenv rehash

cd ${TEST_DIR}/docroot

#EXAMPLE:
# apply cookie expire patch for javascript tests
#wget https://www.drupal.org/files/issues/test-session-expire-2771547-64.patch
#patch -p1 < test-session-expire-2771547-64.patch

# CREATE TESTING DUMP
php ./core/scripts/db-tools.php dump-database-d8-mysql > thunder.php

# Run the webserver
php -S localhost:8080 .ht.router.php &>/dev/null &

+ 0
- 36
scripts/travis/05-update-2-3.sh View File

@@ -1,36 +0,0 @@
#!/usr/bin/env bash

# Update paragraphs to version 1.10 first.
cd ${TEST_DIR}
composer require drupal/paragraphs:1.10 drupal/core:~8.7.0 --no-update
composer update
cd ${TEST_DIR}/docroot
drush updb -y
# Remove paragraphs dependency.
cd ${TEST_DIR}
composer remove drupal/paragraphs --no-update
composer update

# Update to the latest version of thunder.
cd ${TEST_DIR}
composer require burdamagazinorg/thunder:~8.2.51 --no-update
composer update

cd ${TEST_DIR}/docroot
drush updb -y

cd ${TEST_DIR}
composer config repositories.thunder path ${THUNDER_DIST_DIR}

composer remove burdamagazinorg/thunder
composer require "thunder/thunder-distribution:*" drupal/core:~8.8.0 --no-update

composer update

composer require "thunder/thunder_testing_demo:3.x-dev" "drupal/media_entity:^2.0-beta4" "drupal/video_embed_field:^2.2" "drupal/media_entity_image" "drupal/riddle_marketplace:^3.0-beta2"

cd ${TEST_DIR}/docroot
drush updb -y
drush en vem_migrate_oembed -y
drush vem:migrate_oembed
drush cr

+ 0
- 8
scripts/travis/06-run-config-tests.sh View File

@@ -1,8 +0,0 @@
#!/usr/bin/env bash

source ${THUNDER_DIST_DIR}/scripts/travis/05-setup-tests.sh

# Run Drupal tests
cd ${TEST_DIR}/docroot

thunderDumpFile=thunder.php phpunit --verbose --debug --configuration core --group ThunderConfig ${ADDITIONAL_PHPUNIT_PARAMETERS} $(pwd)/$(drush eval "echo drupal_get_path('profile', 'thunder');")/tests || exit 1

+ 0
- 25
scripts/travis/06-run-tests.sh View File

@@ -1,25 +0,0 @@
#!/usr/bin/env bash

source ${THUNDER_DIST_DIR}/scripts/travis/05-setup-tests.sh

cd ${TEST_DIR}/docroot

# Silently pull docker image
docker pull selenium/standalone-chrome:3.14.0-iron > /dev/null
docker run -d -p 4444:4444 -v $(pwd)/$(drush eval "echo drupal_get_path('profile', 'thunder');"):/project -v /dev/shm:/dev/shm --net=host selenium/standalone-chrome:3.14.0-iron
docker ps -a

# Make simple export import
if [[ "${TEST_UPDATE}" != "true" ]]; then
drush -y cex sync

# We have to use "2>&1" because drush outputs everything to stderr
DRUSH_CIM_RESULT=$(drush -y cim sync 2>&1)
if [[ "${DRUSH_CIM_RESULT}" != *"There are no changes to import."* ]]; then
exit 1
fi
fi

# execute Drupal tests
thunderDumpFile=thunder.php phpunit --verbose --debug --configuration core --group Thunder ${ADDITIONAL_PHPUNIT_PARAMETERS} $(pwd)/$(drush eval "echo drupal_get_path('profile', 'thunder');")/tests || exit 1
thunderDumpFile=thunder.php phpunit --verbose --debug --configuration core --group ThunderInstaller ${ADDITIONAL_PHPUNIT_PARAMETERS} $(pwd)/$(drush eval "echo drupal_get_path('profile', 'thunder');")/tests || exit 1

+ 0
- 23
scripts/travis/06-test-source-code.sh View File

@@ -1,23 +0,0 @@
#!/usr/bin/env bash

# run phpcs
phpcs --config-set installed_paths ${TEST_DIR}/vendor/drupal/coder/coder_sniffer
# Ignore check of .md files, because they should be able to contain more then 80 characters per line.
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme --ignore=*.md -p .
phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme -p .

# JS ESLint checking
if ! [ -x "$(command -v eslint)" ]; then
npm install -g eslint
fi

# Install ESLint requirements
npm install -g eslint-config-drupal-bundle

# Execute JavaScript code check
eslint .

# Check for deprecated methods.
cd ${TEST_DIR}
cp ${THUNDER_DIST_DIR}/phpstan.neon.dist phpstan.neon
phpstan analyse --memory-limit 300M ${TEST_DIR}/docroot/profiles/contrib/thunder

+ 0
- 33
scripts/travis/07-upload-artifacts-to-s3.sh View File

@@ -1,33 +0,0 @@
#!/usr/bin/env bash
#
# Package and upload built Thunder project and database

# Package database
gzip < "${DEPLOYMENT_DUMP_FILE}" > "${DB_ARTIFACT_FILE}"

# Workaround for https://www.drupal.org/project/drupal/issues/3091285
chmod -R +w "${TEST_DIR}/docroot/sites/default"

# Include performance measurement module in artifact
cd "${TEST_DIR}"
composer require "thunder/thunder_performance_measurement:dev-master" "thunder/testsite_builder:dev-master" "drupal/media_entity_generic:^1.0" --no-interaction --update-no-dev

# Apply patches important for testsite_builder
cd "${TEST_DIR}/docroot" || exit
curl --silent "https://www.drupal.org/files/issues/2020-01-29/3109767_2.patch" | patch -p1

# Cleanup project
cd "${TEST_DIR}"
composer install --no-dev
rm -rf "${TEST_DIR}/bin"
rm -rf "${TEST_DIR}/docroot/sites/default/files/*"
rm -f "${DEPLOYMENT_DUMP_FILE}"
find "${TEST_DIR}" -type d -name ".git" | xargs rm -rf
find "${THUNDER_DIST_DIR}" -type d -name ".git" | xargs rm -rf

# Make zip for package
cd "${TEST_DIR}" && tar -czhf "${PROJECT_ARTIFACT_FILE}" .

# Upload files to S3 bucket
aws s3 cp "${DB_ARTIFACT_FILE}" "s3://thunder-builds/${DB_ARTIFACT_FILE_NAME}"
aws s3 cp "${PROJECT_ARTIFACT_FILE}" "s3://thunder-builds/${PROJECT_ARTIFACT_FILE_NAME}"

+ 0
- 47
scripts/travis/08-build-docker-performance-image.sh View File

@@ -1,47 +0,0 @@
#!/usr/bin/env bash
#
# Download stored project artifact on S3 and pack it into Thunder performance docker image

# Get Thunder performance Docker project for packaging
THUNDER_PERFORMANCE="${TEST_DIR}/../docker-thunder-performance"
git clone https://github.com/thunder/docker-thunder-performance.git "${THUNDER_PERFORMANCE}"

# Download project artifact from S3
aws s3 cp "s3://thunder-builds/${PROJECT_ARTIFACT_FILE_NAME}" "${PROJECT_ARTIFACT_FILE}"

# Extract files to www directory for Docker image packaging
mkdir -p "${THUNDER_PERFORMANCE}/www"
tar -zxf "${PROJECT_ARTIFACT_FILE}" -C "${THUNDER_PERFORMANCE}/www"

# Build Docker image
cd "${THUNDER_PERFORMANCE}"

# Build Docker image and tag it
DOCKER_SANITIZED_BRANCH_NAME=$(echo "${BRANCH_NAME}" | sed 's/\//_/g')
DOCKER_IMAGE_TAG="burda/thunder-performance:${DOCKER_SANITIZED_BRANCH_NAME}-${TRAVIS_JOB_ID}"
./build.sh --tag "${DOCKER_IMAGE_TAG}"

# list Docker images
docker images

# Login to Docker HUB
echo "${DOCKER_PASSWORD_BASE64}" | base64 -d | docker login -u "${DOCKER_USERNAME}" --password-stdin

# Push to Docker HUB
docker push "${DOCKER_IMAGE_TAG}"

# Start Thunde performance testing task for created image
API_CALL_HTTP_CODE=$(curl \
--request POST \
--insecure \
"https://${THUNDER_PTM_HOST}:3000/warmers" \
--header "Authorization: Bearer ${THUNDER_PTM_TOKEN}" \
--header "Content-Type: application/json" \
--data "{\"branchTag\":\"${DOCKER_SANITIZED_BRANCH_NAME}\",\"imageTag\":\"${DOCKER_SANITIZED_BRANCH_NAME}-${TRAVIS_JOB_ID}\",\"composeType\":\"default\"}" \
--output /dev/stderr \
--write-out "%{http_code}" \
)

if [[ "${API_CALL_HTTP_CODE}" != "200" ]]; then
exit 1
fi

Loading…
Cancel
Save