Skip to content

Commit

Permalink
Drupal 7.101 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
shelane authored Sep 14, 2024
1 parent 9ac4af9 commit 9eb3e23
Show file tree
Hide file tree
Showing 225 changed files with 2,977 additions and 582 deletions.
224 changes: 224 additions & 0 deletions docroot/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
################
# Drupal GitLabCI template
#
# Based off GitlabCI templates project: https://git.drupalcode.org/project/gitlab_templates
# Guide: https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-drupal/gitlab-ci
#
# With thanks to:
# - The GitLab Acceleration Initiative participants
# - DrupalSpoons
################

################
# Workflow
#
# Define conditions for when the pipeline will run.
# For example:
# * On commit
# * On merge request
# * On manual trigger
# * etc.
# https://docs.gitlab.com/ee/ci/jobs/job_control.html#specify-when-jobs-run-with-rules
#
# Pipelines can also be configured to run on a schedule,though they still must meet the conditions defined in Workflow and Rules. This can be used, for example, to do nightly regression testing:
# https://gitlab.com/help/ci/pipelines/schedules
################

workflow:
rules:
# These 3 rules from https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Workflows/MergeRequest-Pipelines.gitlab-ci.yml
# Run on merge requests
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Run when called from an upstream pipeline https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html?tab=Multi-project+pipeline#use-rules-to-control-downstream-pipeline-jobs
- if: $CI_PIPELINE_SOURCE == 'pipeline'
# Run on commits.
- if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project"
# The last rule above blocks manual and scheduled pipelines on non-default branch. The rule below allows them:
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_ROOT_NAMESPACE == "project"
# Run if triggered from Web using 'Run Pipelines'
- if: $CI_PIPELINE_SOURCE == "web"
# Run if triggered from WebIDE
- if: $CI_PIPELINE_SOURCE == "webide"

################
# 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
#
################

variables:
_CONFIG_DOCKERHUB_ROOT: "drupalci"
_TARGET_PHP: "8.1"
CONCURRENCY: 15
GIT_DEPTH: "3"
COMPOSER_ALLOW_SUPERUSER: 1

################
# 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:
################
# Code quality checks
#
# This stage includes any codebase validation that we want to perform
# before running functional tests.
################
- 🪄 Lint

################
# Test
#
# The test phase actually executes the tests, as well as gathering results
# and artifacts.
################
- 🗜️ Test

#############
# Templates #
#############

.run-on-mr: &run-on-mr
if: $CI_PIPELINE_SOURCE == "merge_request_event"

.run-on-mr-manual: &run-on-mr-manual
if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: true

.run-on-commit: &run-on-commit
if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project"

.run-daily: &run-daily
if: $CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_ROOT_NAMESPACE == "project"

.default-stage: &default-stage
stage: 🗜️ Test
trigger:
# Rely on the status of the child pipeline.
strategy: depend
include:
- local: .gitlab-ci/pipeline.yml
rules:
- <<: *run-on-commit
- <<: *run-on-mr-manual

################
# Jobs
#
# Jobs define what scripts are actually executed in each stage.
################

'🧹 PHP Compatibility checks (PHPCS)':
stage: 🪄 Lint
variables:
PHPCS_PHP_VERSION: "5.6"
KUBERNETES_CPU_REQUEST: "16"
interruptible: true
allow_failure: true
retry:
max: 2
when:
- unknown_failure
- api_failure
- stuck_or_timeout_failure
- runner_system_failure
- scheduler_failure
image:
name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
artifacts:
expire_in: 6 mos
paths:
- phpcs-quality-report.json
reports:
codequality: phpcs-quality-report.json
rules:
- <<: *run-on-mr
before_script:
- echo "{}" > composer.json
- composer config allow-plugins true -n
- composer require --dev drupal/coder:^8.2@stable micheh/phpcs-gitlab phpcompatibility/php-compatibility dealerdirect/phpcodesniffer-composer-installer
- export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}
script:
- git fetch -vn --depth=$GIT_DEPTH origin "+refs/heads/$TARGET_BRANCH:refs/heads/$TARGET_BRANCH"
- export MODIFIED=`git diff --name-only refs/heads/$TARGET_BRANCH|while read r;do echo "$CI_PROJECT_DIR/$r";done|tr "\n" " "`
- echo -e "$MODIFIED" | tr " " "\n"
- echo "If this list contains more files than what you changed, then you need to rebase your branch."
- vendor/bin/phpcs --basepath=$CI_PROJECT_DIR --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json --report-full --report-summary --standard=PHPCompatibility --runtime-set testVersion $PHPCS_PHP_VERSION --extensions=php,module,inc,install,test,profile,theme $MODIFIED

