Skip to content

Commit

Permalink
Add min-build testing (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbosen authored Mar 17, 2020
1 parent 06dd090 commit 1cdca12
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ jobs:

strategy:
matrix:
RUN: [1, 2, 3]
RUN: [1, 2, 3, 4]
include:
- RUN: 1
DRUPAL_TESTING_COMPOSER_PROJECT: 'drupal/recommended-project'
DRUPAL_TESTING_DRUPAL_VERSION: '~8.7.0'
- RUN: 2
DRUPAL_TESTING_COMPOSER_PROJECT: 'drupal/recommended-project'
DRUPAL_TESTING_DRUPAL_VERSION: '*'
- RUN: 3
DRUPAL_TESTING_COMPOSER_PROJECT: 'drupal/recommended-project'
DRUPAL_TESTING_DRUPAL_VERSION: '~8.8.0'
DRUPAL_TESTING_MIN_BUILD: true
- RUN: 4
DRUPAL_TESTING_COMPOSER_PROJECT: 'thunder/thunder-project'
DRUPAL_TESTING_DRUPAL_VERSION: '~8.8.0'

Expand All @@ -44,14 +47,6 @@ jobs:
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-cache-

- name: Cache NPM dependencies
id: npm-cache
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache
restore-keys: ${{ runner.os }}-npm-cache

- name: Setup environment variables
run: |
echo "::add-path::$HOME/.composer/vendor/bin"
Expand All @@ -63,6 +58,7 @@ jobs:
env:
DRUPAL_TESTING_COMPOSER_PROJECT: ${{ matrix.DRUPAL_TESTING_COMPOSER_PROJECT }}
DRUPAL_TESTING_DRUPAL_VERSION: ${{ matrix.DRUPAL_TESTING_DRUPAL_VERSION }}
DRUPAL_TESTING_MIN_BUILD: ${{ matrix.DRUPAL_TESTING_MIN_BUILD }}

test-split-upload:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ CI=${CI:-${GITHUB_ACTIONS:-false}}
# Generate more verbose output, defaults to false. Can also be set to true by providing the -v parameter to the invoking command.
DRUPAL_TESTING_VERBOSE=${DRUPAL_TESTING_VERBOSE:-false}

# The composer project to use. defaults to the drupal/recommended-project. But e.g. Distribution specific projects can be used instead.
DRUPAL_TESTING_COMPOSER_PROJECT=${DRUPAL_TESTING_COMPOSER_PROJECT:-"drupal/recommended-project"}

# The version of the composer project to use.
DRUPAL_TESTING_COMPOSER_PROJECT_VERSION=${DRUPAL_TESTING_COMPOSER_PROJECT_VERSION:-"*"}

# The directory, where the project is located. On travis this is set to TRAVIS_BUILD_DIR otherwise defaults to the current directory
DRUPAL_TESTING_PROJECT_BASEDIR=${DRUPAL_TESTING_PROJECT_BASEDIR:-${TRAVIS_BUILD_DIR:-$(pwd)}}

Expand Down Expand Up @@ -135,6 +139,10 @@ DRUPAL_TESTING_CONFIG_SYNC_DIRECTORY=${DRUPAL_TESTING_CONFIG_SYNC_DIRECTORY:-"..
# Additional form values for the installation profile. This is uses by drush site-install.
DRUPAL_TESTING_INSTALLATION_FORM_VALUES=${DRUPAL_TESTING_INSTALLATION_FORM_VALUES:-"install_configure_form.enable_update_status_module=NULL"}

# Set this flag to true, to pass the --prefer-lowest parameter to composer. With this parameter, the minimal installable
# versions of dependencies are installed.
DRUPAL_TESTING_MIN_BUILD=${DRUPAL_TESTING_MIN_BUILD:-false}

# The symfony environment variable to ignore deprecations, for possible values see symfony documentation.
# The default value is "week" to ignore any deprecation notices.
export SYMFONY_DEPRECATIONS_HELPER=${SYMFONY_DEPRECATIONS_HELPER-weak}
Expand Down
7 changes: 6 additions & 1 deletion lib/stages/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ _stage_build() {
printf "Building the project.\n\n"

local docroot
local composer_arguments=""
local installed_version
local major_version
local minor_version

docroot=$(get_distribution_docroot)

if ${DRUPAL_TESTING_MIN_BUILD}; then
composer_arguments="--prefer-lowest"
fi

# Install all dependencies
cd "${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}" || exit
composer update
composer update ${composer_arguments}

installed_version=$(composer show 'drupal/core' | grep 'versions' | grep -o -E '[^ ]+$')
major_version="$(cut -d'.' -f1 <<<"${installed_version}")"
Expand Down
12 changes: 7 additions & 5 deletions lib/stages/prepare_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ _stage_prepare_build() {
printf "Prepare composer.json\n\n"

# Build is based on drupal project
composer create-project "${DRUPAL_TESTING_COMPOSER_PROJECT}" "${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}" --no-interaction --no-install
composer create-project "${DRUPAL_TESTING_COMPOSER_PROJECT}":"${DRUPAL_TESTING_COMPOSER_PROJECT_VERSION}" "${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}" --no-interaction --no-install

composer require drupal/core:"${DRUPAL_TESTING_DRUPAL_VERSION}" --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
composer require drupal/core-recommended:"${DRUPAL_TESTING_DRUPAL_VERSION}" --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
composer require drupal/core-dev:"${DRUPAL_TESTING_DRUPAL_VERSION}" --dev --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
if [[ ${DRUPAL_TESTING_PROJECT_TYPE} != "drupal-profile" ]]; then
composer require drupal/core:"${DRUPAL_TESTING_DRUPAL_VERSION}" --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
composer require drupal/core-dev:"${DRUPAL_TESTING_DRUPAL_VERSION}" --dev --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
composer require drupal/core-recommended:"${DRUPAL_TESTING_DRUPAL_VERSION}" --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
fi

# Add asset-packagist for projects, that require frontend assets
if ! composer_repository_exists "https://asset-packagist.org"; then
Expand All @@ -30,7 +32,7 @@ _stage_prepare_build() {
composer require oomphinc/composer-installers-extender --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
fi

composer require drush/drush --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
composer require drush/drush:"^9" --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"

# Require phpstan.
if ${DRUPAL_TESTING_TEST_DEPRECATION}; then
Expand Down
4 changes: 3 additions & 1 deletion lib/stages/start_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ _stage_start_services() {
fi

if ! port_is_open "${DRUPAL_TESTING_HTTP_HOST}" "${DRUPAL_TESTING_HTTP_PORT}"; then
php -S "${DRUPAL_TESTING_HTTP_HOST}":"${DRUPAL_TESTING_HTTP_PORT}" -t "${docroot}" >/dev/null 2>&1 &
cd "${docroot}" || exit
php -S "${DRUPAL_TESTING_HTTP_HOST}":"${DRUPAL_TESTING_HTTP_PORT}" .ht.router.php >/dev/null 2>&1 &
cd - || exit
wait_for_port "${DRUPAL_TESTING_HTTP_HOST}" "${DRUPAL_TESTING_HTTP_PORT}" 30
fi
}

0 comments on commit 1cdca12

Please sign in to comment.