Skip to content
Snippets Groups Projects

Remove dependencies from build

Merged Adam G-H requested to merge issue/drupal_cms-3493477:3493477-no-dependencies into 1.x
+ 34
51
@@ -3,6 +3,7 @@ variables:
# @see https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.main.yml?ref_type=heads
KUBERNETES_CPU_REQUEST: 2
CI_DEBUG_SERVICES: 'true'
COMPOSER_MIRROR_PATH_REPOS: 1
# For faster performance, don't audit dependencies automatically. We have
# a dedicated job for this.
COMPOSER_NO_AUDIT: 1
@@ -99,40 +100,32 @@ default:
- DIR: recipes/drupal_cms_starter
URL: 'git@git.drupal.org:project/drupal_cms_starter.git'
# Creates a Composer-managed Drupal CMS code base that doesn't include any
# dev dependencies.
.build:
variables:
COMPOSER_MIRROR_PATH_REPOS: 1
script:
# Add all components as globally available path repositories, simulating Packagist.
- 'sed "s|\"url\": \"|\"url\": \"$CI_PROJECT_DIR/|g" components.composer.json > $(composer config --global home)/config.json'
# Create the project from the local `project_template` directory.
- composer create-project drupal/cms $BUILD_DIR --stability=dev --repository='{"type":"path","url":"project_template"}'
artifacts:
paths:
- $BUILD_DIR
expire_in: 1 hour
rules:
- when: on_success
.create-project: &create-project
# Add all components as globally available path repositories, simulating Packagist.
- 'sed "s|\"url\": \"|\"url\": \"$CI_PROJECT_DIR/|g" components.composer.json > $(composer config --global home)/config.json'
- composer create-project drupal/cms --stability=dev --no-install --repository='{"type":"path","url":"project_template"}' $BUILD_DIR
# Creates a Drupal CMS code base with dev dependencies installed.
install dev dependencies:
extends: .build
build test project:
stage: test
before_script:
- apt-get update
- apt-get install -y jq
script:
- !reference [.build, script]
# Regenerate `composer.json`, merging our dev requirements into it.
- *create-project
# Regenerate `composer.json`, merging our dev requirements into it, and install dependencies.
- cd $BUILD_DIR
- mv composer.json base.composer.json
- jq -s '.[0] * .[1]' base.composer.json $CI_PROJECT_DIR/dev.composer.json > composer.json
# Add dev dependencies to the built project.
- composer update drupal/core-dev --with-all-dependencies
- composer install
# Apply any patches, if necessary.
- if [[ -f patches.lock.json ]]; then composer patches-repatch; fi
artifacts:
paths:
- $BUILD_DIR
expire_in: 1 hour
rules:
- when: on_success
.start-apache: &start-apache
- ln -s -f $_PROJECT_ROOT/$_WEB_ROOT /var/www/html/$_WEB_ROOT
@@ -142,7 +135,7 @@ install dev dependencies:
.test-base:
stage: test
needs:
- 'install dev dependencies'
- 'build test project'
services:
- name: 'drupalci/mysql-8'
alias: database
@@ -190,7 +183,7 @@ run end-to-end tests:
audit dependencies:
stage: test
needs:
- 'install dev dependencies'
- 'build test project'
script:
- composer audit --working-dir=$BUILD_DIR
rules:
@@ -208,44 +201,34 @@ check spelling:
- docs/**/*.md
script: npx cspell --show-suggestions --show-context --no-progress docs
export config:
# Pre-parses all of the recipes available to the installer and stores them in
# a serialized file format.
prime installer cache:
stage: deploy
needs:
- 'install dev dependencies'
- 'build test project'
script:
- cd $BUILD_DIR
- vendor/bin/drush site:install --yes --db-url=sqlite://localhost/db.sqlite
# Apply the add-on recipes suggested by the starter.
- for name in $(composer suggest --list --working-dir=recipes/drupal_cms_starter); do vendor/bin/drush recipe $CI_PROJECT_DIR/recipes/$(basename $name) --input=drupal_cms_analytics.property_id=GTM-123456; done
- vendor/bin/drush config:export --yes --destination=$CI_PROJECT_DIR/config
- cd $_WEB_ROOT && PATH="$PWD/vendor/bin:$PATH" ./profiles/drupal_cms_installer/build-cache.sh
- mv ./profiles/drupal_cms_installer/cache $CI_PROJECT_DIR/installer_cache
artifacts:
paths:
- config
expire_in: 1 hour
- installer_cache
expire_in: 30 minutes
rules:
- when: on_success
- *deploy-rules
# Use the more accurate name once we've solved https://drupal.org/i/3493555.
# Generates a ZIP file that can be downloaded by the public to spin
# up projects with Drupal CMS.
# @todo Use the more accurate name once we've solved https://drupal.org/i/3493555.
build project: # generate zip file:
extends: .build
stage: deploy
# This is a clean build, so don't download artifacts from previous stages.
# @see https://docs.gitlab.com/ee/ci/jobs/job_artifacts.html#prevent-a-job-from-fetching-artifacts
dependencies: []
before_script:
- apt-get update
- apt-get install zip
needs:
- 'prime installer cache'
script:
- !reference [.build, script]
# Delete all `.git` directories.
- cd $BUILD_DIR
- find . -depth -type d -name '.git' -exec rm -r -f {} ';'
# Speed up the installer by pre-parsing all of the recipes available in the installer
# and storing them in a serialized file format.
- cd $_WEB_ROOT && PATH="$PWD/vendor/bin:$PATH" ./profiles/drupal_cms_installer/build-cache.sh
# Turn the built project into an archive that can be downloaded by the public
# to spin up projects with Drupal CMS.
- cd $CI_PROJECT_DIR && zip --quiet --recurse-paths drupal-cms $BUILD_DIR
- *create-project
- mv installer_cache $BUILD_DIR/$_WEB_ROOT/profiles/drupal_cms_installer/cache
- composer archive --format=zip --file=drupal-cms --dir=$CI_PROJECT_DIR --working-dir=$BUILD_DIR
artifacts:
paths:
- drupal-cms.zip
Loading