# Default job.
'PHP 8.1 MySQL 5.7':
<<: *default-stage
variables:
_TARGET_PHP: "8.1"
_TARGET_DB: "mysql-5.7"
rules:
- <<: *run-on-commit
- <<: *run-on-mr

'PHP 5.6 MySQL 5.5':
<<: *default-stage
variables:
_TARGET_PHP: "5.6"
_TARGET_DB: "mysql-5.5"

'PHP 7.2 MySQL 5.7':
<<: *default-stage
variables:
_TARGET_PHP: "7.2"
_TARGET_DB: "mysql-5.7"

'PHP 7.4 MySQL 5.7':
<<: *default-stage
variables:
_TARGET_PHP: "7.4"
_TARGET_DB: "mysql-5.7"

'PHP 8.0 MySQL 5.7':
<<: *default-stage
variables:
_TARGET_PHP: "8.0"
_TARGET_DB: "mysql-5.7"

'PHP 8.2 MySQL 8':
<<: *default-stage
variables:
_TARGET_PHP: "8.2"
_TARGET_DB: "mysql-8"

'PHP 7.4 PostgreSQL 9.5':
<<: *default-stage
variables:
_TARGET_PHP: "7.4"
_TARGET_DB: "pgsql-9.5"

'PHP 8.1 PostgreSQL 14.1':
<<: *default-stage
variables:
_TARGET_PHP: "8.1"
_TARGET_DB: "pgsql-14.1"

'PHP 7.4 SQLite 3.27.0':
<<: *default-stage
variables:
_TARGET_PHP: "7.4"
_TARGET_DB: "sqlite-3"

'PHP 8.1 MariaDB 10.3.22':
<<: *default-stage
variables:
_TARGET_PHP: "8.1"
_TARGET_DB: "mariadb-10.3.22"
4 changes: 4 additions & 0 deletions docroot/.gitlab-ci/.htaccess-parent
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Redirect everything via the subdirectory.

RewriteEngine on
RewriteRule (.*) subdirectory/$1 [L]
160 changes: 160 additions & 0 deletions docroot/.gitlab-ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
stages:
################
# Test
#
# The test phase actually executes the tests, as well as gathering results
# and artifacts.
################
- 🗜️ Test

#############
# Templates #
#############

.default-job-settings: &default-job-settings
interruptible: true
allow_failure: false
retry:
max: 2
when:
- unknown_failure
- api_failure
- stuck_or_timeout_failure
- runner_system_failure
- scheduler_failure
image:
name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline"

.test-variables: &test-variables
FF_NETWORK_PER_BUILD: 1
SIMPLETEST_BASE_URL: http://localhost/subdirectory
DB_DRIVER: mysql
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: drupal
MYSQL_USER: drupaltestbot
MYSQL_PASSWORD: drupaltestbotpw
POSTGRES_DB: drupaltestbot
POSTGRES_USER: drupaltestbot
POSTGRES_PASSWORD: drupaltestbotpw
CI_PARALLEL_NODE_INDEX: $CI_NODE_INDEX
CI_PARALLEL_NODE_TOTAL: $CI_NODE_TOTAL

.with-database: &with-database
name: $_CONFIG_DOCKERHUB_ROOT/$_TARGET_DB:production
alias: database

.with-chrome: &with-chrome
name: $_CONFIG_DOCKERHUB_ROOT/chromedriver:production
alias: chrome
entrypoint:
- chromedriver
- "--no-sandbox"
- "--log-path=/tmp/chromedriver.log"
- "--verbose"
- "--whitelisted-ips="

