From 1cdca12b5ca0b5a167c45697bec29b5a0b02a69e Mon Sep 17 00:00:00 2001 From: Daniel Bosen Date: Tue, 17 Mar 2020 17:09:51 +0100 Subject: [PATCH] Add min-build testing (#18) --- .github/workflows/test.yml | 16 ++++++---------- configuration.sh | 8 ++++++++ lib/stages/build.sh | 7 ++++++- lib/stages/prepare_build.sh | 12 +++++++----- lib/stages/start_services.sh | 4 +++- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f2310a..ce04112 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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' @@ -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" @@ -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 diff --git a/configuration.sh b/configuration.sh index c532e0c..16339be 100644 --- a/configuration.sh +++ b/configuration.sh @@ -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)}} @@ -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} diff --git a/lib/stages/build.sh b/lib/stages/build.sh index 0b2132f..1706b2f 100644 --- a/lib/stages/build.sh +++ b/lib/stages/build.sh @@ -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}")" diff --git a/lib/stages/prepare_build.sh b/lib/stages/prepare_build.sh index 3a637ba..8afde82 100644 --- a/lib/stages/prepare_build.sh +++ b/lib/stages/prepare_build.sh @@ -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 @@ -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 diff --git a/lib/stages/start_services.sh b/lib/stages/start_services.sh index 59c82dd..aa80940 100644 --- a/lib/stages/start_services.sh +++ b/lib/stages/start_services.sh @@ -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 }