Skip to content
Snippets Groups Projects
Verified Commit 8f5fa569 authored by Dave Long's avatar Dave Long
Browse files

Issue #3402203 by fjgarlin: Improve the test-only job workflow

(cherry picked from commit 0d44d1f7)
parent 1df6d0e1
No related branches found
No related tags found
20 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump,!5950Issue #3403653 by alexpott, longwave: Incorporate improvements to how contrib runs PHPStan to core,!5858Issue #3401971 by fjgarlin: Test-only job shouldn't require constant rebases...,!5716Draft: Issue #3401102 by Spokje, longwave, smustgrave: Nightwatch artifacts on GitLab not retained,!5674Transaction autocommit during shutdown relies on unreliable object destruction order,!5644Issue #3395563 by nireneko, marvil07, lauriii, borisson_, smustgrave, Wim...
Pipeline #54358 passed
Pipeline: drupal

#54359

    ......@@ -125,7 +125,7 @@ default:
    allow_failure: true
    # Default configuration.
    'PHP 8.2 MySQL 8':
    'DEFAULT: PHP 8.2 MySQL 8':
    <<: *default-stage
    variables:
    _TARGET_PHP: "8.2"
    ......@@ -137,6 +137,22 @@ default:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $PERFORMANCE_TEST == "1"
    'DEFAULT: Test-only':
    <<: [ *default-stage, *with-composer ]
    when: manual
    allow_failure: true
    variables:
    _TARGET_PHP: "8.2"
    _TARGET_DB: "mysql-8"
    rules:
    - if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project"
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    trigger:
    # Rely on the status of the child pipeline.
    strategy: depend
    include:
    - local: .gitlab-ci/pipeline-test-only.yml
    # Run on commit, or manually.
    'PHP 8.1 MySQL 5.7':
    <<: [ *default-stage, *run-on-commit ]
    ......
    # cspell:ignore drupaltestbot drupaltestbotpw
    stages:
    - 🗜️ Test
    variables:
    FF_NETWORK_PER_BUILD: 1
    SIMPLETEST_BASE_URL: http://localhost/subdirectory
    DB_DRIVER: mysql
    MYSQL_ROOT_PASSWORD: root
    MYSQL_DATABASE: mysql
    MYSQL_USER: drupaltestbot
    MYSQL_PASSWORD: drupaltestbotpw
    POSTGRES_DB: drupaltestbot
    POSTGRES_USER: drupaltestbot
    POSTGRES_PASSWORD: drupaltestbotpw
    '🩹 Test-only changes':
    stage: 🗜️ Test
    interruptible: true
    image:
    name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
    rules:
    - if: $CI_PIPELINE_SOURCE == "parent_pipeline" && $PERFORMANCE_TEST != "1"
    needs:
    - pipeline: $PARENT_PIPELINE_ID
    job: '📦️ Composer'
    services:
    - name: $_CONFIG_DOCKERHUB_ROOT/$_TARGET_DB:production
    alias: database
    - name: $_CONFIG_DOCKERHUB_ROOT/chromedriver:production
    alias: chrome
    entrypoint:
    - chromedriver
    - "--no-sandbox"
    - "--log-path=/tmp/chromedriver.log"
    - "--verbose"
    - "--whitelisted-ips="
    before_script:
    - |
    [[ $_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
    - $CI_PROJECT_DIR/.gitlab-ci/scripts/server-setup.sh
    script:
    - $CI_PROJECT_DIR/.gitlab-ci/scripts/test-only.sh
    after_script:
    - sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true
    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
    ......@@ -20,16 +20,12 @@ default:
    image:
    name: $_CONFIG_DOCKERHUB_ROOT/php-$_TARGET_PHP-apache:production
    before_script:
    - |
    ln -s $CI_PROJECT_DIR /var/www/html/subdirectory
    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
    - $CI_PROJECT_DIR/.gitlab-ci/scripts/server-setup.sh
    after_script:
    - sed -i "s#$CI_PROJECT_DIR/##" ./sites/default/files/simpletest/phpunit-*.xml || true
    artifacts:
    ......@@ -132,34 +128,10 @@ variables:
    - <<: *with-database
    - <<: *with-chrome
    script:
    - export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}
    - git fetch -vn --depth=50 "$CI_MERGE_REQUEST_PROJECT_URL" "+refs/heads/$TARGET_BRANCH:refs/heads/$TARGET_BRANCH"
    - |
    echo "ℹ️ Changes from ${TARGET_BRANCH}"
    git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only
    echo "If this list contains more files than what you changed, then you need to rebase your branch."
    echo "1️⃣ Reverting non test changes"
    if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=DM --name-only|grep -Ev "*/tests/*"|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 "*/tests/*"|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
    if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=A --name-only|grep -Ev "*/tests/*"|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 "*/tests/*"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
    echo "🗑️️ Deleting $file";
    git rm $file;
    done
    fi
    echo "2️⃣ Running test changes for this branch"
    if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only|grep -E "Test.php$") ]]; then
    for test in `git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only|grep -E "Test.php$"`; do
    sudo SIMPLETEST_BASE_URL="$SIMPLETEST_BASE_URL" SIMPLETEST_DB="$SIMPLETEST_DB" MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data ./vendor/bin/phpunit -c core $test --log-junit=./sites/default/files/simpletest/phpunit-`echo $test|sed 's/\//_/g' `.xml;
    done;
    fi
    - $CI_PROJECT_DIR/.gitlab-ci/scripts/test-only.sh
    '⚙️️ PHPUnit Kernel':
    <<: [*with-composer, *run-tests, *default-job-settings ]
    <<: [ *with-composer, *run-tests, *default-job-settings ]
    parallel: 2
    variables:
    TESTSUITE: PHPUnit-Kernel
    ......
    #!/bin/bash
    ln -s $CI_PROJECT_DIR /var/www/html/subdirectory
    sudo service apache2 start
    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
    #!/bin/bash
    export TARGET_BRANCH=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}${CI_COMMIT_BRANCH}
    git fetch -vn --depth=50 "$CI_MERGE_REQUEST_PROJECT_URL" "+refs/heads/$TARGET_BRANCH:refs/heads/$TARGET_BRANCH"
    echo "ℹ️ Changes from ${TARGET_BRANCH}"
    git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only
    echo "If this list contains more files than what you changed, then you need to rebase your branch."
    echo "1️⃣ Reverting non test changes"
    if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=DM --name-only|grep -Ev "*/tests/*"|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 "*/tests/*"|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
    if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --diff-filter=A --name-only|grep -Ev "*/tests/*"|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 "*/tests/*"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
    echo "🗑️️ Deleting $file";
    git rm $file;
    done
    fi
    echo "2️⃣ Running test changes for this branch"
    if [[ $(git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only|grep -E "Test.php$") ]]; then
    for test in `git diff ${CI_MERGE_REQUEST_DIFF_BASE_SHA} --name-only|grep -E "Test.php$"`; do
    sudo SIMPLETEST_BASE_URL="$SIMPLETEST_BASE_URL" SIMPLETEST_DB="$SIMPLETEST_DB" MINK_DRIVER_ARGS_WEBDRIVER="$MINK_DRIVER_ARGS_WEBDRIVER" -u www-data ./vendor/bin/phpunit -c core $test --log-junit=./sites/default/files/simpletest/phpunit-`echo $test|sed 's/\//_/g' `.xml;
    done;
    fi
    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