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

Issue #3386566 by larowlan, fjgarlin, smustgrave, catch: Add support for 'test...

Issue #3386566 by larowlan, fjgarlin, smustgrave, catch: Add support for 'test only' changes to gitlab CI

(cherry picked from commit 3f49e8cd)
parent 28ada580
No related branches found
No related tags found
14 merge requests!11628Update file MediaLibraryWidget.php,!7564Revert "Issue #3364773 by roshnichordiya, Chris Matthews, thakurnishant_06,...,!5752Issue #3275828 by joachim, quietone, bradjones1, Berdir: document the reason...,!5627Issue #3261805: Field not saved when change of 0 on string start,!5427Issue #3338518: send credentials in ajax if configured in CORS settings.,!5395Issue #3387916 by fjgarlin, Spokje: Each GitLab job exposes user email,!5217Issue #3386607 by alexpott: Improve spell checking in commit-code-check.sh,!5064Issue #3379522 by finnsky, Gauravvvv, kostyashupenko, smustgrave, Chi: Revert...,!5040SDC ComponentElement: Transform slots scalar values to #plain_text instead of throwing an exception,!4958Issue #3392147: Whitelist IP for a Ban module.,!4894Issue #3280279: Add API to allow sites to opt in to upload SVG images in CKEditor 5,!3106Issue #3017548: "Filtered HTML" text format does not support manual teaser break (<!--break-->),!925Issue #2339235: Remove taxonomy hard dependency on node module,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links
Pipeline #24990 passed
Pipeline: drupal

#24996

    Pipeline: drupal

    #24995

      Pipeline: drupal

      #24994

        ...@@ -202,6 +202,54 @@ stages: ...@@ -202,6 +202,54 @@ stages:
        services: services:
        - <<: *with-database - <<: *with-database
        '🩹 Test-only changes':
        <<: [ *with-composer-cache, *phpunit-artifacts, *setup-webserver, *default-job-settings ]
        stage: 🗜️ Test
        when: manual
        interruptible: true
        allow_failure: true
        variables:
        <<: *test-variables
        services:
        - <<: *with-database
        - <<: *with-chrome
        script:
        # Determine DB driver.
        - |
        [[ $_TARGET_DB_TYPE == "sqlite" ]] && export SIMPLETEST_DB=sqlite://localhost/subdirectory/sites/default/files/db.sqlite?module=sqlite
        [[ $_TARGET_DB_TYPE == "mysql" ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql
        [[ $_TARGET_DB_TYPE == "mariadb" ]] && export SIMPLETEST_DB=mysql://$MYSQL_USER:$MYSQL_PASSWORD@database/$MYSQL_DATABASE?module=mysql
        [[ $_TARGET_DB_TYPE == "pgsql" ]] && export SIMPLETEST_DB=pgsql://$POSTGRES_USER:$POSTGRES_PASSWORD@database/$POSTGRES_DB?module=pgsql
        - export
        - 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
        - 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"
        - |
        echo "ℹ️ Changes from ${TARGET_BRANCH}"
        git diff refs/heads/${TARGET_BRANCH} --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 refs/heads/${TARGET_BRANCH} --diff-filter=DM --name-only|grep -Ev "Test.php$"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
        git diff refs/heads/${TARGET_BRANCH} --diff-filter=DM --name-only|grep -Ev "Test.php$"|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 refs/heads/${TARGET_BRANCH} --diff-filter=A --name-only|grep -Ev "Test.php$"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
        git diff refs/heads/${TARGET_BRANCH} --diff-filter=A --name-only|grep -Ev "Test.php$"|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 refs/heads/${TARGET_BRANCH} --name-only|grep -E "Test.php$") ]]; then
        for test in `git diff refs/heads/${TARGET_BRANCH} --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
        '⚙️️ PHPUnit Kernel': '⚙️️ PHPUnit Kernel':
        <<: [*with-composer-cache, *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ] <<: [*with-composer-cache, *phpunit-artifacts, *setup-webserver, *run-tests, *default-job-settings ]
        stage: 🗜️ Test stage: 🗜️ Test
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment