Skip to content

Commit

Permalink
Make the default branch main. (#25)
Browse files Browse the repository at this point in the history
* Start moving to 'main' default branch.

* Fix tests.

* Make tests use main.

* Fix name of dependency.

* Add more recent versions of PHP to travis config.

* Remove unsupported versions of PHP.

* .gitignore fix.
  • Loading branch information
russtaylor authored Mar 1, 2021
1 parent 76744ac commit 350ec61
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
composer.lock
patch.diff
.phpunit.result.cache
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.3
- 7.4
- 8.0

before_script:
- composer self-update
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TryLib currently supports **Freestyle** projects, when your test suite consist o
-U, --lines-of-context ... Generate a diff with n lines of context (like git-diff's -U option)
-s, --staged Use staged changes only to generate the diff
-w, --safelist ... Generate the patch for only the safelisted files
-b, --branch ... Remote branch to diff and try against [master]
-b, --branch ... Remote branch to diff and try against [main]

-c, --show-results Show final try job results
-P, --show-progress Print subtasks progressively as they complete
Expand Down Expand Up @@ -152,8 +152,8 @@ More info can be found in the [divide and concur](http://codeascraft.etsy.com/20

Try will work with your branches! The below scenarios are supported:

* You are working on **master**:
* You want to try against master
* You are working on **main**:
* You want to try against main

try [options] [subjobs]
* You want to diff and try against a different branch
Expand All @@ -164,13 +164,13 @@ Try will work with your branches! The below scenarios are supported:
* You want to try against that branch

try [options] [subjobs]
* You want to diff and try against a different branch (master for example)
* You want to diff and try against a different branch (main for example)

try --branch=master [options] [subjobs]
try --branch=main [options] [subjobs]

* You are working on a **local branch not tracked**
* If the remote has a branch with the same name, it will be used to generate the diff and try against it
* If the remote does not have a branch with the same name, it will use the default remote : **master**
* If the remote does not have a branch with the same name, it will use the default remote : **main**
* You want to diff and try against a specific remote branch

try --branch=my_branch [options] [subjobs]
Expand All @@ -181,7 +181,7 @@ Prior to generate the diff, you can configure try to run a list of pre-checks.

$pre_checks = array(
new TryLib\Precheck\ScriptRunner('/path/to/some/script'),
new TryLib\Precheck\GitCopyBehind(array('master')),
new TryLib\Precheck\GitCopyBehind(array('main')),
new TryLib\Precheck\GitCopyAge(48, 96, $remote_branch)
new TryLib\Precheck\GitReportUntracked(),
);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require-dev": {
"phpunit/phpunit": ">=5.5.0",
"mikey179/vfsStream": "~1"
"mikey179/vfsstream": "~1"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites>
<testsuite name="TryLib Test Suite">
<directory suffix=".php">./tests/</directory>
Expand Down
13 changes: 7 additions & 6 deletions src/TryRunner/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ final class Options {
private function __construct() {} // Do not instantiate.

public static function parse(
$argv,
$jenkins_server,
$default_jenkins_job,
$default_jenkins_job_prefix = null,
$default_wc_path = null,
$default_remote_branch = "master") {
$argv,
$jenkins_server,
$default_jenkins_job,
$default_jenkins_job_prefix = null,
$default_wc_path = null,
$default_remote_branch = "main"
) {

$default_jenkins_job_prefix = $default_jenkins_job_prefix ?: $default_jenkins_job;
$default_wc_path = $default_wc_path ?: ".";
Expand Down
2 changes: 1 addition & 1 deletion tests/JenkinsRunner/FreeStyleProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FreeStyleProjectTest extends \PHPUnit\Framework\TestCase {
private $jenkins_runner;
private $mock_cmd_runner;

function setUp() {
function setUp(): void {
parent::setUp();

$this->mock_cmd_runner = $this->getMockBuilder('TryLib\CommandRunner')
Expand Down
2 changes: 1 addition & 1 deletion tests/JenkinsRunner/MasterProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MasterProjectTest extends \PHPUnit\Framework\TestCase {
private $jenkins_runner;
private $mock_cmd_runner;

function setUp() {
function setUp(): void {
parent::setUp();

$this->mock_cmd_runner = $this->getMockBuilder('TryLib\CommandRunner')
Expand Down
15 changes: 8 additions & 7 deletions tests/JenkinsRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class JenkinsRunnerTest extends \PHPUnit\Framework\TestCase {
private $jenkins_runner;
private $mock_cmd_runner;

function setUp() {
function setUp(): void {
parent::setUp();

$this->mock_cmd_runner = $this->getMockBuilder('TryLib\CommandRunner')
Expand All @@ -49,12 +49,13 @@ function setUp() {
* @expectedException Exception
*/
function testInvalidUrl() {
$this->jenkins_runner = new TestRunner(
'totallyvalid.com/',
self::JENKINS_CLI,
self::JENKINS_JOB,
$this->mock_cmd_runner
);
$this->expectException(\Exception::class);
$this->jenkins_runner = new TestRunner(
'totallyvalid.com/',
self::JENKINS_CLI,
self::JENKINS_JOB,
$this->mock_cmd_runner
);
}


Expand Down
8 changes: 4 additions & 4 deletions tests/Precheck/GitCopyAgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GitCopyAgeTest extends \PHPUnit\Framework\TestCase {

private $mock_cmd_runner;

function setUp() {
function setUp(): void {
parent::setUp();
$this->mock_cmd_runner = $this->getMockBuilder('TryLib\CommandRunner')
->getMock();
Expand Down Expand Up @@ -78,7 +78,7 @@ function testWorkingCopyPastMaxBlockingAge() {
->method('terminate')
->with($this->stringContains('you working copy is 100 hours old.'));

$script_runner->check($this->mock_cmd_runner, 'path', 'origin/master');
$script_runner->check($this->mock_cmd_runner, 'path', 'origin/main');
}

function testWorkingCopyPastMaxWarningAge() {
Expand Down Expand Up @@ -110,7 +110,7 @@ function testWorkingCopyPastMaxWarningAge() {
$this->mock_cmd_runner->expects($this->once())
->method('warn');

$script_runner->check($this->mock_cmd_runner, 'path', 'origin/master');
$script_runner->check($this->mock_cmd_runner, 'path', 'origin/main');
}


Expand Down Expand Up @@ -141,6 +141,6 @@ function testWorkingCopySuccess() {
$this->mock_cmd_runner->expects($this->never())
->method('warn');

$script_runner->check($this->mock_cmd_runner, 'path', 'origin/master');
$script_runner->check($this->mock_cmd_runner, 'path', 'origin/main');
}
}
20 changes: 10 additions & 10 deletions tests/Precheck/GitCopyBehindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ function testShouldRunCheckShouldRun() {

$mock_cmd_runner->expects($this->once())
->method('getOutput')
->will($this->returnValue('master'));
->will($this->returnValue('main'));

$git_copy_behind_check = new GitCopyBehind(array('master'));
$git_copy_behind_check = new GitCopyBehind(array('main'));

$this->assertTrue($git_copy_behind_check->shouldRunCheck($mock_cmd_runner));
}
Expand All @@ -35,7 +35,7 @@ function testShouldRunCheckShouldNotRun() {
->method('getOutput')
->will($this->returnValue('myfeature'));

$git_copy_behind_check = new GitCopyBehind(array('master'));
$git_copy_behind_check = new GitCopyBehind(array('main'));

$this->assertFalse($git_copy_behind_check->shouldRunCheck($mock_cmd_runner));
}
Expand All @@ -50,7 +50,7 @@ function testShouldRunCheckNoBranches() {

$mock_cmd_runner->expects($this->once())
->method('getOutput')
->will($this->returnValue('master'));
->will($this->returnValue('main'));

$git_copy_behind_check = new GitCopyBehind(array());

Expand All @@ -74,15 +74,15 @@ function testCheckWorkingCopyBehind() {

$script_runner = $this->getMockBuilder('TryLib\Precheck\GitCopyBehind')
->setMethods(['shouldRunCheck'])
->setConstructorArgs([['master']])
->setConstructorArgs([['main']])
->getMock();

$script_runner->expects($this->once())
->method('shouldRunCheck')
->with($mock_cmd_runner)
->will($this->returnValue(true));

$script_runner->check($mock_cmd_runner, 'path', 'origin/master');
$script_runner->check($mock_cmd_runner, 'path', 'origin/main');
}

function testCheckWorkingCopyNotBehind() {
Expand All @@ -102,15 +102,15 @@ function testCheckWorkingCopyNotBehind() {

$script_runner = $this->getMockBuilder('TryLib\Precheck\GitCopyBehind')
->setMethods(['shouldRunCheck'])
->setConstructorArgs([['master']])
->setConstructorArgs([['main']])
->getMock();

$script_runner->expects($this->once())
->method('shouldRunCheck')
->with($mock_cmd_runner)
->will($this->returnValue(true));

$script_runner->check($mock_cmd_runner, 'path', 'origin/master');
$script_runner->check($mock_cmd_runner, 'path', 'origin/main');
}

function testCheckShouldNotRun() {
Expand All @@ -128,14 +128,14 @@ function testCheckShouldNotRun() {

$script_runner = $this->getMockBuilder('TryLib\Precheck\GitCopyBehind')
->setMethods(['shouldRunCheck'])
->setConstructorArgs([['master']])
->setConstructorArgs([['main']])
->getMock();

$script_runner->expects($this->once())
->method('shouldRunCheck')
->with($mock_cmd_runner)
->will($this->returnValue(false));

$script_runner->check($mock_cmd_runner, 'path', 'origin/master');
$script_runner->check($mock_cmd_runner, 'path', 'origin/main');
}
}
2 changes: 1 addition & 1 deletion tests/Precheck/GitWarnOnBlocklistedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use TryLib\Precheck\GitWarnOnBlocklisted as GitWarnOnBlocklisted;

class GitWarnOnBlocklistedTest extends \PHPUnit\Framework\TestCase {
function setUp() {
function setUp(): void {
parent::setUp();
$this->mock_cmd_runner = $this->getMockBuilder('TryLib\CommandRunner')
->getMock();
Expand Down
8 changes: 4 additions & 4 deletions tests/Precheck/ScriptRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ScriptRunnerTest extends \PHPUnit\Framework\TestCase {

private $mock_cmd_runner;

function setUp() {
function setUp(): void {
parent::setUp();
$this->mock_cmd_runner = $this->getMockBuilder('TryLib\CommandRunner')
->getMock();
Expand All @@ -28,7 +28,7 @@ function testScriptDoesNotExists() {
$this->mock_cmd_runner->expects($this->never())
->method('terminate');

$script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/master');
$script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/main');
}

function testScriptExistsAndSucceeds() {
Expand All @@ -45,7 +45,7 @@ function testScriptExistsAndSucceeds() {
$this->mock_cmd_runner->expects($this->never())
->method('terminate');

$script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/master');
$script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/main');
}

function testScriptExistsAndFails() {
Expand All @@ -63,6 +63,6 @@ function testScriptExistsAndFails() {
->method('terminate')
->with('Failed running pre-check script vfs://testDir/script');

$script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/master');
$script_runner->check($this->mock_cmd_runner, 'repoPath', 'origin/main');
}
}
Loading

0 comments on commit 350ec61

Please sign in to comment.