Skip to content
Snippets Groups Projects
Commit d170fb04 authored by catch's avatar catch
Browse files

Issue #3391681 by longwave: Use default section to simplify GitLab pipelines

parent 99040d47
No related branches found
No related tags found
No related merge requests found
...@@ -48,10 +48,7 @@ variables: ...@@ -48,10 +48,7 @@ variables:
CONCURRENCY: 24 CONCURRENCY: 24
GIT_DEPTH: "3" GIT_DEPTH: "3"
PARENT_PIPELINE_ID: $CI_PIPELINE_ID PARENT_PIPELINE_ID: $CI_PIPELINE_ID
_TARGET_PHP: "8.2"
.default-lint-variables: &default-lint-variables
_TARGET_PHP: "8.2"
_TARGET_DB: "sqlite-3"
############# #############
# Stages # # Stages #
...@@ -62,12 +59,11 @@ stages: ...@@ -62,12 +59,11 @@ stages:
- 🗜️ Test - 🗜️ Test
############# #############
# Templates # # Defaults #
############# #############
.default-job-settings: &default-job-settings default:
interruptible: true interruptible: true
allow_failure: false
retry: retry:
max: 2 max: 2
when: when:
...@@ -79,6 +75,10 @@ stages: ...@@ -79,6 +75,10 @@ stages:
image: image:
name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
#############
# Templates #
#############
.with-composer: &with-composer .with-composer: &with-composer
needs: needs:
- '📦️ Composer' - '📦️ Composer'
...@@ -88,19 +88,9 @@ stages: ...@@ -88,19 +88,9 @@ stages:
- '📦️ Yarn' - '📦️ Yarn'
.default-job-settings-lint: &default-job-settings-lint .default-job-settings-lint: &default-job-settings-lint
<<: [*default-job-settings]
rules: rules:
- if: $PERFORMANCE_TEST != "1" - if: $PERFORMANCE_TEST != "1"
.junit-artifacts: &junit-artifacts
artifacts:
expose_as: junit
expire_in: 6 mos
paths:
- junit.xml
reports:
junit: junit.xml
################ ################
# Stages # Stages
...@@ -227,9 +217,7 @@ stages: ...@@ -227,9 +217,7 @@ stages:
################ ################
'📦️ Composer': '📦️ Composer':
<<: *default-job-settings
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "1" KUBERNETES_CPU_REQUEST: "1"
stage: 🏗️ Build stage: 🏗️ Build
cache: cache:
...@@ -249,9 +237,7 @@ stages: ...@@ -249,9 +237,7 @@ stages:
- composer install - composer install
'📦️ Yarn': '📦️ Yarn':
<<: *default-job-settings
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "2" KUBERNETES_CPU_REQUEST: "2"
stage: 🏗️ Build stage: 🏗️ Build
cache: cache:
...@@ -274,10 +260,9 @@ stages: ...@@ -274,10 +260,9 @@ stages:
################ ################
'🧹 PHP Static Analysis (phpstan)': '🧹 PHP Static Analysis (phpstan)':
<<: [ *with-composer, *junit-artifacts, *default-job-settings-lint ] <<: [ *with-composer, *default-job-settings-lint ]
stage: 🪄 Lint stage: 🪄 Lint
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "16" KUBERNETES_CPU_REQUEST: "16"
script: script:
- php vendor/bin/phpstan analyze --configuration=./core/phpstan.neon.dist --error-format=gitlab > phpstan-quality-report.json - php vendor/bin/phpstan analyze --configuration=./core/phpstan.neon.dist --error-format=gitlab > phpstan-quality-report.json
...@@ -286,10 +271,9 @@ stages: ...@@ -286,10 +271,9 @@ stages:
codequality: phpstan-quality-report.json codequality: phpstan-quality-report.json
'🧹 PHP Coding standards (PHPCS)': '🧹 PHP Coding standards (PHPCS)':
<<: [ *with-composer, *junit-artifacts, *default-job-settings-lint ] <<: [ *with-composer, *default-job-settings-lint ]
stage: 🪄 Lint stage: 🪄 Lint
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "16" KUBERNETES_CPU_REQUEST: "16"
script: script:
- composer phpcs -- --report-full --report-summary --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json - composer phpcs -- --report-full --report-summary --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json
...@@ -298,10 +282,9 @@ stages: ...@@ -298,10 +282,9 @@ stages:
codequality: phpcs-quality-report.json codequality: phpcs-quality-report.json
'🧹 JavaScript linting (eslint)': '🧹 JavaScript linting (eslint)':
<<: [ *with-yarn, *junit-artifacts, *default-job-settings-lint ] <<: [ *with-yarn, *default-job-settings-lint ]
stage: 🪄 Lint stage: 🪄 Lint
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "2" KUBERNETES_CPU_REQUEST: "2"
script: script:
- yarn --cwd=./core run -s lint:core-js-passing --format gitlab - yarn --cwd=./core run -s lint:core-js-passing --format gitlab
...@@ -310,10 +293,9 @@ stages: ...@@ -310,10 +293,9 @@ stages:
codequality: eslint-quality-report.json codequality: eslint-quality-report.json
'🧹 CSS linting (stylelint)': '🧹 CSS linting (stylelint)':
<<: [ *with-yarn, *junit-artifacts, *default-job-settings-lint ] <<: [ *with-yarn, *default-job-settings-lint ]
stage: 🪄 Lint stage: 🪄 Lint
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "2" KUBERNETES_CPU_REQUEST: "2"
script: script:
- yarn run --cwd=./core lint:css --color --custom-formatter=node_modules/stylelint-formatter-gitlab - yarn run --cwd=./core lint:css --color --custom-formatter=node_modules/stylelint-formatter-gitlab
...@@ -325,7 +307,6 @@ stages: ...@@ -325,7 +307,6 @@ stages:
<<: [ *with-yarn, *default-job-settings-lint ] <<: [ *with-yarn, *default-job-settings-lint ]
stage: 🪄 Lint stage: 🪄 Lint
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "2" KUBERNETES_CPU_REQUEST: "2"
script: script:
- yarn run --cwd=./core build:css --check - yarn run --cwd=./core build:css --check
...@@ -335,7 +316,6 @@ stages: ...@@ -335,7 +316,6 @@ stages:
<<: [ *with-yarn, *default-job-settings-lint ] <<: [ *with-yarn, *default-job-settings-lint ]
stage: 🪄 Lint stage: 🪄 Lint
variables: variables:
<<: *default-lint-variables
KUBERNETES_CPU_REQUEST: "2" KUBERNETES_CPU_REQUEST: "2"
script: script:
- export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH} - export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}
......
...@@ -7,10 +7,8 @@ stages: ...@@ -7,10 +7,8 @@ stages:
# Templates # # Templates #
############# #############
.default-job-settings: &default-job-settings default:
stage: 🗜️ Test
interruptible: true interruptible: true
allow_failure: false
retry: retry:
max: 2 max: 2
when: when:
...@@ -21,17 +19,30 @@ stages: ...@@ -21,17 +19,30 @@ stages:
- scheduler_failure - scheduler_failure
image: image:
name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
rules: before_script:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline" && $PERFORMANCE_TEST != "1" - |
ln -s $CI_PROJECT_DIR /var/www/html/subdirectory
.junit-artifacts: &junit-artifacts sudo service apache2 start
[[ $_TARGET_DB == sqlite* ]] && export SIMPLETEST_DB=sqlite://localhost/$CI_PROJECT_DIR/sites/default/files/db.sqlite?module=sqlite
[[ $_TARGET_DB == mysql* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql
[[ $_TARGET_DB == mariadb* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql
[[ $_TARGET_DB == pgsql* ]] && export SIMPLETEST_DB=pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@database/$POSTGRES_DB?module=pgsql
mkdir -p ./sites/simpletest ./sites/default/files ./build/logs/junit /var/www/.composer
chown -R www-data:www-data ./sites ./build/logs/junit ./vendor /var/www/
sudo -u www-data git config --global --add safe.directory $CI_PROJECT_DIR
artifacts: artifacts:
expose_as: junit when: always
expire_in: 6 mos expire_in: 6 mos
paths:
- junit.xml
reports: reports:
junit: junit.xml junit: ./sites/default/files/simpletest/phpunit-*.xml
paths:
- ./sites/default/files/simpletest/phpunit-*.xml
- ./sites/simpletest/browser_output
.default-job-settings: &default-job-settings
stage: 🗜️ Test
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline" && $PERFORMANCE_TEST != "1"
.with-composer: &with-composer .with-composer: &with-composer
needs: needs:
...@@ -45,7 +56,7 @@ stages: ...@@ -45,7 +56,7 @@ stages:
- pipeline: $PARENT_PIPELINE_ID - pipeline: $PARENT_PIPELINE_ID
job: '📦️ Yarn' job: '📦️ Yarn'
.test-variables: &test-variables variables:
FF_NETWORK_PER_BUILD: 1 FF_NETWORK_PER_BUILD: 1
SIMPLETEST_BASE_URL: http://localhost/subdirectory SIMPLETEST_BASE_URL: http://localhost/subdirectory
DB_DRIVER: mysql DB_DRIVER: mysql
...@@ -74,45 +85,13 @@ stages: ...@@ -74,45 +85,13 @@ stages:
- "--verbose" - "--verbose"
- "--whitelisted-ips=" - "--whitelisted-ips="
.phpunit-artifacts: &phpunit-artifacts
artifacts:
when: always
expire_in: 6 mos
reports:
junit: ./sites/default/files/simpletest/phpunit-*.xml
paths:
- ./sites/default/files/simpletest/phpunit-*.xml
- ./sites/simpletest/browser_output
.setup-webroot: &setup-webserver
before_script:
- ln -s $CI_PROJECT_DIR /var/www/html/subdirectory
- sudo service apache2 start
.set-simpletest-db: &set-simpletest-db
- |
[[ $_TARGET_DB == sqlite* ]] && export SIMPLETEST_DB=sqlite://localhost/$CI_PROJECT_DIR/sites/default/files/db.sqlite?module=sqlite
[[ $_TARGET_DB == mysql* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql
[[ $_TARGET_DB == mariadb* ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql
[[ $_TARGET_DB == pgsql* ]] && export SIMPLETEST_DB=pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@database/$POSTGRES_DB?module=pgsql
.set-directory-settings: &set-directory-settings
- |
mkdir -p ./sites/simpletest ./sites/default/files ./build/logs/junit /var/www/.composer
chown -R www-data:www-data ./sites ./build/logs/junit ./vendor /var/www/
sudo -u www-data git config --global --add safe.directory $CI_PROJECT_DIR
.run-tests: &run-tests .run-tests: &run-tests
script: script:
- *set-simpletest-db
- *set-directory-settings
# Need to pass this along directly. # Need to pass this along directly.
- sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --types "$TESTSUITE" --concurrency "$CONCURRENCY" --repeat "1" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --all --ci-parallel-node-index $CI_PARALLEL_NODE_INDEX --ci-parallel-node-total $CI_PARALLEL_NODE_TOTAL - sudo MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data php ./core/scripts/run-tests.sh --color --keep-results --types "$TESTSUITE" --concurrency "$CONCURRENCY" --repeat "1" --sqlite "./sites/default/files/tests.sqlite" --dburl $SIMPLETEST_DB --url $SIMPLETEST_BASE_URL --verbose --non-html --all --ci-parallel-node-index $CI_PARALLEL_NODE_INDEX --ci-parallel-node-total $CI_PARALLEL_NODE_TOTAL
.run-repeat-class-test: &run-repeat-class-test .run-repeat-class-test: &run-repeat-class-test
script: script:
- *set-simpletest-db
- *set-directory-settings
- echo "ℹ️ Running class ${REPEAT_TEST_CLASS}" - echo "ℹ️ Running class ${REPEAT_TEST_CLASS}"
- | - |
if [[ $REPEAT_TEST_CLASS == "Drupal\Tests\Change\Me" ]]; then if [[ $REPEAT_TEST_CLASS == "Drupal\Tests\Change\Me" ]]; then
...@@ -135,29 +114,22 @@ stages: ...@@ -135,29 +114,22 @@ stages:
################ ################
'🌐️️ PHPUnit Functional': '🌐️️ PHPUnit Functional':
<<: [ *with-composer, *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ] <<: [ *with-composer, *run-tests, *default-job-settings ]
parallel: 7 parallel: 7
variables: variables:
<<: *test-variables
TESTSUITE: PHPUnit-Functional TESTSUITE: PHPUnit-Functional
CONCURRENCY: "$CONCURRENCY"
KUBERNETES_CPU_REQUEST: "24" KUBERNETES_CPU_REQUEST: "24"
services: services:
- <<: *with-database - <<: *with-database
'🩹 Test-only changes': '🩹 Test-only changes':
<<: [ *with-composer, *phpunit-artifacts, *setup-webserver, *default-job-settings ] <<: [ *with-composer, *default-job-settings ]
when: manual when: manual
interruptible: true
allow_failure: true allow_failure: true
variables:
<<: *test-variables
services: services:
- <<: *with-database - <<: *with-database
- <<: *with-chrome - <<: *with-chrome
script: script:
- *set-simpletest-db
- *set-directory-settings
- export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH} - export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}
- git fetch -vn --depth=3 "$CI_MERGE_REQUEST_PROJECT_URL" "+refs/heads/$TARGET_BRANCH:refs/heads/$TARGET_BRANCH" - git fetch -vn --depth=3 "$CI_MERGE_REQUEST_PROJECT_URL" "+refs/heads/$TARGET_BRANCH:refs/heads/$TARGET_BRANCH"
- | - |
...@@ -185,21 +157,18 @@ stages: ...@@ -185,21 +157,18 @@ stages:
fi fi
'⚙️️ PHPUnit Kernel': '⚙️️ PHPUnit Kernel':
<<: [*with-composer, *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ] <<: [*with-composer, *run-tests, *default-job-settings ]
parallel: 2 parallel: 2
variables: variables:
<<: *test-variables
TESTSUITE: PHPUnit-Kernel TESTSUITE: PHPUnit-Kernel
CONCURRENCY: "$CONCURRENCY"
KUBERNETES_CPU_REQUEST: "16" KUBERNETES_CPU_REQUEST: "16"
services: services:
- <<: *with-database - <<: *with-database
'🖱️️️ PHPUnit Functional Javascript': '🖱️️️ PHPUnit Functional Javascript':
<<: [ *with-composer, *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ] <<: [ *with-composer, *run-tests, *default-job-settings ]
parallel: 2 parallel: 2
variables: variables:
<<: *test-variables
TESTSUITE: PHPUnit-FunctionalJavascript TESTSUITE: PHPUnit-FunctionalJavascript
CONCURRENCY: 15 CONCURRENCY: 15
KUBERNETES_CPU_REQUEST: "8" KUBERNETES_CPU_REQUEST: "8"
...@@ -208,37 +177,31 @@ stages: ...@@ -208,37 +177,31 @@ stages:
- <<: *with-chrome - <<: *with-chrome
'👷️️️ PHPUnit Build': '👷️️️ PHPUnit Build':
<<: [ *with-composer, *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ] <<: [ *with-composer, *run-tests, *default-job-settings ]
variables: variables:
<<: *test-variables
TESTSUITE: PHPUnit-Build TESTSUITE: PHPUnit-Build
CONCURRENCY: "$CONCURRENCY"
KUBERNETES_CPU_REQUEST: "2" KUBERNETES_CPU_REQUEST: "2"
services: services:
- <<: *with-database - <<: *with-database
'⚡️ PHPUnit Unit': '⚡️ PHPUnit Unit':
<<: [ *with-composer, *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ] <<: [ *with-composer, *run-tests, *default-job-settings ]
services: services:
# There are some unit tests that need a database. # There are some unit tests that need a database.
# @todo Remove after https://www.drupal.org/project/drupal/issues/3386217 # @todo Remove after https://www.drupal.org/project/drupal/issues/3386217
- <<: *with-database - <<: *with-database
variables: variables:
<<: *test-variables
TESTSUITE: PHPUnit-Unit TESTSUITE: PHPUnit-Unit
CONCURRENCY: "$CONCURRENCY"
KUBERNETES_CPU_REQUEST: "16" KUBERNETES_CPU_REQUEST: "16"
'🦉️️️ Nightwatch': '🦉️️️ Nightwatch':
<<: [ *with-composer-and-yarn, *setup-webserver, *default-job-settings ] <<: [ *with-composer-and-yarn, *default-job-settings ]
variables: variables:
<<: *test-variables
KUBERNETES_CPU_REQUEST: "3" KUBERNETES_CPU_REQUEST: "3"
services: services:
- <<: *with-database - <<: *with-database
- <<: *with-chrome - <<: *with-chrome
script: script:
- *set-simpletest-db
- export DRUPAL_TEST_DB_URL=$SIMPLETEST_DB - export DRUPAL_TEST_DB_URL=$SIMPLETEST_DB
- cp ./core/.env.example ./core/.env - cp ./core/.env.example ./core/.env
# dotenv-safe/config does not support environment variables # dotenv-safe/config does not support environment variables
...@@ -264,23 +227,19 @@ stages: ...@@ -264,23 +227,19 @@ stages:
- ./nightwatch_output - ./nightwatch_output
'🔁 Repeat Class Test': '🔁 Repeat Class Test':
<<: [ *with-composer, *phpunit-artifacts, *setup-webserver, *run-repeat-class-test, *default-job-settings ] <<: [ *with-composer, *run-repeat-class-test, *default-job-settings ]
when: manual when: manual
interruptible: true
allow_failure: true allow_failure: true
variables: variables:
<<: *test-variables
CONCURRENCY: "$CONCURRENCY"
REPEAT_TEST_CLASS: 'Drupal\Tests\Change\Me' REPEAT_TEST_CLASS: 'Drupal\Tests\Change\Me'
services: services:
- <<: *with-database - <<: *with-database
'🚲 Performance tests': '🚲 Performance tests':
<<: [ *with-composer, *phpunit-artifacts, *setup-webserver, *default-job-settings ] <<: [ *with-composer, *default-job-settings ]
rules: rules:
- if: $PERFORMANCE_TEST == "1" - if: $PERFORMANCE_TEST == "1"
variables: variables:
<<: *test-variables
KUBERNETES_CPU_REQUEST: "24" KUBERNETES_CPU_REQUEST: "24"
services: services:
- <<: *with-database - <<: *with-database
......
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