Skip to content

Commit

Permalink
Merge pull request #17 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 Feb 14, 2020
2 parents b636f50 + 09cc3e4 commit 4418b2c
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 64 deletions.
10 changes: 5 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hasher [![Packagist License][badge_license]](LICENSE.md) [![For Laravel][badge_laravel]][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 All @@ -14,9 +14,9 @@

The Hasher package provides a flexible hash manager for Laravel.

This package offers [Hashids](https://github.com/ivanakimov/hashids.php) as default driver with multiple connections.
This package offers [Hashids](https://github.com/ivanakimov/hashids.php) as default driver with multiple connections.

> Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers.
> Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers.
Feel free to check out the [releases](https://github.com/ARCANEDEV/Hasher/releases), [license](LICENSE.md), and [contribution guidelines](CONTRIBUTING.md).

Expand Down Expand Up @@ -50,8 +50,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.

[badge_license]: https://img.shields.io/packagist/l/arcanedev/hasher.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.x%20|%206.x-orange.svg?style=flat-square

[badge_build]: https://img.shields.io/travis/ARCANEDEV/Hasher.svg?style=flat-square
[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/Hasher/run-tests?style=flat-square
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/Hasher.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/Hasher.svg?style=flat-square
[badge_insight]: https://img.shields.io/sensiolabs/i/0c427742-b488-4bff-87ed-cb1d59217d20.svg?style=flat-square
Expand All @@ -63,9 +62,9 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.

[link-author]: https://github.com/arcanedev-maroc
[link-github-repo]: https://github.com/ARCANEDEV/Hasher
[link-github-status]: https://github.com/ARCANEDEV/Hasher/actions
[link-github-issues]: https://github.com/ARCANEDEV/Hasher/issues
[link-contributors]: https://github.com/ARCANEDEV/Hasher/graphs/contributors
[link-packagist]: https://packagist.org/packages/arcanedev/hasher
[link-travis]: https://travis-ci.org/ARCANEDEV/Hasher
[link-scrutinizer]: https://scrutinizer-ci.com/g/ARCANEDEV/Hasher/?branch=master
[link-insight]: https://insight.sensiolabs.com/projects/0c427742-b488-4bff-87ed-cb1d59217d20
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"license": "MIT",
"require": {
"php": ">=7.2.0",
"arcanedev/support": "^5.0",
"arcanedev/support": "^5.1.1",
"hashids/hashids": "^4.0"
},
"require-dev": {
Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/HashDriver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher\Contracts;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher\Contracts;

/**
* Interface HashDriver
Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/HashManager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher\Contracts;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher\Contracts;

/**
* Interface HashManager
Expand Down
6 changes: 5 additions & 1 deletion src/Drivers/HashidsDriver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher\Drivers;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher\Drivers;

use Arcanedev\Hasher\Contracts\HashDriver;
use Hashids\Hashids;
Expand Down
10 changes: 7 additions & 3 deletions src/HashManager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher;

use Arcanedev\Hasher\Contracts\HashManager as HashManagerContract;
use Illuminate\Contracts\Container\Container;
Expand Down Expand Up @@ -51,7 +55,7 @@ public function __construct(Container $container)
*
* @return string
*/
public function getDefaultDriver()
public function getDefaultDriver(): string
{
return $this->config('default.driver');
}
Expand All @@ -61,7 +65,7 @@ public function getDefaultDriver()
*
* @return string
*/
public function getDefaultOption()
public function getDefaultOption(): string
{
return $this->option ?? $this->config('default.option', 'main');
}
Expand Down
7 changes: 5 additions & 2 deletions src/HasherServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher;

use Arcanedev\Support\Providers\PackageServiceProvider as ServiceProvider;
use Illuminate\Contracts\Support\DeferrableProvider;
Expand Down Expand Up @@ -37,7 +41,6 @@ public function register(): void

$this->registerConfig();

// Services
$this->singleton(Contracts\HashManager::class, HashManager::class);
}

Expand Down
6 changes: 5 additions & 1 deletion tests/Drivers/HashidsDriverTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher\Tests\Drivers;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher\Tests\Drivers;

use Arcanedev\Hasher\Drivers\HashidsDriver;
use Arcanedev\Hasher\Tests\TestCase;
Expand Down
26 changes: 15 additions & 11 deletions tests/HasherManagerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher\Tests;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher\Tests;

/**
* Class HasherManagerTest
Expand Down Expand Up @@ -41,7 +45,7 @@ protected function tearDown(): void
*/

/** @test */
public function it_can_be_instantiated()
public function it_can_be_instantiated(): void
{
$expectations = [
\Arcanedev\Hasher\Contracts\HashManager::class,
Expand All @@ -54,27 +58,27 @@ public function it_can_be_instantiated()
}

/** @test */
public function it_can_get_default_driver()
public function it_can_get_default_driver(): void
{
static::assertSame('hashids', $this->manager->getDefaultDriver());
}

/** @test */
public function it_can_get_default_option()
public function it_can_get_default_option(): void
{
static::assertSame('main', $this->manager->getDefaultOption());
}

/** @test */
public function it_can_set_default_option()
public function it_can_set_default_option(): void
{
$this->manager->option('alt');

static::assertSame('alt', $this->manager->getDefaultOption());
}

/** @test */
public function it_can_get_hash_driver_without_name()
public function it_can_get_hash_driver_without_name(): void
{
$driver = $this->manager->driver();

Expand All @@ -89,7 +93,7 @@ public function it_can_get_hash_driver_without_name()
}

/** @test */
public function it_can_get_hash_driver_with_name()
public function it_can_get_hash_driver_with_name(): void
{
$driver = $this->manager->driver('custom');

Expand All @@ -104,7 +108,7 @@ public function it_can_get_hash_driver_with_name()
}

/** @test */
public function it_can_get_hash_driver_with_name_and_option()
public function it_can_get_hash_driver_with_name_and_option(): void
{
$driver = $this->manager->with('alt', 'custom');

Expand All @@ -121,7 +125,7 @@ public function it_can_get_hash_driver_with_name_and_option()
}

/** @test */
public function it_can_encode_and_decode()
public function it_can_encode_and_decode(): void
{
$value = 123456;
$mainDriver = $this->manager->option('main')->driver();
Expand All @@ -138,7 +142,7 @@ public function it_can_encode_and_decode()
}

/** @test */
public function it_can_encode_and_decode_with_helper()
public function it_can_encode_and_decode_with_helper(): void
{
$value = 123456;
$mainDriver = hasher()->with('main');
Expand All @@ -155,7 +159,7 @@ public function it_can_encode_and_decode_with_helper()
}

/** @test */
public function it_can_encode_and_decode_from_manager()
public function it_can_encode_and_decode_from_manager(): void
{
$value = 123456;
$hashed = $this->manager->encode($value);
Expand Down
10 changes: 7 additions & 3 deletions tests/HasherServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher\Tests;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher\Tests;

use Arcanedev\Hasher\HasherServiceProvider;

Expand Down Expand Up @@ -43,7 +47,7 @@ protected function tearDown(): void
*/

/** @test */
public function it_can_be_instantiated()
public function it_can_be_instantiated(): void
{
$expectations = [
\Illuminate\Support\ServiceProvider::class,
Expand All @@ -59,7 +63,7 @@ public function it_can_be_instantiated()
}

/** @test */
public function it_can_provides()
public function it_can_provides(): void
{
$expected = [
\Arcanedev\Hasher\Contracts\HashManager::class,
Expand Down
6 changes: 5 additions & 1 deletion tests/Stubs/CustomHasherClient.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\Hasher\Tests\Stubs;
<?php

declare(strict_types=1);

namespace Arcanedev\Hasher\Tests\Stubs;

use Arcanedev\Hasher\Contracts\HashDriver;
use Illuminate\Support\Arr;
Expand Down

0 comments on commit 4418b2c

Please sign in to comment.