2023-11-23 10:33:20 +00:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-02-20 17:30:09 +00:00
|
|
|
|
BASELINE=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA:-$CI_MERGE_REQUEST_DIFF_BASE_SHA}
|
2023-11-23 10:33:20 +00:00
|
|
|
|
|
2024-02-20 17:30:09 +00:00
|
|
|
|
echo "ℹ️ Changes from ${BASELINE}"
|
|
|
|
|
git diff ${BASELINE} --name-only
|
2023-11-23 10:33:20 +00:00
|
|
|
|
echo "If this list contains more files than what you changed, then you need to rebase your branch."
|
|
|
|
|
|
|
|
|
|
echo "1️⃣ Reverting non test changes"
|
2024-02-20 17:30:09 +00:00
|
|
|
|
if [[ $(git diff ${BASELINE} --diff-filter=DM --name-only|grep -Ev "*/tests/*"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
|
|
|
|
|
git diff ${BASELINE} --diff-filter=DM --name-only|grep -Ev "*/tests/*"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
|
2023-11-23 10:33:20 +00:00
|
|
|
|
echo "↩️ Reverting $file";
|
2024-02-20 17:30:09 +00:00
|
|
|
|
git checkout ${BASELINE} -- $file;
|
2023-11-23 10:33:20 +00:00
|
|
|
|
done
|
|
|
|
|
fi
|
2024-02-20 17:30:09 +00:00
|
|
|
|
if [[ $(git diff ${BASELINE} --diff-filter=A --name-only|grep -Ev "*/tests/*"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh) ]]; then
|
|
|
|
|
git diff ${BASELINE} --diff-filter=A --name-only|grep -Ev "*/tests/*"|grep -v .gitlab-ci|grep -v scripts/run-tests.sh|while read file;do
|
2023-11-23 10:33:20 +00:00
|
|
|
|
echo "🗑️️ Deleting $file";
|
|
|
|
|
git rm $file;
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "2️⃣ Running test changes for this branch"
|
2024-06-26 10:01:40 +00:00
|
|
|
|
EXIT_CODE=0
|
2024-02-20 17:30:09 +00:00
|
|
|
|
if [[ $(git diff ${BASELINE} --name-only|grep -E "Test.php$") ]]; then
|
|
|
|
|
for test in `git diff ${BASELINE} --name-only|grep -E "Test.php$"`; do
|
2024-06-26 10:01:40 +00:00
|
|
|
|
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 || EXIT_CODE=$?;
|
2023-11-23 10:33:20 +00:00
|
|
|
|
done;
|
|
|
|
|
fi
|
2024-06-26 10:01:40 +00:00
|
|
|
|
|
|
|
|
|
echo "Exiting with EXIT_CODE=$EXIT_CODE"
|
|
|
|
|
exit $EXIT_CODE
|