Skip to content

Commit

Permalink
Merge pull request #95 from ARCANEDEV/update-github_actions
Browse files Browse the repository at this point in the history
Using GitHub Actions for testing
  • Loading branch information
arcanedev-maroc committed Jan 31, 2020
2 parents 007d706 + 27b1864 commit a2e3d6f
Show file tree
Hide file tree
Showing 33 changed files with 407 additions and 293 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Expand Up @@ -8,6 +8,5 @@
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore
CONTRIBUTING.md export-ignore
46 changes: 46 additions & 0 deletions .github/workflows/run-tests.yml
@@ -0,0 +1,46 @@
name: run-tests

on: [push]

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4]
laravel: [6.*]
dependency-version: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: xdebug

- name: Install dependencies
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest

- name: Execute tests
run: |
mkdir -p build/logs
vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- name: Scrutinizer CI
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Expand Up @@ -22,7 +22,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 2
runs: 6
php_code_sniffer:
enabled: true
config:
Expand Down
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
@@ -1,6 +1,6 @@
# noCAPTCHA (new reCAPTCHA) [![Packagist License][badge_license]](LICENSE.md) [![For PHP][badge_php]][link-github-repo]

[![Travis Status][badge_build]][link-travis]
[![Github Workflow Status][badge_build]][link-github-status]
[![Coverage Status][badge_coverage]][link-scrutinizer]
[![Scrutinizer Code Quality][badge_quality]][link-scrutinizer]
[![SensioLabs Insight][badge_insight]][link-insight]
Expand Down Expand Up @@ -55,7 +55,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.

[badge_php]: https://img.shields.io/badge/PHP-Framework%20agnostic-4F5B93.svg?style=flat-square
[badge_license]: https://img.shields.io/packagist/l/arcanedev/no-captcha.svg?style=flat-square
[badge_build]: https://img.shields.io/travis/ARCANEDEV/noCAPTCHA.svg?style=flat-square
[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/noCAPTCHA/run-tests?style=flat-square
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/noCAPTCHA.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/noCAPTCHA.svg?style=flat-square
[badge_insight]: https://img.shields.io/sensiolabs/i/ae37b4c0-5478-4afb-9a71-1fe5534d8ef5.svg?style=flat-square
Expand All @@ -65,10 +65,10 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.
[badge_downloads]: https://img.shields.io/packagist/dt/arcanedev/no-captcha.svg?style=flat-square

[link-author]: https://github.com/arcanedev-maroc
[link-github-status]: https://github.com/ARCANEDEV/noCAPTCHA/actions
[link-github-repo]: https://github.com/ARCANEDEV/noCAPTCHA
[link-github-issues]: https://github.com/ARCANEDEV/noCAPTCHA/issues
[link-contributors]: https://github.com/ARCANEDEV/noCAPTCHA/graphs/contributors
[link-packagist]: https://packagist.org/packages/arcanedev/no-captcha
[link-travis]: https://travis-ci.org/ARCANEDEV/noCAPTCHA
[link-scrutinizer]: https://scrutinizer-ci.com/g/ARCANEDEV/noCAPTCHA/?branch=master
[link-insight]: https://insight.sensiolabs.com/projects/ae37b4c0-5478-4afb-9a71-1fe5534d8ef5
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -18,11 +18,11 @@
"ext-curl": "*",
"ext-json": "*",
"arcanedev/php-html": "^3.0",
"arcanedev/support": "^5.0",
"arcanedev/support": "^5.1",
"psr/http-message": "^1.0"
},
"require-dev": {
"orchestra/testbench": "^4.0",
"orchestra/testbench": "^4.5",
"phpunit/phpunit": "^8.0",
"phpunit/phpcov": "^6.0"
},
Expand Down
16 changes: 10 additions & 6 deletions src/AbstractNoCaptcha.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha;

