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

MNT Use GitHub Actions CI #41

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:
# Every Monday at 2:00pm UTC
schedule:
- cron: '0 14 * * 1'

jobs:
ci:
name: CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && startsWith(github.repository, 'silverstripe/')) || (github.event_name != 'schedule')
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
17 changes: 17 additions & 0 deletions .github/workflows/keepalive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Keepalive

on:
workflow_dispatch:
# The 4th of every month at 10:50am UTC
schedule:
- cron: '50 10 4 * *'

jobs:
keepalive:
name: Keepalive
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && startsWith(github.repository, 'silverstripe/')) || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Keepalive
uses: silverstripe/gha-keepalive@v1
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"jeremeamia/superclosure": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36|^5.7.27"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 14 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>

<file>src</file>
<file>tests</file>

<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
</rule>
</ruleset>
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Manager/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ProcessManager implements Manager

/**
* Get a list of the waiting tasks.
*
*
* @return array
*/
public function getWaiting()
Expand All @@ -75,7 +75,7 @@ public function getWaiting()

/**
* Get a list of the running tasks.
*
*
* @return array
*/
public function getRunning()
Expand Down
25 changes: 18 additions & 7 deletions src/Rules/InMemoryRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ public function canRunTask(Task $task, Profile $profile)
continue;
}

if (($rule->getHandler() === null || $rule->getHandler() === $task->getHandler()) && ($this->hasTooManyProcessesRunning($rule, $profile) || $this->hasTooManySiblingProcessesRunning($rule, $profile))) {
if (($rule->getHandler() === null || $rule->getHandler() === $task->getHandler()) &&
(
$this->hasTooManyProcessesRunning($rule, $profile) ||
$this->hasTooManySiblingProcessesRunning($rule, $profile)
)
) {
return false;
}
}
Expand Down Expand Up @@ -128,7 +133,8 @@ private function withinConstraints(Rule $rule, Profile $profile)
private function withinProcessorConstraints(Rule $rule, Profile $profile)
{
if ($rule->getMinimumProcessorUsage() !== null && $rule->getMaximumProcessorUsage() !== null) {
return $profile->getProcessorLoad() >= $rule->getMinimumProcessorUsage() && $profile->getProcessorLoad() <= $rule->getMaximumProcessorUsage();
return $profile->getProcessorLoad() >= $rule->getMinimumProcessorUsage() &&
$profile->getProcessorLoad() <= $rule->getMaximumProcessorUsage();
}

return false;
Expand All @@ -145,7 +151,8 @@ private function withinProcessorConstraints(Rule $rule, Profile $profile)
private function withinMemoryConstraints(Rule $rule, Profile $profile)
{
if ($rule->getMinimumMemoryUsage() !== null && $rule->getMaximumMemoryUsage() !== null) {
return $profile->getMemoryLoad() >= $rule->getMinimumMemoryUsage() && $profile->getMemoryLoad() <= $rule->getMaximumMemoryUsage();
return $profile->getMemoryLoad() >= $rule->getMinimumMemoryUsage() &&
$profile->getMemoryLoad() <= $rule->getMaximumMemoryUsage();
}

return false;
Expand All @@ -161,7 +168,8 @@ private function withinMemoryConstraints(Rule $rule, Profile $profile)
*/
private function hasTooManySiblingProcessesRunning(Rule $rule, Profile $profile)
{
return $this->withinSiblingConstraints($rule, $profile) && count($profile->getSiblingProcesses()) >= $rule->getProcesses();
return $this->withinSiblingConstraints($rule, $profile) &&
count($profile->getSiblingProcesses()) >= $rule->getProcesses();
}

/**
Expand All @@ -174,7 +182,8 @@ private function hasTooManySiblingProcessesRunning(Rule $rule, Profile $profile)
*/
private function withinSiblingConstraints(Rule $rule, Profile $profile)
{
return $this->withinSiblingProcessorConstraints($rule, $profile) || $this->withinSiblingMemoryConstraints($rule, $profile);
return $this->withinSiblingProcessorConstraints($rule, $profile) ||
$this->withinSiblingMemoryConstraints($rule, $profile);
}

/**
Expand All @@ -189,7 +198,8 @@ private function withinSiblingConstraints(Rule $rule, Profile $profile)
private function withinSiblingProcessorConstraints(Rule $rule, Profile $profile)
{
if ($rule->getMinimumSiblingProcessorUsage() !== null && $rule->getMaximumSiblingProcessorUsage() !== null) {
return $profile->getSiblingProcessorLoad() >= $rule->getMinimumSiblingProcessorUsage() && $profile->getSiblingProcessorLoad() <= $rule->getMaximumSiblingProcessorUsage();
return $profile->getSiblingProcessorLoad() >= $rule->getMinimumSiblingProcessorUsage() &&
$profile->getSiblingProcessorLoad() <= $rule->getMaximumSiblingProcessorUsage();
}

return false;
Expand All @@ -206,7 +216,8 @@ private function withinSiblingProcessorConstraints(Rule $rule, Profile $profile)
private function withinSiblingMemoryConstraints(Rule $rule, Profile $profile)
{
if ($rule->getMinimumSiblingMemoryUsage() !== null && $rule->getMaximumSiblingMemoryUsage() !== null) {
return $profile->getSiblingMemoryLoad() >= $rule->getMinimumSiblingMemoryUsage() && $profile->getSiblingMemoryLoad() <= $rule->getMaximumSiblingMemoryUsage();
return $profile->getSiblingMemoryLoad() >= $rule->getMinimumSiblingMemoryUsage() &&
$profile->getSiblingMemoryLoad() <= $rule->getMaximumSiblingMemoryUsage();
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/Handler/CallbackHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CallbackHandlerTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Manager/GroupProcessManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GroupProcessManagerTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Manager/ProcessManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ProcessManagerTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Manager/SynchronousManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SynchronousManagerTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Profile/InMemoryProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InMemoryProfileTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Rule/InMemoryRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class InMemoryRuleTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Rules/InMemoryRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InMemoryRulesTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Shell/BashShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BashShellTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Task/CallbackTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CallbackTaskTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Task/ProcessCallbackTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProcessCallbackTaskTest extends Test
/**
* @inheritdoc
*/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
4 changes: 2 additions & 2 deletions tests/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace AsyncPHP\Doorman\Tests;

use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

abstract class Test extends PHPUnit_Framework_TestCase
abstract class Test extends TestCase
{
/**
* Safely deletes a file.
Expand Down