Skip to content
Snippets Groups Projects
Commit ee1286b9 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3394413 by phenaproxima, tedbow: Enable GitLab CI, and use it to build...

Issue #3394413 by phenaproxima, tedbow: Enable GitLab CI, and use it to build out a core code base with Automatic Updates and Package Manager as core modules
parent 80514f0d
No related branches found
No related tags found
No related merge requests found
################
# DrupalCI GitLabCI template
#
# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
#
# With thanks to:
# * The GitLab Acceleration Initiative participants
# * DrupalSpoons
################
################
# Guidelines
#
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
#
# However, you can modify this template if you have additional needs for your project.
################
################
# Includes
#
# Additional configuration can be provided through includes.
# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
#
# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml
# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values
################
include:
################
# DrupalCI includes:
# As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically.
# View these include files at https://git.drupalcode.org/project/gitlab_templates/
################
- project: $_GITLAB_TEMPLATES_REPO
ref: $_GITLAB_TEMPLATES_REF
file:
- '/includes/include.drupalci.main.yml'
# EXPERIMENTAL: For Drupal 7, remove the above line and uncomment the below.
# - '/includes/include.drupalci.main-d7.yml'
- '/includes/include.drupalci.variables.yml'
- '/includes/include.drupalci.workflows.yml'
################
# Pipeline configuration variables
#
# These are the variables provided to the Run Pipeline form that a user may want to override.
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################
variables:
SKIP_COMPOSER_LINT: '1'
SKIP_ESLINT: '1'
SKIP_PHPCS: '1'
SKIP_PHPSTAN: '1'
SKIP_PHPUNIT: '1'
SKIP_STYLELINT: '1'
_WEB_ROOT: '.'
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/
# ((((((((((((( *(((((((((((((((((((((((* *((((((((((((
# ((((((((((((( ,(((((((((((((..((((((((((((( *((((((((((((
# ((((((((((((, /((((((((((((* /((((((((((((/ ((((((((((((
# ((((((((((((( /((((((((((((/ (((((((((((((* ((((((((((((
# (((((((((((((/ /(((((((((((( ,((((((((((((, *((((((((((((
# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
###################################################################################
composer:
extends: .composer-base
variables:
COMPOSER_MIRROR_PATH_REPOS: '1'
PATH_REPO: '/tmp/automatic_updates'
script:
- mkdir $PATH_REPO
- mv ./* $PATH_REPO
# Expand the composer.json from the module with defaults to bring the Drupal project.
- curl -OL https://git.drupalcode.org/$_GITLAB_TEMPLATES_REPO/-/raw/$_GITLAB_TEMPLATES_REF/scripts/expand_composer_json.php
- php expand_composer_json.php
- composer config name drupal/automatic_updates-ci
- composer config repo.automatic_updates path $PATH_REPO
- composer require --no-update drupal/automatic_updates
- composer install $COMPOSER_EXTRA
- rm expand_composer_json.php
- composer create-project --no-install drupal/recommended-project:$_TARGET_CORE ./composer/Template/RecommendedProject
- composer create-project --no-install drupal/legacy-project:$_TARGET_CORE ./composer/Template/LegacyProject
- composer run core-convert --working-dir=./modules/contrib/automatic_updates -- $PWD --gitlabci
- test -d ./core/modules/package_manager
- test -d ./core/modules/auto_updates
- rm -r -f ./modules/contrib
...@@ -43,6 +43,8 @@ class ConverterCommand extends Command { ...@@ -43,6 +43,8 @@ class ConverterCommand extends Command {
private bool $skipCoreChecks; private bool $skipCoreChecks;
private bool $gitlabci;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -61,7 +63,7 @@ class ConverterCommand extends Command { ...@@ -61,7 +63,7 @@ class ConverterCommand extends Command {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$this->core_dir = $input->getArgument('core_dir'); $this->core_dir = realpath($input->getArgument('core_dir'));
$this->core_branch = $input->getArgument('core_branch'); $this->core_branch = $input->getArgument('core_branch');
$this->contrib_branch = $input->getArgument('contrib_branch'); $this->contrib_branch = $input->getArgument('contrib_branch');
$this->package_manager_only = $input->getOption('package_manager_only'); $this->package_manager_only = $input->getOption('package_manager_only');
...@@ -112,7 +114,6 @@ class ConverterCommand extends Command { ...@@ -112,7 +114,6 @@ class ConverterCommand extends Command {
// Switch to the core directory and require all of the packages there are in // Switch to the core directory and require all of the packages there are in
// this module's composer.json require section. // this module's composer.json require section.
chdir('core');
$require_section = $this->getContribModuleComposerJsonSection('require'); $require_section = $this->getContribModuleComposerJsonSection('require');
// Hardcode symfony version to 6.4 for core. // Hardcode symfony version to 6.4 for core.
$core_symfony_version_update = function ($package_name, $version): string { $core_symfony_version_update = function ($package_name, $version): string {
...@@ -123,10 +124,8 @@ class ConverterCommand extends Command { ...@@ -123,10 +124,8 @@ class ConverterCommand extends Command {
}; };
foreach ($require_section as $package_name => $version) { foreach ($require_section as $package_name => $version) {
$version = $core_symfony_version_update($package_name, $version); $version = $core_symfony_version_update($package_name, $version);
static::executeCommand("composer require $package_name:$version --no-update"); static::executeCommand("composer require $package_name:$version --no-update --working-dir={$this->core_dir}/core");
} }
// Switch back to the parent directory.
chdir('..');
// Run composer update for just this packages. // Run composer update for just this packages.
static::executeCommand("composer update " . implode(' ', array_keys($require_section))); static::executeCommand("composer update " . implode(' ', array_keys($require_section)));
...@@ -246,16 +245,17 @@ class ConverterCommand extends Command { ...@@ -246,16 +245,17 @@ class ConverterCommand extends Command {
// Run phpcbf because removing code from merge request may result in unused // Run phpcbf because removing code from merge request may result in unused
// use statements or multiple empty lines. // use statements or multiple empty lines.
system("composer phpcbf $package_manager_core_path"); $contrib_dir = self::getContribDir();
system("composer run phpcbf --working-dir=$contrib_dir -- $package_manager_core_path");
if ($this->package_manager_only) { if ($this->package_manager_only) {
$fs->remove($core_module_path); $fs->remove($core_module_path);
} }
else { else {
static::copyGenericTest($core_module_path, $this->core_dir); static::copyGenericTest($core_module_path, $this->core_dir);
system("composer phpcbf $core_module_path"); system("composer run phpcbf --working-dir=$contrib_dir -- $$core_module_path");
} }
static::addWordsToDictionary($this->core_dir, self::getContribDir() . "/dictionary.txt"); static::addWordsToDictionary($this->core_dir, $contrib_dir . "/dictionary.txt");
self::info("Added to dictionary"); self::info("Added to dictionary");
chdir($this->core_dir); chdir($this->core_dir);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment