Skip to content

Commit

Permalink
Fixes build
Browse files Browse the repository at this point in the history
  • Loading branch information
SmetDenis committed Apr 23, 2021
1 parent e63894e commit 8a95f11
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 7 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# JBZoo Toolbox - Retry
#
# This file is part of the JBZoo Toolbox project.
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#
# @package Retry
# @license MIT
# @copyright Copyright (C) JBZoo.com, All rights reserved.
# @link https://github.com/JBZoo/Retry
#

name: Continuous Integration

on:
pull_request:
branches:
- "*"
push:
branches:
- 'master'
schedule:
- cron: '15 */8 * * *'

env:
COLUMNS: 120
TERM_PROGRAM: Hyper

jobs:
phpunit:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ 7.2, 7.3, 7.4 ]
experimental: [ false ]
include:
- php-version: "8.0"
experimental: true
- php-version: "8.1"
experimental: true
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP and composer
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug
tools: composer

- name: Build the Project
continue-on-error: ${{ matrix.experimental }}
run: make build --no-print-directory

- name: 🧪 PHPUnit Tests
continue-on-error: ${{ matrix.experimental }}
run: make test --no-print-directory

- name: 👍 Code Quality
continue-on-error: ${{ matrix.experimental }}
run: make codestyle --no-print-directory

- name: 📝 Build All Reports at Once
continue-on-error: ${{ matrix.experimental }}
run: make report-all --no-print-directory
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ language: php
os: linux
dist: xenial

git:
depth: false

php:
- 7.2
- 7.3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},

"require-dev" : {
"jbzoo/toolbox-dev" : "^2.10.0",
"jbzoo/toolbox-dev" : "^2.11.0",
"jbzoo/jbdump" : ">=1.5.6"
},

Expand Down
6 changes: 4 additions & 2 deletions src/Retry.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Retry

/**
* This receive any exceptions we encounter.
* @var callable
* @var callable|null
*/
protected $errorHandler;

Expand Down Expand Up @@ -358,6 +358,7 @@ public function setErrorHandler(callable $callback): self
* Gets a default decider that simply check exceptions and maxattempts
* @return Closure
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @psalm-suppress MissingClosureParamType
*/
protected static function getDefaultDecider(): Closure
{
Expand Down Expand Up @@ -426,7 +427,8 @@ public function getWaitTime(int $attempt): int
*/
protected function cap(int $waitTime): int
{
return $this->getWaitCap() > 0 ? \min($this->getWaitCap(), $waitTime) : $waitTime;
$waitCap = (int)$this->getWaitCap();
return $waitCap > 0 ? \min($waitCap, $waitTime) : $waitTime;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/RetryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ public function testWaitLessOneSecond()

// We expect that this took just barely over the 100ms we asked for
isTrue(
$elapsedMS > 90 && $elapsedMS < 150,
"Expected elapsedMS between 90 & 150, got: {$elapsedMS}"
$elapsedMS > 90 && $elapsedMS < 175,
"Expected elapsedMS between 90 & 175, got: {$elapsedMS}"
);
}

Expand All @@ -211,8 +211,8 @@ public function testWaitMoreOneSecond()

// We expect that this took just barely over the 100ms we asked for
isTrue(
$elapsedMS > 1200 && $elapsedMS < 1300,
"Expected elapsedMS between 90 & 150, got: {$elapsedMS}"
$elapsedMS > 1200 && $elapsedMS < 1400,
"Expected elapsedMS between 1200 & 1400, got: {$elapsedMS}"
);
}

Expand Down

0 comments on commit 8a95f11

Please sign in to comment.