use Arcanedev\NoCaptcha\Utilities\Request;
use Illuminate\Support\HtmlString;
Expand Down Expand Up @@ -243,7 +247,7 @@ public function verifyRequest(ServerRequestInterface $request)
*
* @param array $query
*
* @return \Arcanedev\NoCaptcha\Utilities\ResponseV3
* @return \Arcanedev\NoCaptcha\Contracts\Utilities\Response
*/
protected function sendVerifyRequest(array $query = [])
{
Expand All @@ -260,7 +264,7 @@ protected function sendVerifyRequest(array $query = [])
*
* @param string $json
*
* @return \Arcanedev\NoCaptcha\Utilities\AbstractResponse|mixed
* @return \Arcanedev\NoCaptcha\Contracts\Utilities\Response|mixed
*/
abstract protected function parseResponse($json);

Expand All @@ -285,7 +289,7 @@ protected function hasLang()
* @param string $name
* @param string $value
*/
private static function checkKey($name, &$value)
private static function checkKey($name, &$value): void
{
self::checkIsString($name, $value);

Expand All @@ -302,7 +306,7 @@ private static function checkKey($name, &$value)
*
* @throws \Arcanedev\NoCaptcha\Exceptions\ApiException
*/
private static function checkIsString($name, $value)
private static function checkIsString($name, $value): void
{
if ( ! is_string($value)) {
throw new Exceptions\ApiException(
Expand All @@ -319,7 +323,7 @@ private static function checkIsString($name, $value)
*
* @throws \Arcanedev\NoCaptcha\Exceptions\ApiException
*/
private static function checkIsNotEmpty($name, $value)
private static function checkIsNotEmpty($name, $value): void
{
if (empty($value)) {
throw new Exceptions\ApiException("The {$name} must not be empty");
Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/NoCaptcha.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Contracts;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Contracts;

use Arcanedev\NoCaptcha\Contracts\Utilities\Request;

Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/NoCaptchaManager.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Contracts;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Contracts;

/**
* Interface NoCaptchaManager
Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/Utilities/Request.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Contracts\Utilities;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Contracts\Utilities;

/**
* Interface RequestInterface
Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/Utilities/Response.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Contracts\Utilities;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Contracts\Utilities;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
Expand Down
6 changes: 5 additions & 1 deletion src/Exceptions/ApiException.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Exceptions;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Exceptions;

/**
* Class ApiException
Expand Down
6 changes: 5 additions & 1 deletion src/Exceptions/InvalidArgumentException.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Exceptions;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Exceptions;

/**
* Class InvalidArgumentException
Expand Down
6 changes: 5 additions & 1 deletion src/Exceptions/InvalidUrlException.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Exceptions;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Exceptions;

/**
* Class InvalidUrlException
Expand Down
6 changes: 5 additions & 1 deletion src/Exceptions/NoCaptchaException.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha\Exceptions;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Exceptions;

/**
* Class NoCaptchaException
Expand Down
8 changes: 6 additions & 2 deletions src/NoCaptchaManager.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha;

use Illuminate\Support\Manager;
use Arcanedev\NoCaptcha\Contracts\{
Expand Down Expand Up @@ -96,6 +100,6 @@ protected function buildDriver(string $driver): NoCaptchaContract
*/
protected function config(string $key = '')
{
return $this->container['config']->get("no-captcha.{$key}");
return $this->config->get("no-captcha.{$key}");
}
}
6 changes: 5 additions & 1 deletion src/NoCaptchaServiceProvider.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha;

use Arcanedev\Support\Providers\PackageServiceProvider as ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
Expand Down
23 changes: 13 additions & 10 deletions src/NoCaptchaV2.php
@@ -1,7 +1,10 @@
<?php namespace Arcanedev\NoCaptcha;
<?php

use Arcanedev\Html\Elements\Button;
use Arcanedev\Html\Elements\Div;
declare(strict_types=1);

namespace Arcanedev\NoCaptcha;

use Arcanedev\Html\Elements\{Button, Div};
use Arcanedev\NoCaptcha\Exceptions\InvalidArgumentException;
use Arcanedev\NoCaptcha\Utilities\ResponseV2;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -154,7 +157,7 @@ public function getApiScript()
captchas: [],
reset: function(name) {
var captcha = window.noCaptcha.get(name);
if (captcha)
window.noCaptcha.resetById(captcha.id);
},
Expand All @@ -179,9 +182,9 @@ public function getApiScript()
id: grecaptcha.render(name, {'sitekey' : sitekey}),
name: name
};
window.noCaptcha.captchas.push(captcha);
return captcha;
}
}
Expand Down Expand Up @@ -223,7 +226,7 @@ public function scriptWithCallback(array $captchas, $callbackName = 'captchaRend
*
* @return string
*/
private function renderCaptchas(array $captchas)
private function renderCaptchas(array $captchas): string
{
return implode(PHP_EOL, array_map(function($captcha) {
return "if (document.getElementById('{$captcha}')) { window.noCaptcha.render('{$captcha}', '{$this->siteKey}'); }";
Expand All @@ -242,7 +245,7 @@ private function renderCaptchas(array $captchas)
*
* @return bool
*/
private function hasCallbackName($callbackName)
private function hasCallbackName($callbackName): bool
{
return ! (is_null($callbackName) || trim($callbackName) === '');
}
Expand Down Expand Up @@ -271,7 +274,7 @@ protected function parseResponse($json)
*
* @return array
*/
private function prepareAttributes(array $attributes)
private function prepareAttributes(array $attributes): array
{
$attributes = array_merge(
['class' => 'g-recaptcha', 'data-sitekey' => $this->siteKey],
Expand All @@ -294,7 +297,7 @@ private function prepareAttributes(array $attributes)
* @param array $supported
* @param string $default
*/
private static function checkDataAttribute(array &$attributes, $name, array $supported, $default)
private static function checkDataAttribute(array &$attributes, $name, array $supported, $default): void
{
$attribute = $attributes[$name] ?? null;

Expand Down
6 changes: 5 additions & 1 deletion src/NoCaptchaV3.php
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\NoCaptcha;
<?php

declare(strict_types=1);

namespace Arcanedev\NoCaptcha;

use Arcanedev\Html\Elements\Input;
use Arcanedev\NoCaptcha\Utilities\ResponseV3;
Expand Down
9 changes: 6 additions & 3 deletions src/Utilities/AbstractResponse.php
@@ -1,7 +1,10 @@
<?php namespace Arcanedev\NoCaptcha\Utilities;
<?php

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
declare(strict_types=1);

namespace Arcanedev\NoCaptcha\Utilities;

use Illuminate\Contracts\Support\{Arrayable, Jsonable};
use JsonSerializable;

/**
Expand Down

0 comments on commit a2e3d6f

Please sign in to comment.