Skip to content

Commit

Permalink
Run Infection only for changed files in PRs (#575)
Browse files Browse the repository at this point in the history
Add --only-covered --min-msi=90 options

Reuse code, add $INFECTION_FLAGS for nightly build

Test on the branch, not PR

Revert "Test on the branch, not PR"
  • Loading branch information
maks-rafalko committed Nov 20, 2018
1 parent ab723af commit ebae8b8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
14 changes: 14 additions & 0 deletions .ci/xdebug.sh → .ci/travis-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,18 @@ function xdebug-enable() {
if [[ -f "/tmp/xdebug.ini" ]]; then
phpenv config-add /tmp/xdebug.ini
fi
}

function get-infection-pr-flags() {
if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]]; then
INFECTION_PR_FLAGS="";
else
git remote set-branches --add origin $TRAVIS_BRANCH;
git fetch;

CHANGED_FILES=$(git diff origin/$TRAVIS_BRANCH --diff-filter=AM --name-only | grep src/ | paste -sd "," -);
INFECTION_PR_FLAGS="--filter=${CHANGED_FILES} --ignore-msi-with-no-mutations --only-covered --min-msi=90";
fi

echo $INFECTION_PR_FLAGS;
}
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ addons:
- expect

before_install:
- source .ci/xdebug.sh
- source .ci/travis-functions.sh
- xdebug-disable

jobs:
Expand Down Expand Up @@ -58,10 +58,13 @@ jobs:
fi
- if [[ $NO_DEBUGGER == 1 ]]; then xdebug-disable; fi
- |
INFECTION_PR_FLAGS=$(get-infection-pr-flags);
echo "INFECTION_PR_FLAGS=$INFECTION_PR_FLAGS";
if [[ $PHPDBG != 1 ]]; then
bin/infection $INFECTION_FLAGS;
bin/infection $INFECTION_FLAGS $INFECTION_PR_FLAGS;
else
phpdbg -qrr bin/infection $INFECTION_FLAGS;
phpdbg -qrr bin/infection $INFECTION_FLAGS $INFECTION_PR_FLAGS;
fi
after_success:
Expand Down Expand Up @@ -126,7 +129,9 @@ jobs:
- make build/bin/infection.phar;
- ./tests/e2e_tests build/bin/infection.phar;
- phpdbg -qrr $PHPUNIT_BIN
- phpdbg -qrr bin/infection $INFECTION_FLAGS
- |
INFECTION_PR_FLAGS=$(get-infection-pr-flags);
phpdbg -qrr bin/infection $INFECTION_FLAGS $INFECTION_PR_FLAGS;
- stage: Deploy
php: 7.2
Expand Down
1 change: 0 additions & 1 deletion src/Mutator/Arithmetic/Minus.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ final class Minus extends Mutator
/**
* Replaces "-" with "+"
*
*
* @return Node\Expr\BinaryOp\Plus
*/
public function mutate(Node $node)
Expand Down
1 change: 0 additions & 1 deletion src/Mutator/Arithmetic/Plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ final class Plus extends Mutator
/**
* Replaces "+" with "-"
*
*
* @return Node\Expr\BinaryOp\Minus
*/
public function mutate(Node $node)
Expand Down

0 comments on commit ebae8b8

Please sign in to comment.