diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..6aa41259bf21e11ddfc2c14ce4055cef24dd6a74 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,128 @@ +################ +# 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 diff --git a/scripts/src/ConverterCommand.php b/scripts/src/ConverterCommand.php index de11db8a635564e914c6559f7e025e558900bfd8..900d7f0e627d1e6a6a0fdf11deb32eb03c7347e4 100644 --- a/scripts/src/ConverterCommand.php +++ b/scripts/src/ConverterCommand.php @@ -43,6 +43,8 @@ class ConverterCommand extends Command { private bool $skipCoreChecks; + private bool $gitlabci; + /** * {@inheritdoc} */ @@ -61,7 +63,7 @@ class ConverterCommand extends Command { * {@inheritdoc} */ 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->contrib_branch = $input->getArgument('contrib_branch'); $this->package_manager_only = $input->getOption('package_manager_only'); @@ -112,7 +114,6 @@ class ConverterCommand extends Command { // Switch to the core directory and require all of the packages there are in // this module's composer.json require section. - chdir('core'); $require_section = $this->getContribModuleComposerJsonSection('require'); // Hardcode symfony version to 6.4 for core. $core_symfony_version_update = function ($package_name, $version): string { @@ -123,10 +124,8 @@ class ConverterCommand extends Command { }; foreach ($require_section as $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. static::executeCommand("composer update " . implode(' ', array_keys($require_section))); @@ -246,16 +245,17 @@ class ConverterCommand extends Command { // Run phpcbf because removing code from merge request may result in unused // 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) { $fs->remove($core_module_path); } else { 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"); chdir($this->core_dir);