Skip to content
Snippets Groups Projects
Commit 29b630cb authored by Qiangjun Ran's avatar Qiangjun Ran
Browse files

Issue #3014492 by jungle: Adopt Gitlab CI and fix CS violations detected

parent 0b74931d
Branches 4.0.x
No related tags found
No related merge requests found
Pipeline #83756 failed
################
# DrupalCI GitLabCI template
#
# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
#
# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
#
# This is hestenet's test template
# Source: https://gitlab.com/drupal-infrastructure/gitlab-acceleration/gitlabci/file-templates/-/blob/main/gitlab-ci/template.gitlab-ci.yml
#
# With thanks to:
# With thanks to:
# * The GitLab Acceleration Initiative participants
# * DrupalSpoons
################
......@@ -14,26 +14,26 @@
################
# 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.
# 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.
# 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.
# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
#
# Includes can be overriden 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:
include:
################
# DrupalCI includes:
# include.drupalci.main.yml - This parent include contains nested includes for all DrupalCI test features. As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelies automatically.
# View this file to see what nested includes are provided.
# DrupalCI includes:
# include.drupalci.main.yml - This parent include contains nested includes for all DrupalCI test features. As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelies automatically.
# View this file to see what nested includes are provided.
################
remote: 'https://git.drupalcode.org/project/gitlab_templates/-/raw/1.0.x/includes/include.drupalci.main.yml'
......@@ -41,35 +41,39 @@ include:
# Variables
#
# The include file include.drupalci.main.yml in this template includes a include.drupalci.variables.yml
# - These variables provide 'Semantic Labels' to help you automatically track the current supported and development versions of Drupal, as well as the current min/max system requirements for PHP, database, etc.
# - If this file is updated, your testing configuration will automatically follow these changes.
# - These variables provide 'Semantic Labels' to help you automatically track the current supported and development versions of Drupal, as well as the current min/max system requirements for PHP, database, etc.
# - If this file is updated, your testing configuration will automatically follow these changes.
#
# Overriding variables
# - To override one or more of these variables, simply declare your own variables keyword.
# - Keywords declared directly in .gitlab-ci.yml take precedence over include files.
# - To override one or more of these variables, simply declare your own variables keyword.
# - Keywords declared directly in .gitlab-ci.yml take precedence over include files.
# - Documentation: https://docs.gitlab.com/ee/ci/variables/
# - Predefined variables: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
#
# - Predefined variables: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
#
################
variables:
_TARGET_CORE: "$CORE_MAJOR_DEVELOPMENT"
_TARGET_PHP: "$CORE_PHP_MAX"
################
# Workflow
#
# The include file include.drupalci.main.yml in this template includes a include.drupalci.worfklows.yml
# - This will test on commit, on merge request, and on any scheduled defined in the GitLab UI for your project.
# - If this file is updated, your testing configuration will automatically follow these changes.
# - This will test on commit, on merge request, and on any scheduled defined in the GitLab UI for your project.
# - If this file is updated, your testing configuration will automatically follow these changes.
#
# Overriding workflows
# - To override these workflows, simply declare your own workflow keyword.
# - Keywords declared directly in .gitlab-ci.yml take precedence over include files.
# - Documentation: https://docs.gitlab.com/ee/ci/yaml/workflow.html
# - To override these workflows, simply declare your own workflow keyword.
# - Keywords declared directly in .gitlab-ci.yml take precedence over include files.
# - Documentation: https://docs.gitlab.com/ee/ci/yaml/workflow.html
#
################
################
# Workflow
#
# Set global defaults, including:
# Set global defaults, including:
# - php image
# - interruptible:true, so that new pushes can stop the current job and start a new one
#
......@@ -85,38 +89,38 @@ default:
# Stages
#
# Each job is assigned to a stage, defining the order in which the jobs are executed.
# Jobs in the same stage run in parallel.
# Jobs in the same stage run in parallel.
#
# If all jobs in a stage succeed, the pipeline will proceed to the next stage.
# If any job in the stage fails, the pipeline will exit early.
# If any job in the stage fails, the pipeline will exit early.
################
stages:
stages:
################
# Build
#
# In the Build stage we are assembling our test environment:
# In the Build stage we are assembling our test environment:
# * Selecting the core version to test against
# * Selecting php version
# * Selectig the database, and configuring it
# * Plus any additional build steps, like composer runs, etc
# Wherever possible, we use variables defined in: include.druaplci.variables.yml so that the configuration can stay up to date with current Drupal Core development.
# Wherever possible, we use variables defined in: include.druaplci.variables.yml so that the configuration can stay up to date with current Drupal Core development.
#
# Documentation: https://docs.gitlab.com/ee/ci/yaml/#stages
# Documentation: https://docs.gitlab.com/ee/ci/yaml/#stages
################
- build
- build
################
# Validate
#
# The validate stage includes any codebase validation that we want to perform before running functional tests. These are items we may want to fail-fast on, before doing a full test-run.
# The validate stage includes any codebase validation that we want to perform before running functional tests. These are items we may want to fail-fast on, before doing a full test-run.
################
- validate
################
# Test
#
# The test phase actually executes the functional tests, as well as gathering results and artifacts.
#
# The test phase actually executes the functional tests, as well as gathering results and artifacts.
################
- test
......@@ -124,11 +128,11 @@ stages:
# Jobs
#
# Jobs define what scripts are actually executed in each stage.
#
# The 'rules' keyword can also be used to define conditions for each job.
#
# The 'rules' keyword can also be used to define conditions for each job.
# # @TODO: Use rules to define core version to test against, allow overriding default on manual run with variables. (Perhaps with 'variables in variables')
#
# Documentation: https://docs.gitlab.com/ee/ci/jobs/
# Documentation: https://docs.gitlab.com/ee/ci/jobs/
################
################
......@@ -157,13 +161,13 @@ composer:
artifacts:
expire_in: 1 week
expose_as: 'web-vendor'
paths: # @todo - where we want to store artifacts?
paths: # @todo - where we want to store artifacts?
- vendor/
- $_WEB_ROOT
- .composer-plugin.env
- composer.spoons.json
- composer.spoons.lock\
script: #this script is configuring composer, including options for local Dev - can we simplify?
script: #this script is configuring composer, including options for local Dev - can we simplify?
- export
- bash <(curl -s $_COMPOSER_SETUP)
......@@ -171,16 +175,16 @@ composer:
# Validate Jobs
################
composer-lint:
stage: validate
composer-lint:
stage: validate
script:
- composer validate
- composer lint
phpcs:
phpcs:
stage: validate
script:
# Do we need: vendor/drupalspoons/composer-plugin/templates/phpcs.xml.dist ?
script:
# Do we need: vendor/drupalspoons/composer-plugin/templates/phpcs.xml.dist ?
#- cp -u vendor/drupalspoons/composer-plugin/templates/phpcs.xml.dist $_WEB_ROOT/modules/custom
- composer phpcs -- --report-junit=junit.xml --report-full --report-summary
allow_failure: true
......@@ -192,7 +196,7 @@ phpcs:
reports:
junit: junit.xml
stylelint:
stylelint:
stage: validate
script:
# Installs all core javascript dependencies.
......@@ -226,13 +230,14 @@ eslint:
################
# Test Jobs
################
# @TODO: Multiple environment handling
# Do we want to offer a default example of matrix testing, perhaps commented out? Or linked to in documentation?
# Or do we want to stick to single environment for cost control, and rely on advanced maintainers to figure it out?
# @TODO: Multiple environment handling
# Do we want to offer a default example of matrix testing, perhaps commented out? Or linked to in documentation?
# Or do we want to stick to single environment for cost control, and rely on advanced maintainers to figure it out?
################
phpunit:
phpunit:
stage: test
allow_failure: true
variables:
# https://docs.gitlab.com/runner/configuration/feature-flags.html#available-feature-flags
FF_NETWORK_PER_BUILD: 1
......@@ -249,7 +254,7 @@ phpunit:
POSTGRES_PASSWORD: drupaltestbotpw
services:
- name: $_CONFIG_DOCKERHUB_ROOT/$_TARGET_DB_TYPE-$_TARGET_DB_VERSION:production
- name: $_CONFIG_DOCKERHUB_ROOT/$_TARGET_DB_TYPE-$_TARGET_DB_VERSION:production
alias: database
- name: $_CONFIG_DOCKERHUB_ROOT/chromedriver:production
alias: chrome
......@@ -285,28 +290,28 @@ phpunit:
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/
# ((((((((((((( *(((((((((((((((((((((((* *((((((((((((
# ((((((((((((( ,(((((((((((((..((((((((((((( *((((((((((((
......@@ -314,17 +319,17 @@ phpunit:
# ((((((((((((( /((((((((((((/ (((((((((((((* ((((((((((((
# (((((((((((((/ /(((((((((((( ,((((((((((((, *((((((((((((
# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
###################################################################################
......@@ -64,8 +64,8 @@ class ColorBackgroudFormatter extends FormatterBase {
// settingsForm(), and the schema defined in
// config/schema/field_example.schema.yml.
return [
'adjust_text_color' => TRUE,
] + parent::defaultSettings();
'adjust_text_color' => TRUE,
] + parent::defaultSettings();
}
/**
......@@ -129,9 +129,9 @@ class ColorBackgroudFormatter extends FormatterBase {
protected function lightness(string $color) {
$hex = ltrim($color, '#');
// Convert the hex string to RGB.
$r = hexdec($hex[0].$hex[1]);
$g = hexdec($hex[2].$hex[3]);
$b = hexdec($hex[4].$hex[5]);
$r = hexdec($hex[0] . $hex[1]);
$g = hexdec($hex[2] . $hex[3]);
$b = hexdec($hex[4] . $hex[5]);
// Calculate the HSL lightness value and return that as a percent.
return ((max($r, $g, $b) + min($r, $g, $b)) / 510.0) * 100;
......
......@@ -54,8 +54,8 @@ class ColorBackgroundFormatterTest extends FieldExampleBrowserTestBase {
// Test the formatter's configuration options. First verify the foreground
// color calculation logic is enabled by default and working.
$assert->elementAttributeNotContains('css', 'p[style*="background-color: '. $color . '"]', 'style', 'color: inherit');
$assert->elementAttributeContains('css', 'p[style*="background-color: '. $color . '"]', 'style', 'color: black');
$assert->elementAttributeNotContains('css', 'p[style*="background-color: ' . $color . '"]', 'style', 'color: inherit');
$assert->elementAttributeContains('css', 'p[style*="background-color: ' . $color . '"]', 'style', 'color: black');
// Then toggle the setting off.
\Drupal::service('entity_display.repository')
......@@ -71,12 +71,12 @@ class ColorBackgroundFormatterTest extends FieldExampleBrowserTestBase {
->save();
// Clear the cache to ensure we get updated field output.
//drupal_flush_all_caches();
// drupal_flush_all_caches();
$this->getSession()->reload();
$assert = $this->assertSession();
$assert->elementAttributeContains('css', 'p[style*="background-color: '. $color . '"]', 'style', 'color: inherit');
$assert->elementAttributeNotContains('css', 'p[style*="background-color: '. $color . '"]', 'style', 'color: black');
$assert->elementAttributeContains('css', 'p[style*="background-color: ' . $color . '"]', 'style', 'color: inherit');
$assert->elementAttributeNotContains('css', 'p[style*="background-color: ' . $color . '"]', 'style', 'color: black');
}
/**
......
......@@ -6,7 +6,7 @@ use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\examples\Functional\ExamplesBrowserTestBase;
/**
* Class FieldExampleBrowserTestBase.
* The Base Class for field example browser testing.
*
* @group field_example
* @group examples
......
......@@ -2,8 +2,6 @@
namespace Drupal\Tests\field_example\Functional;
use Drupal\Component\Render\FormattableMarkup;
/**
* Functional tests of the 3text widget.
*
......
......@@ -2,8 +2,6 @@
namespace Drupal\Tests\field_example\Functional;
use Drupal\Component\Render\FormattableMarkup;
/**
* Test basic functionality of the widgets.
*
......
......@@ -167,7 +167,7 @@ class FileExampleReadWriteForm extends FormBase {
$form['debug']['reset_session'] = [
'#type' => 'submit',
'#value' => $this->t('Reset the Session'),
'#submit' => [[$this->submitHandlerHelper,'handleResetSession']],
'#submit' => [[$this->submitHandlerHelper, 'handleResetSession']],
];
return $form;
......@@ -186,7 +186,7 @@ class FileExampleReadWriteForm extends FormBase {
$filename = $this->fileSystem->basename($destination);
if (!$filename) {
$form_state->setError($form['write_file']['destination'], $this->t('The destination %destination is not valid.', array('%destination' => $destination)));
$form_state->setError($form['write_file']['destination'], $this->t('The destination %destination is not valid.', ['%destination' => $destination]));
return;
}
......
......@@ -6,7 +6,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
/**
*
* Controller for theming example routes.
*/
class ThemingPageController {
......
......@@ -7,6 +7,7 @@
<ruleset name="drupal_examples">
<description>Default PHP CodeSniffer configuration for Drupal core.</description>
<file>.</file>
<exclude-pattern>./modules/js_example/js/accordion.js</exclude-pattern>
<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
<!-- Drupal sniffs -->
<rule ref="Drupal.Arrays.Array">
......@@ -124,7 +125,6 @@
<rule ref="Drupal.WhiteSpace.ObjectOperatorSpacing"/>
<rule ref="Drupal.WhiteSpace.OpenBracketSpacing"/>
<rule ref="Drupal.WhiteSpace.OpenTagNewline"/>
<rule ref="Drupal.WhiteSpace.OperatorSpacing"/>
<rule ref="Drupal.WhiteSpace.ScopeClosingBrace"/>
<rule ref="Drupal.WhiteSpace.ScopeIndent"/>
......
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