.phpunit-artifacts: &phpunit-artifacts
artifacts:
when: always
expire_in: 6 mos
reports:
junit: ./sites/default/files/simpletest/*.xml
paths:
- ./sites/default/files/simpletest

.setup-webroot: &setup-webserver
before_script:
- ln -s $CI_PROJECT_DIR /var/www/html/subdirectory
- cp $CI_PROJECT_DIR/.gitlab-ci/.htaccess-parent /var/www/html/.htaccess
- sudo service apache2 start

.get-simpletest-db: &get-simpletest-db
- |
# Assume SQLite unless we have another known target.
export SIMPLETEST_DB=sqlite://localhost/$CI_PROJECT_DIR/sites/default/files/db.sqlite
[[ $_TARGET_DB == mysql* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE
[[ $_TARGET_DB == mariadb* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE
[[ $_TARGET_DB == pgsql* ]] && export SIMPLETEST_DB=pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@database/$POSTGRES_DB
- echo "SIMPLETEST_DB = $SIMPLETEST_DB"

.prepare-dirs: &prepare-dirs
- mkdir -p ./sites/default/files ./sites/default/files/simpletest ./build/logs/junit
- chown -R www-data:www-data ./sites ./build/logs/junit /var/www/
- sudo -u www-data git config --global --add safe.directory $CI_PROJECT_DIR

.install-drupal: &install-drupal
- sudo -u www-data /usr/local/bin/drush si -y --db-url=$SIMPLETEST_DB --clean-url=0 --account-name=admin --account-pass=drupal [email protected]
- sudo -u www-data /usr/local/bin/drush vset simpletest_clear_results '0'
- sudo -u www-data /usr/local/bin/drush vset simpletest_verbose '1'
- sudo -u www-data /usr/local/bin/drush en -y simpletest

.run-tests: &run-tests
script:
- *get-simpletest-db
- *prepare-dirs
- *install-drupal
# We need to pass this along directly even though it's set in the environment parameters.
- sudo -u www-data php ./scripts/run-tests.sh --color --concurrency "$CONCURRENCY" --url "$SIMPLETEST_BASE_URL" --verbose --fail-only --all --xml "$CI_PROJECT_DIR/sites/default/files/simpletest" --ci-parallel-node-index $CI_PARALLEL_NODE_INDEX --ci-parallel-node-total $CI_PARALLEL_NODE_TOTAL

.run-test-only-tests: &run-test-only-tests
script:
- *get-simpletest-db
- *prepare-dirs
- *install-drupal
- export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}
- git fetch -vn --depth=50 origin "+refs/heads/$TARGET_BRANCH:refs/heads/$TARGET_BRANCH"
- |
echo "ℹ️ Changes from ${TARGET_BRANCH}"
git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only
echo "1️⃣ Reverting non test changes"
if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=DM --name-only|grep -Ev '.test$'|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=DM --name-only|grep -Ev '.test$'|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
echo "↩️ Reverting $file"
git checkout refs/heads/${TARGET_BRANCH} -- $file;
done
fi
echo "2️⃣ Deleting new files"
if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=A --name-only|grep -Ev '.test$'|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=A --name-only|grep -Ev '.test$'|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
echo "🗑️️ Deleting $file"
git rm $file
done
fi
echo "3️⃣ Running test changes for this branch"
if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only|grep -E '.test$') ]]; then
git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only|grep -E ".test$"|while read file;do
sudo -u www-data php ./scripts/run-tests.sh --color --concurrency "$CONCURRENCY" --url "$SIMPLETEST_BASE_URL" --verbose --fail-only --xml "$CI_PROJECT_DIR/sites/default/files/simpletest/test-only" --file "$file"
done
fi
################
# Jobs
#
# Jobs define what scripts are actually executed in each stage.
################

'⚡️ PHPUnit Unit':
<<: [ *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ]
stage: 🗜️ Test
parallel: 3
services:
- <<: *with-database
- <<: *with-chrome
variables:
<<: *test-variables
CONCURRENCY: "$CONCURRENCY"
KUBERNETES_CPU_REQUEST: "16"

'🩹 Test-only changes':
<<: [ *phpunit-artifacts, *setup-webserver, *run-test-only-tests, *default-job-settings ]
stage: 🗜️ Test
when: manual
interruptible: true
allow_failure: true
variables:
<<: *test-variables
services:
- <<: *with-database
- <<: *with-chrome
Loading

0 comments on commit 9eb3e23

Please sign in to comment.