Loading...

Run tests on commit

David Carr

1 min read - 27th Aug, 2021

Table of Contents

Run tests on commit

Go into git hooks folder and copy pre-commit.sample to pre-commit

cp .git/hooks/pre-commit.sample .git/hooks/pre-commit

then edit it with vim:

vi .git/hooks/pre-commit

clear the contents by pressing dG to clear the contents.

Next to into insert mode by pressing i

now paste in:

#!/usr/bin/env php
<?php
echo "Running tests.. ";
exec('vendor/bin/phpunit', $output, $returnCode);
if ($returnCode !== 0) {
    // Show full output
    echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL;
    echo "Aborting commit.." . PHP_EOL;
    exit(1);
}
// Show summary (last line)
echo array_pop($output) . PHP_EOL;
exit(0);

Now save and exit by pressing ESC then :wq to write and quit

now every commit will run the tests suite.

So you only want to do this where you have tests passing or you can't move forward until you fix the tests.

Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

0 comments
Add a comment