Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different DRUPAL_TI_SIMPLETEST_GROUP depending on TRAVIS_PULL_REQUEST #67

Open
yanniboi opened this issue Jan 7, 2016 · 2 comments
Open
Labels

Comments

@yanniboi
Copy link
Contributor

yanniboi commented Jan 7, 2016

Hi, this might be me not entirely understanding the travis test stack properly, but I have a request.

I would like to be able to run all drupal simpletests with my module enabled when I push code to a repo. This is so as to make sure that my module does not break core functionality.

As this takes hours however, I would like to only run tests that my module provides when creating pull requests, so that we don't have to spend hours waiting for tests before merging code.

Drupal_ti uses the DRUPAL_TI_SIMPLETEST_GROUP variable to tell the simpletest runner which tests to limit by, and TRAVIS_PULL_REQUEST tells me whether on not I want the runner to filter tests.

I've attempted to change the variable like this:

if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
  echo 'Scheduling all simpletests to be run.'
else
  echo 'Scheduling my_module simpletests to be run.'
  export DRUPAL_TI_SIMPLETEST_GROUP='my_module'
fi

But this doesn't seem to work as by the time the simpltest runner 'script.sh' runs, it has reset DRUPAL_TI_SIMPLETEST_GROUP to whatever is set in the .travis.yml.

Is there any way that I can achieve this without patching the runner script as part of my environment setup?

@yanniboi
Copy link
Contributor Author

yanniboi commented Jan 7, 2016

I am currently solving this issue by applying the following patch as part of my before-script tasks, but this is obviously not a stable solution as I clone the dev-master drupal_ti repo to stay up to date with changes to drupal 8 core...

diff --git a/runners/simpletest/script.sh b/runners/simpletest/script.sh
index a9f0bf9..2f5c240 100755
--- a/runners/simpletest/script.sh
+++ b/runners/simpletest/script.sh
@@ -11,6 +11,16 @@ then
         ARGS=( "${ARGS[@]}" "$DRUPAL_TI_SIMPLETEST_GROUP" )
 fi

+# Hack by yanniboi to allow different filters on pull request.
+if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
+        echo 'Scheduling all simpletests to be run.'
+        ARGS=( "${ARGS[@]}" "$DRUPAL_TI_NON_PULL_SIMPLETEST_GROUP" )
+else
+        echo 'Scheduling decoupled_auth simpletests to be run.'
+        ARGS=( "${ARGS[@]}" "$DRUPAL_TI_PULL_SIMPLETEST_GROUP" )
+fi
+
+echo ${ARGS[@]}

 cd "$DRUPAL_TI_DRUPAL_DIR"
 { php "$DRUPAL_TI_SIMPLETEST_FILE" --php $(which php) "${ARGS[@]}" || echo "1 fails"; } | tee /tmp/simpletest-result.txt

@LionsAd
Copy link
Owner

LionsAd commented May 24, 2016

drupal_ti is module, which means you can just define a .before directory then add:

.drupal_ti/before/runners/simpletest/script.sh

and there you can change your code to use:

if [ "${TRAVIS_PULL_REQUEST}" = "false" ]
then
  echo 'Scheduling all simpletests to be run.'
  DRUPAL_TI_SIMPLETEST_GROUP="$DRUPAL_TI_NON_PULL_SIMPLETEST_GROUP"
else
  echo 'Scheduling decoupled_auth simpletests to be run.'
  DRUPAL_TI_SIMPLETEST_GROUP="$DRUPAL_TI_PULL_SIMPLETEST_GROUP"
fi

but the same should also work somewhere in travis.yml - if you source the script e.g. with '. myscript.sh'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants