Skip to content

Commit

Permalink
Merge pull request #15 from nkammah/master
Browse files Browse the repository at this point in the history
Move TryLib to composer and fix tests to work with recent phpunit version
  • Loading branch information
nkammah authored Apr 28, 2017
2 parents d8a5f4b + 76cce0c commit 43052ed
Show file tree
Hide file tree
Showing 43 changed files with 435 additions and 474 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor
composer.lock
patch.diff
29 changes: 9 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
language: php

php:
- "5.3"
- "5.4"
- "5.5"
- "7.0"
- "7.1"

- 5.6
- 7.0
- 7.1

before_script:
- pear config-set verbose 3
- pear channel-discover pear.bovigo.org
- pear install bovigo/vfsStream-beta
- export PHP_INCLUDE_PATH=`pear config-get php_dir`
- export PHP_INI_FILE=`pear config-get php_ini`
- echo 'include_path = ".:${PHP_INCLUDE_PATH}"' >> $PHP_INI_FILE
- echo $PHP_INCLUDE_PATH
- phpenv rehash

script: phpunit tests

notifications:
email: false
irc: false
- composer self-update
- composer install --prefer-source --no-interaction --dev

script: phpunit
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ Try will work with your branches! The below scenarios are supported:
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_GitCopyAge(48, 96, $remote_branch)
new TryLib_Precheck_GitReportUntracked(),
new TryLib\Precheck\ScriptRunner('/path/to/some/script'),
new TryLib\Precheck\GitCopyBehind(array('master')),
new TryLib\Precheck\GitCopyAge(48, 96, $remote_branch)
new TryLib\Precheck\GitReportUntracked(),
);

$repo_manager->runPrechecks($pre_checks);
Expand All @@ -194,4 +194,4 @@ Some pre-checks will just emit a warning, some can block the try execution.

You can run the unit test suite with:

phpunit tests
phpunit
8 changes: 0 additions & 8 deletions TryLib/Autoload.php

This file was deleted.

20 changes: 0 additions & 20 deletions TryLib/Precheck/GitWarnOnBlacklisted.php

This file was deleted.

62 changes: 0 additions & 62 deletions TryLib/Util/PHPOptions/test.php

This file was deleted.

29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "etsy/TryLib",
"type": "library",
"description": "Try lib : send your diffs to your CI cluster.",
"version": "2.0.0",
"license": "MIT",
"keywords": ["try", "etsy", "ci", "continuous integration"],
"authors": [
{
"name": "Nassim Kammah",
"email": "nkammah@etsy.com"
},
{
"name": "Laura Beth Lincoln Denker"
}
],
"require": {
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": ">=5.5.0",
"mikey179/vfsStream": "~1"
},
"autoload": {
"psr-4": {
"TryLib\\": "src/"
}
}
}
88 changes: 0 additions & 88 deletions package.xml

This file was deleted.

17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="TryLib Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
11 changes: 8 additions & 3 deletions TryLib/CommandRunner.php → src/CommandRunner.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

class TryLib_CommandRunner {
namespace TryLib;

use TryLib\Util\AnsiColor;
use TryLib\Util\DisplayException as DisplayException;

class CommandRunner {
protected $verbose;
protected $stderr;
protected $out;
Expand All @@ -24,8 +29,8 @@ public function __construct($verbose = false, $stdout = null, $stderr = null) {
$this->out = '';

try {
$this->colors = new TryLib_Util_AnsiColor();
} catch (TryLib_Util_DisplayException $e) {
$this->colors = new AnsiColor();
} catch (DisplayException $e) {
$this->colors = false;
}
}
Expand Down
7 changes: 6 additions & 1 deletion TryLib/JenkinsRunner.php → src/JenkinsRunner.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php

namespace TryLib;

use Exception;

/**
* Abstract class for interfacing with Jenkins projects
* Every Jenkins project should be invokable via CLI using a
Expand All @@ -7,7 +12,7 @@
* Finally, upon calling the "build" command via the CLI, the output
* from the CLI should be parseable to provide the results of the build.
*/
abstract class TryLib_JenkinsRunner {
abstract class JenkinsRunner {
protected $jenkins_url;
protected $jenkins_cli;
protected $try_job_name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

class TryLib_JenkinsRunner_FreeStyleProject extends TryLib_JenkinsRunner{
namespace TryLib\JenkinsRunner;

use TryLib\JenkinsRunner;

class FreeStyleProject extends JenkinsRunner{

public function getBuildCommand() {
return 'build';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php

class TryLib_JenkinsRunner_MasterProject extends TryLib_JenkinsRunner{
namespace TryLib\JenkinsRunner;

use TryLib\JenkinsRunner;
use TryLib\Util\AnsiColor;
use TryLib\Util\DisplayException as DisplayException;

class MasterProject extends JenkinsRunner{
protected $colors;
private $jobs;
private $excluded_jobs;
Expand All @@ -26,8 +32,8 @@ public function __construct(
$this->excluded_jobs = array();

try {
$this->colors = new TryLib_Util_AnsiColor();
} catch (TryLib_Util_DisplayException $e) {
$this->colors = new AnsiColor();
} catch (DisplayException $e) {
$this->colors = false;
}

Expand Down Expand Up @@ -105,7 +111,7 @@ public function pollForCompletion($show_progress) {
public function processLogOuput($prev_text, $show_progress) {
$try_log = $this->getJobOutput();

$new_text = str_replace($prev_text, '', $try_log);
$new_text = str_replace($prev_text, "", $try_log);
$prev_text = $try_log;

if ($show_progress) {
Expand Down
4 changes: 3 additions & 1 deletion TryLib/Precheck.php → src/Precheck.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

interface TryLib_PreCheck {
namespace TryLib;

interface Precheck {
function check($cmd_runner, $location, $upstream);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?php

class TryLib_Precheck_GitCopyAge implements TryLib_Precheck {
namespace TryLib\Precheck;

use TryLib\Precheck as Precheck;
use DateTime;
use DateInterval;

class GitCopyAge implements Precheck {
protected $max_age_warning;
protected $max_age_blocking;
protected $remote_branch;
Expand Down
Loading

0 comments on commit 43052ed

Please sign in to comment.