Skip to content
Snippets Groups Projects
Commit d4af2e55 authored by Jose Luis Bellido Rojas's avatar Jose Luis Bellido Rojas Committed by Valery Lourie
Browse files

#3417410: Just replace current .gitlab-ci with the proposed .gitlab-ci.yml template.

parent 29b630cb
Branches 4.0.x
No related tags found
No related merge requests found
......@@ -3,9 +3,6 @@
#
# 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:
# * The GitLab Acceleration Initiative participants
# * DrupalSpoons
......@@ -25,268 +22,47 @@
# 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 overriden by re-declaring anything provided in an include, here in gitlab-ci.yml
# 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:
# 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.
# 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/
################
remote: 'https://git.drupalcode.org/project/gitlab_templates/-/raw/1.0.x/includes/include.drupalci.main.yml'
- project: $_GITLAB_TEMPLATES_REPO
# "ref" value can be:
# - Recommended (default) - `ref: $_GITLAB_TEMPLATES_REF` - The Drupal Association will update this value to the recommended tag for contrib.
# - Latest - `ref: main` - Get the latest additions and bug fixes as they are merged into the templates.
# - Minor or Major latests - `ref: 1.x-latest` or `ref: 1.0.x-latest` - Get the latest additions within a minor (mostly bugfixes) or major (bugs and new features).
# - Fixed tag - `ref: 1.0.1` - Set the value to a known tag. This will not get any updates.
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'
################
# 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.
# Pipeline configuration variables
#
# 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.
# - Documentation: https://docs.gitlab.com/ee/ci/variables/
# - Predefined variables: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
# 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:
_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.
#
# 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
#
################
################
# Workflow
#
# Set global defaults, including:
# - php image
# - interruptible:true, so that new pushes can stop the current job and start a new one
#
################
default:
interruptible: true
image:
name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
################
# 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.
#
# 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.
################
stages:
################
# Build
#
# 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.
#
# Documentation: https://docs.gitlab.com/ee/ci/yaml/#stages
################
- 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.
################
- validate
################
# Test
#
# The test phase actually executes the functional tests, as well as gathering results and artifacts.
################
- test
################
# Jobs
#
# Jobs define what scripts are actually executed in each stage.
#
# 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/
################
################
# Build Jobs
################
variable-checks: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "Checking variables"
- echo $_TARGET_CORE
- echo $_TARGET_PHP
- echo $_TARGET_DB_TYPE
- echo $_TARGET_DB_VERSION
- echo $_WEB_ROOT
- echo $_COMPOSER_JSON
# @TODO - work in progress to adapt the composer build step from DrupalSpoons examples
composer:
stage: build
variables:
# Used the bin/setup script.
NONINTERACTIVE: 1
# Use artifacts to copy codebase to subsequent jobs.
# See https://lorisleiva.com/laravel-deployment-using-gitlab-pipelines/.
artifacts:
expire_in: 1 week
expose_as: 'web-vendor'
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?
- export
- bash <(curl -s $_COMPOSER_SETUP)
################
# Validate Jobs
################
composer-lint:
stage: validate
script:
- composer validate
- composer lint
phpcs:
stage: validate
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
artifacts:
expose_as: junit
expire_in: 6 mos
paths:
- junit.xml
reports:
junit: junit.xml
stylelint:
stage: validate
script:
# Installs all core javascript dependencies.
- yarn --cwd $_WEB_ROOT/core add stylelint-junit-formatter
- composer stylelint -- --color || true
- composer stylelint -- --color --custom-formatter node_modules/stylelint-junit-formatter > junit.xml || true
allow_failure: true
artifacts:
expose_as: junit
expire_in: 6 mos
paths:
- junit.xml
reports:
junit: junit.xml
eslint:
stage: validate
script:
# Installs all core javascript dependencies.
- yarn --cwd $_WEB_ROOT/core add stylelint-junit-formatter
- composer eslint -- --format junit --output-file junit.xml || true
allow_failure: true
artifacts:
expose_as: junit
expire_in: 6 mos
paths:
- junit.xml
reports:
junit: junit.xml
_PHPUNIT_CONCURRENT: "1"
################
# 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?
# We just customize some configuration for each of them but rely on the defaults defined at /includes/include.drupalci.main.yml
################
phpunit:
stage: test
allow_failure: true
variables:
# https://docs.gitlab.com/runner/configuration/feature-flags.html#available-feature-flags
FF_NETWORK_PER_BUILD: 1
SIMPLETEST_BASE_URL: http://localhost:8888
DB_DRIVER: mysql
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: mysql
MYSQL_USER: drupaltestbot
MYSQL_PASSWORD: drupaltestbotpw
MARIADB_TAG: $_TARGET_DB_VERSION
POSTGRES_TAG: $_TARGET_DB_VERSION
POSTGRES_DB: pgsql
POSTGRES_USER: drupaltestbot
POSTGRES_PASSWORD: drupaltestbotpw
services:
- name: $_CONFIG_DOCKERHUB_ROOT/$_TARGET_DB_TYPE-$_TARGET_DB_VERSION:production
alias: database
- name: $_CONFIG_DOCKERHUB_ROOT/chromedriver:production
alias: chrome
entrypoint:
- chromedriver
- "--no-sandbox"
- "--log-path=/tmp/chromedriver.log"
- "--verbose"
- "--whitelisted-ips="
script:
# Determine DB driver.
- |
[[ $_TARGET_DB_TYPE == "sqlite" ]] && export SIMPLETEST_DB=sqlite://localhost/sites/default/files/.sqlite
[[ $_TARGET_DB_TYPE == "mysql" ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE
[[ $_TARGET_DB_TYPE == "pgsql" ]] && export SIMPLETEST_DB=pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@database/$POSTGRES_DB
- export
- mkdir $_WEB_ROOT/sites/simpletest
- composer webserver >> webserver.log 2>&1 &
# Provide some context on the test run.
- vendor/bin/drush status
# Finally, execute tests.
- composer unit -- --log-junit junit.xml
artifacts:
expire_in: 6 mos
expose_as: 'junit-browser_output-webserver_log'
reports:
junit: junit.xml
paths:
- junit.xml
- webserver.log
- $_WEB_ROOT/sites/simpletest/browser_output
###################################################################################
#
......
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